单项选择题

Given the command line java Pass2 and:

What is the result? ()

A. doStuff x = 6 main x = 6
B. Compilation fails.
C. doStuff x = 6 main x = 7
D. An exception is thrown at runtime.
E. doStuff x = 7 main x = 6
F. doStuff x = 7 main x = 7


您可能感兴趣的试卷

你可能感兴趣的试题

1.多项选择题

Given:

Which five methods, inserted independently at line 5, will compile?()

A. protected int blipvert(long x) { return 0; }
B. protected long blipvert(int x) { return 0; }
C. private int blipvert(long x) { return 0; }
D. private int blipvert(int x) { return 0; }
E. public int blipvert(int x) { return 0; }
F. protected long blipvert(long x) { return 0; }
G. protected long blipvert(int x, int y) { return 0; }

2.单项选择题

Click the Exhibit button. 
 What is the result?()

A. The code will deadlock.
B. The code may run with output "2 0 6 4".
C. The code may run with no output.
D. The code may run with output "0 6".
E. An exception is thrown at runtime.
F. The code may run with output "0 2 4 6".

3.单项选择题

Given: 

Which code, inserted at line 15, creates an instance of the Point class defined in Line?()

A. Line l = new Line() ; l.Point p = new l.Point();
B. Line.Point p = new Line.Point();
C. The Point class cannot be instatiated at line 15.
D. Point p = new Point();

4.单项选择题

Given:  
11. public static void main(String[] args) {  
12. Object obj = new int[] { 1, 2, 3 };  
13. int[] someArray = (int[])obj;  
14. for (int i : someArray) System.out.print(i + " ");  
15. }  
What is the result? ()

A. Compilation fails because of an error in line 13.
B. A ClassCastException is thrown at runtime.
C. 1 2 3
D. Compilation fails because of an error in line 14.
E. Compilation fails because of an error in line 12.

6.多项选择题

Click the Exhibit button. 
 Given:

Which two statements are true if a NullPointerException is thrown on line 3 of class C?()

A. The application will crash.
B. The code on line 29 will be executed.
C. The code on line 5 of class A will execute.
D. The exception will be propagated back to line 27.
E. The code on line 5 of class B will execute.

7.单项选择题

Given:

What is the result? ()

A. A new Item object is created with the preferred value in the id attribute.
B. The attribute id in the Item object is modified to the new value.
C. Compilation fails.
D. An exception is thrown at runtime.
E. The attribute id in the Item object remains unchanged.

8.单项选择题

Given:

What is the result?()

A. An exception is thrown at runtime.
B. int Long
C. Compilation fails.
D. Short Long

9.单项选择题

Given:

Which statement is true?()

A. The cardID and limit variables break polymorphism.
B. The code demonstrates polymorphism.
C. The ownerName variable breaks encapsulation.
D. The setCardInformation method breaks encapsulation.
E. The class is fully encapsulated.

10.单项选择题

Click the Exhibit button.  
Given this code from Class B:  
25. A a1 = new A();  
26. A a2 = new A();  
27. A a3 = new A();  
28. System.out.println(A.getInstanceCount()); 
 What is the result?()

A. Compilation of class A fails.
B. Line 28 prints the value 3 to System.out.
C. Line 28 prints the value 1 to System.out.
D. Compilation fails because of an error on line 28.
E. A runtime error occurs when line 25 executes.

最新试题

Given: What is the result?()

题型:单项选择题

Click the Exhibit button.  What is the output of the program shown in the exhibit? ()

题型:单项选择题

Click the Exhibit button.  What is the result?()

题型:单项选择题

Given the command line java Pass2 and:What is the result? ()

题型:单项选择题

Given:  11. public void genNumbers() {  12. ArrayList numbers = new ArrayList();  13. for (int i=0; i<10; i++) {14. int value = i * ((int) Math.random());  15. Integer intObj = new Integer(value);  16. numbers.add(intObj);  17. }  18. System.out.println(numbers);  19. }  Which line of code marks the earliest point that an object referenced by intObj becomes a  candidate for garbage collection?()

题型:单项选择题

Given:  11. // insert code here  12. private N min, max;  13. public N getMin() { return min; }  14. public N getMax() { return max; }  15. public void add(N added) {  16. if (min == null  added.doubleValue() < min.doubleValue()) 17. min = added;  18. if (max == null  added.doubleValue() > max.doubleValue()) 19. max = added;  20. }  21. }  Which two, inserted at line 11, will allow the code to compile?()

题型:多项选择题

Given:10. interface Jumper { public void jump(); } ...  20. class Animal {} ...  30. class Dog extends Animal {  31. Tail tail;  32. }  ...  40. class Beagle extends Dog implements Jumper{  41. public void jump() {} 42. }  ...  50. class Cat implements Jumper{  51. public void jump() {}  52. }.Which three are true?()

题型:多项选择题

Given:What is the result?() 

题型:单项选择题

Click the Exhibit button.  Given: ClassA a = new ClassA();  a.methodA();  What is the result?()

题型:单项选择题

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

题型:多项选择题