移动端

  • 题王微信公众号

    题王微信公众号

    微信搜“题王网”真题密题、最新资讯、考试攻略、轻松拿下考试

计算机考试 | Java认证考试

科目:

SCJP程序员认证考试

[切换]
题库
练习
考试
资讯

模式切换

0 0 0
我的错题 我的收藏 学习笔记

章节目录

多选题 Which of the following statements about variables and their scopes are true? ()   

A

 Instance variables are member variables of a class.

B

 Instance variables are declared with the static keyword.

C

 Local variables defined inside a method are created when the method is executed.

D

 Local variables must be initialized before they are used.

单选题 What is the result?()

A

Compilation fails due to an error in line 23.

B

Compilation fails due to an error in line 29.

C

A ClassCastException occurs in line 29.

D

A ClassCastException occurs in line 31.

E

The value of all four objects prints in natural order.

多选题 Which two code fragments correctly create and initialize a static array of int elements?() 

A

 static final int[] a = { 100,200 };

B

 static final int[] a; static { a=new int[2]; a[0]=100; a[1]=200; }

C

 static final int[] a = new int[2] { 100,200 };

D

 static final int[] a; static void init() { a = new int[3]; a[0]=100; a[1]=200; }

单选题 Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection?()

A

Line 16

B

Line 17

C

Line 18

D

Line 19

E

The object is NOT a candidate for garbage collection.

单选题 What is the result?()

A

Canada

B

null Canada

C

Canada null

D

Canada Canada

E

Compilation fails due to an error on line 26.

F

Compilation fails due to an error on line 29.

单选题 Which code, inserted at line 14, allows the Sprite class to compile?()

A

Direction d = NORTH;

B

Nav.Direction d = NORTH;

C

Direction d = Direction.NORTH;

D

Nav.Direction d = Nav.Direction.NORTH;

多选题 Which three statements are true?()

A

 The default constructor initializes method variables.

B

 The default constructor has the same access as its class.

C

 The default constructor invoked the no-arg constructor of the superclass.

D

 If a class lacks a no-arg constructor, the compiler always creates a default constructor. 

E

 The compiler creates a default constructor only when there are no other constructors for the class.

多选题 10. interface Foo {  11. int bar();  12. }  13.  14. public class Beta {  15.  16. class A implements Foo {  17. public int bar() { return 1; }  18. }  19.  20. public int fubar( Foo foo) { return foo.bar(); }  21.  22. public void testFoo() {  23.  24. class A implements Foo {  25. public int bar() { return 2; }  26. }  27.  28. System.out.println( fubar( new A())); 29. }  30.  31. public static void main( String[] argv) {  32. new Beta().testFoo();  33. }  34. }  Which three statements are true?()

A

 Compilation fails.

B

 The code compiles and the output is 2.

C

 If lines 16, 17 and 18 were removed, compilation would fail.

D

 If lines 24, 25 and 26 were removed, compilation would fail.

E

 If lines 16, 17 and 18 were removed, the code would compile and the output would be 2.

F

 If lines 24, 25 and 26 were removed, the code would compile and the output would be 1.

多选题 1. class TestA {  2. TestB b;  3. TestA() {  4. b = new TestB(this);  5. }  6. }  7. class TestB {  8. TestA a;  9. TestB(TestA a) {  10. this.a = a;  11. }  12. }  13. class TestAll {  14. public static void main (String args[]) {  15. new TestAll().makeThings(); 16. // ...code continues on  17. }  18. void makeThings() {  19. TestA test = new TestA(); 20. }  21. }  Which two statements are true after line 15, before main completes?()

A

 Line 15 causes a stack overflow.

B

 An exception is thrown at runtime.

C

 The object referenced by a is eligible for garbage collection.

D

 The object referenced by b is eligible for garbage collection.

E

 The object referenced by a is not eligible for garbage collection.

F

 The object referenced by b is not eligible for garbage collection.

首页 上一页 1 2 3 4 5 尾页 /

到第