Compilation fails.
After line 15, the value of age is 5.
After line 15, the value of age is 3.
An exception is thrown at runtime.
第1题:
String s = strings.get(0);
Iterator i1 = strings.iterator();
String[] array1 = strings.toArray();
Iterator
String[] array2 = strings.toArray(new String[1]);
Iterator
第2题:
x > 0
x > -3
x <= -3
x <= 0 & x > -3
第3题:
Looser coupling
Tighter coupling
Lower cohesion
Higher cohesion
Weaker encapsulation
Stronger encapsulation
第4题:
Value = 3
Value = 4
Value = 5
Value = 6
Value = 7
Value = 8
第5题:
Compilation will fail.
Compilation succeeds and no exceptions are thrown.
Compilation succeeds but an exception is thrown at line 5 in ClassTest.java.
Compilation succeeds but an exception is thrown at line 6 in ClassTest.java.
第6题:
short LONG
SHORT LONG
Compilation fails.
An exception is thrown at runtime.
第7题:
Member data have no access modifiers.
Member data can be modified directly.
The access modifier for methods is protected.
The access modifier to member data is private.
Methods provide for access and modification of data.
第8题:
float[] = new float(3);
float f2[] = new float[];
float[] f1 = new float[3];
float f3[] = new float[3];
float f5[] = { 1.0f, 2.0f, 2.0f };
float f4[] = new float[] { 1.0f. 2.0f. 3.0f};
第9题:
int ia = new int [15];
float fa = new float [20];
char ca = “Some String”;
Object oa = new float[20];
Int ia = (4, 5, 6) (1, 2, 3)
第10题:
Calling the yield method.
Calling the wait method on an object.
Calling the notify method on an object.
Calling the notifyAll method on an object.
Calling the start method on another Thread object.
第11题:
An exception is thrown.
The code does no compile.
“Hello World.” Is printed to the terminal.
The program exits without printing anything.
第12题:
If only one thread is blocked in the wait method of an object, and another thread executes the modify on that same object, then the first thread immediately resumes execution.
If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, it is still possible that the first thread might never resume execution.
If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, then the first thread definitely resumes execution as a direct and sole consequence of the notify call.
If two threads are blocked in the wait method of one object, and another thread executes the notify method on the same object, then the first thread that executed the wait call first definitely resumes execution as a direct and sole consequence of the notify call.
第13题:
Line 26 prints “a” to System.out.
Line 26 prints „b” to System.out.
An exception is thrown at line 26 at runtime.
Compilation of class A will fail due to an error in line 6.
第14题:
Compilation succeeds and 1 is printed.
Compilation succeeds and 2 is printed.
An error at line 8 causes compilation to fail.
An error at line 14 causes compilation to fail.
Compilation succeeds but an exception is thrown at line 14.
第15题:
public int method1(int a, int b) { return 0; }
private int method1(int a, int b) { return 0; }
private int method1(int a, long b) { return 0; }
public short method1(int a, int b) { return 0: }
static protected int method1(int a, int b) { return 0; }
第16题:
line 21
line 23
line 27
line 29
第17题:
AC
BD
ACD
ABCD
Compilation fails.
第18题:
int Long
Short Long
Compilation fails.
An exception is thrown at runtime.
第19题:
i = 6 and j = 5
i = 5 and j = 5
i = 6 and j = 4
i = 5 and j = 6
i = 6 and j = 6
第20题:
3/2
3<2
3*4
3<<2
3*2^2
3<<<2
第21题:
import utils.*;
static import utils.*;
import utils.Repetition.*;
static import utils.Repetition. *;
import utils.Repetition.twice();
import static utils.Repetition.twice;
static import utils.Repetition.twice;
第22题:
0
3
4
5
The code will not compile.
第23题:
Compilation fails because of an error in line 3.
Compilation fails because of an error in line 7.
Compilation fails because of an error in line 9.
If you define D e = new E(), then e.bMethod() invokes the version of bMethod()defined in Line 5.
If you define D e = (D)(new E()),then e.bMethod() invokes the version of bMethod() defined in Line 5.
If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.
第24题:
String name= File.getParentName(“file.txt”);
String name= (new File(“file.txt”)).getParent();
String name = (new File(“file.txt”)).getParentName();
String name= (new File(“file.txt”)).getParentFile();
Directory dir=(new File (“file.txt”)).getParentDir(); String name= dir.getName();