java创建坐标原点,Java语言约定,坐标原点位于绘图区域的____

1、[单选题]在编写访问数据库的 Java 程序时,Connection 对象的作用是(  )

A、存储查询结果

B、在指定的连接中处理 SQL 语句

C、用来表示与数据库的连接

D、用来创建数据库的连接

2、[填空题]注册鼠标点击事件监视器的方法是___________。

3、[主观题]【程序分析题】阅读下列程序,请写出该程序的功能。

import java.io.*; import java.awt.*; import javax.swing.*; import java.awt.event.*;

class MyWindow extends JFrame implements ActionListener{

JTextArea text;BufferedReader in;JTextField fileName; FileReader file;

MyWindow(){

Container con=this.getContentPane();//获得内容面板

con.setLayout(new BorderLayout());

fileName=new JTextField("输入文件名"); fileName.addActionListener(this); text=new JTextArea(20,30); JScrollPane jsp:new JScrollPane(text); con.add(jsp,BorderLayout.CENTER);

con.add(fileName,"South");setVisible(true);

}

public void actionPerformed(ActionEvent e)

{ String s; try{File f=new File(fileName.getText()); file=new FileReader(f); in=new BufferedReader(file); } catch(FileNotFoundException el){} try{ while((s=in.readLine())!=null) text.append(s+'\n');

}catch(IOException exp){}

}

}

public class Test34{ public static void main(String args[ ]) {new MyWindow();}

}

4、[主观题]【程序分析题】阅读下列程序,请写出该程序的输出结果。

class MyThread extends Thread {

String message; int s;

MyThread(String message, int sec) { this.message = message; s = sec; }

public void run( ) {

try{ sleep(s); }catch(InterruptedException e){}

System.out.println(message+" "+getPriority( ));

}

}

class ThreadTest {

public static void main(String args[]){

Thread foo = new MyThread("Foo", 1000);

foo.setPriority(Thread.MIN_PRIORITY); foo.start( );

Thread bar = new MyThread("Bar",800);

bar.setPriority(3); bar.start( );

Thread gar = new MyThread("Gar",400);

gar.setPriority(7); gar.start( );

Thread kar = new MyThread("Kar", 100);

kar.setPriority(Thread. MAX_PRIORITY); kar.start( );

}

)

注:假设处理机中没有其它线程占用资源。

5、[主观题]【程序分析题】阅读下列程序,请写出该程序的输出结果。

class Test32a {

String name; int age; long number;

Test32a(long number, String name,int age) {

System.out.println("Name: "+name);

System. out. println("Age: "+age);

System.out.println("Tel: " +number);

}

}

class Test32b extends Test32a {

Test32b(long number, String name,int age,boolean b) {

super(number, name,age); System.out.println("Married: "+b);

}

}

public class Test32 {

public static void main(String args[]) {

Test32b abe=new Test32b(4747,"Tony",29,true);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值