JAVA单选题参考题库 联系客服

发布时间 : 星期六 文章JAVA单选题参考题库更新完毕开始阅读d9510ec4ad02de80d4d840b5

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

202、表达式7%(-3)的运算结果为D A、-2 B、-1 C、2 D、1

203、请阅读下面的程序 public class Test {

public static void main(String[] args) { int sum = 0;

for (int i = 1; i <= 100; i++) { if (i % 2 == 1) { continue; }

sum += i; }

System.out.println(\ } }

sum的值为(B)

A、1050

B、2550

C、2500

D、以上答案都不对

204、下列关于类与对象的说法中,错误的是( D )。 A、类是对某一类事物的抽象描述,而对象则是该类事物的个体。 B、对象是类的实例化

C、类用于描述多个对象的共同特征,它是对象的模板 D、类与对象之间没有关系

205、下列选项中,用户创建归档文件的jar命令是( A ) A、jar -c B、jar -v C、jar -f D、jar -x

206、阅读下面的程序: public class test {

public static void main(String args[]) { int i;

float f = 2.3f; double d = 2.7;

i = ((int)Math.ceil(f)) * ((int)Math.round(d)); System.out.println(i); } }

程序执行后,运行结果为以下哪个选项?A A、9

B、5

C、6

D、6.1

207、Outer类中定义了一个成员内部类Inner,需要在main()方法中创建Inner类实例对象,以下四种方式哪一种是正确的?D

A、Inner in = new Inner()

B、Inner in = new Outer.Inner();

C、Outer.Inner in = new Outer.Inner();

D、Outer.Inner in = new Outer().new Inner(); 208、请阅读下面的程序 public class

Example {

public static void main(String[] args)

{ int x =

1; do

{

x++; } while (x <=

4); System.out.println(\

x);

}

}

运行程序后,下列选项中,哪一个是x的值C A、3 B、4

C、5

D、6

209、被声明为private,protected 及public 的类成员,在类的外部则(B)

A、只能访问到声明为public 的成员 B、只可能访问到声明为protected 和public 的成员 C、都可以访问

D、都不能访问

210、若int a = 7;a %= 2;则执行后,变量a的值是B A、7

B、1

C、2 D、3 211、下面浮点型数据的定义中,错误的是(A ) A、float a=1.23;

B、double b=1.23; C、double c=1.5E4; D、float d='a';

212、class MyException extends (1) { }

public class Demo {

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

show(); } catch ( (2) e) { e.printStackTrace(); } }

public static void show() (3) MyException { throw new MyException(); }

以上程序,创建了一个自定义异常(编译异常),请补全空白处代码(A、(1) Exception (2) MyException (3) throws B、(1) MyException (2) Exception (3) throws C、(1) Exception (2) Exception (3) throws D、(1) Exception (2) MyException (3) Exception

213、要产生[20,999]之间的随机整数可以使用以下哪个表达式?B A、(int)(20+Math.random()*97) B、20+(int)(Math.random()*980) C、(int)Math.random()*999 D、20+(int)Math.random()*980

214、下列异常声明中,正确的是( C ) A、public void throws IOException fun(){} B、public void fun throws IOException(){} C、public void fun()throws IOException{}

A )

D、public void fun()throws IOException,throws SQLException{} 215、下列选项中,不属于面向对象特征的是( C )。 A、继承性 B、封装性 C、跨平台性 D、多态性

216、下列选项中,属于浮点数常量的是?(B ) A、198 B、2e3f C、true D、null

217、下面哪种写法可以实现访问数组arr的第1个元素?A A、arr[0] B、arr(0) C、arr[1] D、arr(1)

218、已知类的继承关系如下: class Employee;

class Manager extends Employeer; class Director extends Employee; 则以下语句能通过编译的有哪些?A

A、Employee e=new Manager();

B、Director d=new Manager(); C、Director d=new Employee(); D、Manager m=new Director();

219、已知 String 对象 s=\,则 s.substring(2, 5)的返回值为?( B ) private static void show(){ System.out.println(name) }

public static void main(String[] args){ Demo d = new Demo(“lisa”); d.show();

A、\B、\C、\D、\

220、下列选项中,不属于运行时异常类子类的是( D ) A、ArrayStoreException B、ClassCastException C、IllegalArgumentException D、ThreadDeath

221、若int[][] arr= {{1,2,3}},则arr[0][1]的结果为( C ) A、0 B、1 C、2 D、3

222、阅读下面的代码 class Demo{

private String name;

Demo(String name){this.name = name;}

} }

下列关于程序运行结果的描述中,正确的是(D)

A、输出 lisa B、输出null C、输出name

D、编译失败,无法从静态上下文中引用非静态变量name 223、请阅读下面的程序 public class SwitchDemo3 {

public static void main(String[] args) { char c = ‘B’; switch ? { case ‘A’:

System.out.println(“优”); break; case ‘B’:

System.out.println(“良”); break; case ‘C’:

System.out.println(“差”); break; } } }

下列选项中,哪一个才是程序的运行结果B A、优