选择题(四)

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;
这段程序执行完后,cresult的值是: (   )

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语言的关键字(    

AFloat      Bthis       Cstring     Dunsigned      

 

100. 下面哪个是Java语言中正确的标识符(    

A3com       Bimport     Cthat           Dthis

 

101. 下面哪个语句不能定义一个字符变量(     

Achar c1=06477;           Bchar c2=’\uface’ ;

Cchar c4=0xbeef ;             Dchar c3=\u0041;

 

102. 下面哪个修饰符修饰的方法只能被本类中的其他方法使用(     

Aprotected         Bstatic            Cprivate    Dpublic

 

103. 下面哪个运算后结果为32        

A2^5        B(8>>2)<<4      C、2>>5           D、 (2<<1)*(32>>3)

 

104. 下面哪个是对字符串String的正确定义(     

AString s1=null;                 BString s2=’null’ ;    

CString s3=(String) ‘abc’ ;    DString s4=(String) ‘\uface’;

 

105. 下面哪条语句不能定义一个float型的变量(     

Afloat f1= -343 ;                Bfloat f2=3.14 ;      

Cfloat f3=0x12345 ;              Dfloat f4=2.8F ;      

 

106. 下面哪条语句定义了5个元素的数组(     

Aint [] a={22,23,24,25,12};

Bint a []=new int(5);

Cint [5] array;

Dint [] 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   结果是下面哪一个?(     )

Aargs[2]=2         Bargs[2]=null      Cargs[2]=1      D、运行出现异常  

 

109. 下面哪个描述是正确的(    

AApplet程序中不需要main()方法,也不能有

BApplication程序中可以没有main()方法。

CApplet程序中可以不定义init( )方法

DApplication程序中必须有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 ”);

    }

}

Ahello throwit caught

Bhello throwit caught finally after

Chello throwit RuntimeException after

Dhello throwit caught finally after RuntimeException

 

111. 对一个java源文件 aaa.java,编辑保存后但未编译,在其所在目录下执行 java aaa,则接着会出现什么(     

Aerror: cannot read: aaa.java

B、无任何显示

CException 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安装后没有正确设置环境变量PATHClasspath

 

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子句

CHello world

DHello world Finally executing

114. 下面哪个是Java语言中正确的标识符(      

A3D         B$this          Cextends    Dimplements

 

115. 下面哪个范围是char型的取值范围(      

A-256 ~ 255     B-(2^15) ~ (2^15)-1       C’\u0000’ ~ ‘\uffff’      D 0~32767

 

116. 下面哪个语句不能定义一个字符变量(      

Achar c1=3210;                   Bchar c2=’\uface’ ;

Cchar c4=0xabcd ;                Dchar c3=”\u0065”;

 

117. 下面哪个是对字符串String的正确定义(      

AString s1=”\n\t null”;            BString s2=’null’ ;    

CString s3=(String) ‘abc’ ;        DString 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   结果是下面哪一个?

Anames      Bb       Cnull       D 运行出现异常

 

119. 下面哪个描述是正确的(      

AApplet程序中不需要main()方法,也不能有

BApplication程序中可以没有main()方法。

CApplet程序中可以不定义init( )方法

DApplication程序中必须有run( )方法

 

120. 下面哪项可以得到数组元素的个数,java中定义数组名为 abc,(      

Aabc.length( )     Babc.length     Clen(abc)       Dubound(abc)

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值