纠错
全专业资料、题库、学位、网课
最高直省2344元
上千+科次精品网课
买网课即送全真模考题库
五千+科次教材资料
电子资料满三件9折
五千+科次在线题库
全真呈现历年考试试题
1、[填空题]设有字符串定义:Strings = "12341234";则表达式s.indexOf("2")的值是______。
2、[主观题]【程序设计题】某应用程序的界面如下图所示,有3个文本框,第一个文本框对象为tl,第二个文 本框对象为t2,第三个文本框对象为r。程序对前两个文本框作事件监视。程序运行 时,当前两个文本框有整数输入时,在第三个文本框输出它们的和。要求编写实现 上述功能的方法 actionPerformed(ActionEvent e)。
public void actionPerformed(ActionEvent e){
//请在以下位置编写代码
3、[主观题]【程序填空题】以下是一个放幻灯片的应用程序,程序的界面中含一个面板子类P的对象和一个按 钮对象b。设幻灯片已经装人内存,并存放于mylmage数组中,幻灯片的张数存于 变量mim中。程序运行时,用户点击按钮b,按钮的监视方法循环更换幻灯片号 curlmage,并让系统调用P重定义的paintComponent〇方法显示当前幻灯片。
int curlmage = 0; final int num = 30;
Image [ ] mylmage = new Image [num];
//以下是类P内定义的两个方法
public void actionPerformed(ActionEvent e){
if (e.getSource() = b) {
________________________
curlmage = (curlmage + 1) % num;
try {mythread.sleep(200);
} catch (InterruptedException e) {}
}
public void paintComponent(Graphics g) {
if ((mylmage [curlmage]) != null)
g.__________ (mylmage [curlmage], 10, 10,
mylmage[curlmage].getWidth()
mylmage [curImage].getHeight(), this);
4、[主观题]【程序分析题】阅读下列程序,请写出该程序的功能。
import java.util.*; import java.io.*;
import java.awt.*;import javax.swing.*;import java.awt.event. *;
class MyFrame extends JFrame implements ActionListener {
JText Area text;
JTextField tf; Buffered Writer out;
MyFrame () {
super("—个测试程序");
Container con = getContentPane();
text = new JTextArea(10, 20);
text.setBackground(Color.cya^);
tf = new JTextField();
tf.addActionListener(this);
con.setLayout(new BorderLayout())
con.add(text, ’’Center"); con.add(tf, "South");
setVisible(true); pack();
}
public void actionPerformed(ActionEvent e)
{ if (e.getSource() == tf) {
try {
out = new BufferedWriter(new FileWriter(tf.getText()));
StringTokenizer tokens=new StringTokenizer(text.getText());
int n = tokens.countTokens(), i;
for(i = 0; i < n; i++){
out. write(tokens.nextT oken()+”\r\n");
out.flush(); text.setText(null); System.exit(O);
} catch (IOException exp) {
text.setText("文件写出错! \n");
}
}
}
ptr c class Test36{
public static void main(String args[])
{ new MyFrameQ;
5、[主观题]【程序分析题】.阅读下列程序段,请写出标有注解(1)、(2)和(3)语句的作用。
Image img[];
public void int(){
img=new Image[15];
for (int i=0;i<15;i++){
img[i]=getImage(getCodeBase(),’’img"+i+".jpg"); // (1)
}
public void paint(Graphics g){ int i=0, k=0;
while(k<15000){;//语句略
g.drawlmage(img[i],0,0,this); //(2)
k++;
for(intj=0;j<5000000;j++){} //(3)
i = (i+1)% img.length;
}
}
Copyright © 2010 - 2023 湖南求实创新教育科技有限公司 All Right Reserved.
温馨提示:如您需要的资料本网暂时没有,请于工作日08:00-18:00,点击这里,联系客服及时补充资料。