选择题(六)

151.给出下面代码:
  1) class Parent {
  
2} private String name;
  
3} public Parent(){}
  
4} }
  
5) public class Child extends Parent {
  
6} private String department;
  
7} public Child() {}
  
8} public String getValue(){ return name; }
  
9} public static void main(String arg[]) {
  
10} Parent p = new Parent();
  
11} }
  
12} }
  那些行将引起错误? (      )

A、 第3 B、 第6 C、 第7 D、 第8

152.
TeacherStudent是类Person的子类;
   
Person p;
   
Teacher t;
   
Student s;
   
//p, t and s are all non-null.
   
if(t instanceof Person) { s = (Student)t; }
  最后一句语句的结果是:

A、 将构造一个Student对象; B、 表达式是合法的;

C、 表达式是错误的;        D、 编译时正确,但运行时错误。

153.
给出下面代码段

  
1) public class Test {
  
2} int m, n;
  
3} public Test() {}
  
4} public Test(int a) { m=a; }
  
5} public static void main(String arg[]) {
  
6} Test t1,t2;
  
7} int j,k;
  
8} j=0; k=0;
  
9} t1=new Test();
  
10} t2=new Test(j,k);
  
11} }
  
12} }
  哪行将引起一个编译时错误? (      )

A line 3 B line 5 C line 6 D line 10

154.
对于下列代码: (      )

  1) class Person {
  
2) public void printValue(int i, int j) {//... }
  
3) public void printValue(int i){//... }
  
4) }
  
5) public class Teacher extends Person {
  
6) public void printValue() {//... }
  
7) public void printValue(int i) {//...}
  
8) public static void main(String args[]){
  
9) Person t = new Teacher();
  
10) t.printValue(10);
  
11) }
  第10行语句将调用哪行语句??

A line 2 B line 3 C line 6 D line 7

155.
哪个关键字可以抛出异常?(      )  

A transient B finally C throw D static

156.Main()
方法的返回类型是:(      )  

A int B void C boolean D static

157.System
类在哪个包中? (      )

A java.util B java.io C java.awt D java.lang

158.
对于下列代码:

  
public class Parent {
   
public int addValue( int a, int b) {
     
int s;
     
s = a+b;
     
return s;
   
}
  
}
  
class Child extends Parent {
  
}
 下述哪些方法可以加入类Child? (      )

A int addValue( int a, int b ){// do something...}

B public void addValue (int a, int b ){// do something...}

C public int addValue( int a ){// do something...}

D public int addValue( int a, int b )throws MyException {//do something...}

159.
给出下面代码:

  
public class test{
   
static int a[] = new a[10];
   
public static void main(String args[]) {
    
System.out.println(arr[10]);
   
}
  
}
那个选项是正确的? (      )


A
、 编译时将产生错误; B、 编译时正确,运行时将产生错误;

C、 输出零;           D、 输出空。

160.
下面哪些选项是正确的main方法说明? (      )

A public main(String args[])     B public static void main(String args[])

C private static void main(String args[])   D void main()

161.Java语言具有许多优点和特点,下列选项中,哪个反映了Java程序并行机制的特点(  )

A 安全性    B 多线程    C 跨平台    D 可移植

162.下列哪个类声明是正确的(  )

A abstract final class H1{…} B abstract private move(){…}

C protected private number    D public abstract class Car{…}

163.下列关于for循环和while循环的说法中哪个是正确的(  )

A while循环能实现的操作,for循环也都能实现

B while循环判断条件一般是程序结果,for循环判断条件一般是非程序结果

C 两种循环任何时候都可替换

D 两种循环结构中都必须有循环体,循环体不能为空

164.异常包含下列哪些内容(  )

A 程序中的语法错误                         B 程序的编译错误

C 程序执行过程中遇到的事先没有预料到的情况 D 程序事先定义好的可能出现的意外情况

165.Character流与Byte流的区别是(  )

 

A 每次读入的字节数不同           B 前者带有缓冲,后者没有

C 前者是块读写,后者是字节读写   D 二者没有区别,可以互换使用

166.监听事件和处理事件(  )

A 都由Listener完成          B 都由相应事件Listener处登记过的构件完成

C Listener和构件分别完成  D Listener和窗口分别完成

167.Applet可以做下列哪些操作(  )

A 读取客户端文件

B 在客户端主机上创建新文件

C 在客户端装载程序库

D 读取客户端部分系统变量

168.下列哪个属于容器的构件(  )

A JFrame

B JButton

C JPnel

D JApplet

169.如果希望所有的控件在界面上均匀排列,应使用下列哪种布局管理器(  )

A BoxLayout

B GridLayout

C BorderLayout

D FlowLayout

170.为实现多线程之间的通信,需要使用下列哪种流才合适(  )

A Filter stream

B File stream

C Random access stream

D Piped stream

171.函数重载是指 ( )
A.
两个或两个以上的函数取相同的函数名,但形参的个数或类型不同
B.
两个以上的函数取相同的名字和具有相同的参数个数,但形参的类型可以不同
C.
两个以上的函数名字不同,但形参的个数或类型相同
D.
两个以上的函数取相同的函数名,并且函数的返回类型相同
172.指出下列程序运行的结果( )
public class Example{
String str=new String(″good″);
char
[]ch={′a′,′b′,′c′};
public static void main(String args
[]){
Example ex=new Example();
ex.change(ex.str,ex,ch);
System.out.print(ex.str+″and″);
System.out.print(ex.ch);
}
public void change(String str,char ch
[]){
str=″test ok″;
ch
0=′g′;
}
}
A.good and abc
            B.good and gbc
C.test ok and abc
        D.test ok and gbc


173.
运行下列程序,会产生的结果是(    )
public class X extends Thread implements Runable{
public void run(){
System.out.println(″this is run()″);
}
public static void main(String args
[])
}
Thread t=new Thread(new X());
t.start();
}
}


A.
第一行会产生编译错误         B.第六行会产生编译错误
C.
第六行会产生运行错误          D.程序会运行和启动


174.
对于catch子句的排列,下列哪种是正确的(    )


A.
父类在先,子类在后


B.
子类在先,父类在后


C.
有继承关系的异常不能在同一个try程序段内


D.
先有子类,其他如何排列都无关 


175.Java
中,数值类型值中可能出现的符号是(    )


A.R
    B.D   C.T   D.Y


176.
构造方法何时被调用(    )


A.
类定义时           B.创建对象时
C.
调用对象方法时        D.使用对象的变量时


177.
下面的表达式中正确的是( )


A.String s=″
你好″;int i=3;s+=i;


B.String s=″
你好″;int i=3;if(i==s){s+=i};


C.String s=″
你好″;int i=3;s=i+s;


D.String s=″
你好int i=3;s=i+;


178.
哪个布局管理器使用的是组件的最佳尺寸(    )


A.FlowLayout
          B.BorderLayout
C.GridLayout
          D.CardLayout


179.
在异常处理中,如释放资源、关闭文件、关闭数据库等由( )来完成。


A.try
子句           B.catch子句
C.finally
子句         D.throw子句


180.
要从文件″file.dat″文件中读出第10个字节到变量C中,下列哪个方法适合( )


A.FileInputStream in=new FileInputStream(″file.dat″);in.skip9.;int c=in.read();


B.FileInputStream in=new FileInputStream(″file.dat″);in.skip10.;int c=in.read();


C.FileInputStream in=new FileInputStream(″file.dat″);int c=in.read();


D.RandomAccssFile in=RandomAccssFile(″file.dat″);in.skip9.;int c=in.readByte();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值