选择题(四)
92.下面关于Applet的说法正确的是 (??? )
A、 Applet也需要main方法
B、 Applet必须继承自java.awt.Applet
C、 Applet能访问本地文件
D、 Applet程序不需要编译
93.看下面一段程序:
class Aclass{
void go(){
System.out.println("Aclass");
}
}
public class Bclass extends Aclass{
void go{
System.out.println("Bclass");
}
public static void main(String args[]){
Aclass a=new Aclass();
Aclass a1=new Bclass();
a.go();
a1.go();
}
以上程序运行结果是:
A、 Aclass
Aclass
B、 Bclass
Bclass
C、 Aclass
Bclass
D、 Bclass
Aclass
94.下列关于Java线程的说法那些是正确的(??? )
A、 每一个Java线程可以看成由代码、一个真实的CPU以及数据三部份组成。
B、 创建线程的两种方法中,从Thread类中继承的创建方式可以防止出现多父类问题。
C、 Thread类属于java.util程序包。
D、 以上说法无一正确。
95.看以下程序:
boolean a=false;
boolean b=true;
boolean c=(a&&b)&&(!b);
int result=c==false?1:2;
这段程序执行完后,c与result的值是: ( ??)
A、 c=false;result=1;
B、 c=true;result=2;
C、 c=true;result=1;
D、 c=false;result=2;
96.运行下列程序, 会产生什么结果 ( ??)
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、 in the Inner outer
B、 outer
C、 in the Inner
D、编译不通过
97.指出下列程序的运行结果 ( ??)
int i = 9;
switch (i) {
default:
System.out.println("default");
case 0:
System.out.println("zero");
break;
case 1:
System.out.println("one");
case 2:
System.out.println("two");
}
A、 default
B、 default, zero
C、 error default clause not defined
D、 no output displayed那个
98.运行下列程序,会产生什么结果: ( ??)
class Outer1{
private int a;
void foo(double d,final float f){
String s;
final boolean b;
class Inner{
void methodInner(){
System.out.println("in the Inner");
}
}
}
public static void main(String args[])
{
Outer1 me=new Outer1();
me.foo(123,123);
System.out.println("outer");
}
}
A、 in the Inner outer
B、 outer
C、 in the Inner
D、 编译不通过
99. 下面哪个单词是Java语言的关键字(???? )
A、Float????? B、this?????? C、string???? D、unsigned??????
?
100. 下面哪个是Java语言中正确的标识符(???? )
A、3com?????? B、import???? C、that?????????? D、this
?
101. 下面哪个语句不能定义一个字符变量(????? )
A、char c1=06477;?????????? B、char c2=’\uface’ ;
C、char c4=0xbeef ;???????????? D、char c3=\u0041;
?
102. 下面哪个修饰符修饰的方法只能被本类中的其他方法使用(????? )
A、protected???????? B、static??????????? C、private??? D、public
?
103. 下面哪个运算后结果为32? (?????? )
A、2^5??????? B、(8>>2)<<4????? C、2>>5?????????? D、 (2<<1)*(32>>3)
?
104. 下面哪个是对字符串String的正确定义(????? )
A、String s1=null;???????????????? B、String s2=’null’ ;????
C、String s3=(String) ‘abc’ ;??? D、String s4=(String) ‘\uface’;
?
105. 下面哪条语句不能定义一个float型的变量(????? )
A、float f1= -343 ;??????????????? B、float f2=3.14 ;??????
C、float f3=0x12345 ; ???????????? D、float f4=2.8F ;??????
?
106. 下面哪条语句定义了5个元素的数组(????? )
A、int [] a={22,23,24,25,12};
B、int a []=new int(5);
C、int [5] array;
D、int [] arr;
?
107. 下面哪个范围是char型的取值范围(?????? )
A、-256 ~ 255?????????????????? B、-(2^15) ~ (2^15)-1?????? C、’\u0000’ ~ ‘\uffff’????? D、??? 0~32767
?
108. 给出一段程序,选择运行结果
public class sss {
public static void main(String args[])
{
?? String s1=args[1];??? String s2=args[2];
?? String s3=args[3];??? String s4=args[4];
?? System.out.println(“args[2]=”+s2);
}
}
命令行执行:? java sss 1 2 3 4?? 结果是下面哪一个?(? ???)
A、args[2]=2???????? B、args[2]=null????? C、args[2]=1????? D、运行出现异常??
?
109. 下面哪个描述是正确的(???? )
A、Applet程序中不需要main()方法,也不能有
B、Application程序中可以没有main()方法。
C、Applet程序中可以不定义init( )方法
D、Application程序中必须有run( )方法????
?
110. 给出一段程序,试判断哪个是正确的结果(????? )
public class rtExcept{
??? public static void throwit(){
System.out.print(“throwit”);
throw new RuntimeException();? }
??? public static void main(String [] aa){
?????? try{
?????????? System.out.print(“hello “);
?????????? throwit(); }
?????? catch(Exception re){
?????? System.out.print(“caught ”);? }
?????? finally{
?????? System.out.print(“finally ”); }
?????? System.out.print(“after ”);
??? }
}
A、hello throwit caught
B、hello throwit caught finally after
C、hello throwit RuntimeException after
D、hello throwit caught finally after RuntimeException
?
111. 对一个java源文件 aaa.java,编辑保存后但未编译,在其所在目录下执行 java aaa,则接着会出现什么(????? )
A、error: cannot read: aaa.java
B、无任何显示
C、Exception in thread "main" java.lang.NoClassDefFoundError: aaa
D、程序正常执行并显示
112. 编译java程序时出现error: cannot read: aaa.java,则下列原因最正确的是(????? )
A、原因是执行的当前目录下没有找到aaa.java文件。
B、原因是没有安装JDK开发环境。
C、原因是java源文件名后缀一定是以 .txt 结尾。
D、原因是JDK安装后没有正确设置环境变量PATH和Classpath 。
?
113. 给出一段程序,试判断哪个是正确的结果(?????? )
public class myprogram{
??? public static void main (String args[]){
??? try{
??? System.out.print(“Hello world ”); }
??? finally{
System.out.println(“Finally executing”);
}
}
}
A、无法编译,因为没有指定异常
B、无法编译,因为没有catch子句
C、Hello world
D、Hello world Finally executing
114. 下面哪个是Java语言中正确的标识符(?????? )
A、3D???????? B、$this????????? C、extends??? D、implements
?
115. 下面哪个范围是char型的取值范围(?????? )
A、-256 ~ 255???? B、-(2^15) ~ (2^15)-1?????? C、’\u0000’ ~ ‘\uffff’????? D、 0~32767
?
116. 下面哪个语句不能定义一个字符变量(?????? )
A、char c1=3210;?????????????????? B、char c2=’\uface’ ;
C、char c4=0xabcd ;??????????????? D、char c3=”\u0065”;
?
117. 下面哪个是对字符串String的正确定义(?????? )
A、String s1=”\n\t null”;??????????? B、String s2=’null’ ;????
C、String s3=(String) ‘abc’ ;??????? D、String s4=(String) ‘\uface’;
?
118. 给出下面一段程序,选择运行结果(????? )
public class X{
?? public static void main(String [] args){
??? String names[]=new String[5];
??? for(int x=0;x<args.length;x++)? names[x]=args[x];
??? System.out.println(names[2]);
}}
命令行执行:? java X a b?? 结果是下面哪一个?
A、names????? B、b?????? C、null?????? D、 运行出现异常
?
119. 下面哪个描述是正确的(?????? )
A、Applet程序中不需要main()方法,也不能有
B、Application程序中可以没有main()方法。
C、Applet程序中可以不定义init( )方法
D、Application程序中必须有run( )方法
?
120. 下面哪项可以得到数组元素的个数,java中定义数组名为 abc,(?????? )
A、abc.length( )???? B、abc.length???? C、len(abc)?????? D、ubound(abc)
?