Alpha a=x;
Foo f=(Delta)x;
Foo f=(Alpha)x;
Beta b=(Beta)(Alpha)x;
第1题:
Inheritance represents an is-a relationship.
Inheritance represents a has-a relationship.
Interfaces must be used when creating a has-a relationship.
Instance variables can be used when creating a has-a relationship.
第2题:
6
7
10
11
Compilation fails.
An exception is thrown at runtime.
第3题:
An exception is thrown.
The program exists without printing anything.
An error at line 1 causes compilation to fail.
An error at line 6 causes the compilation to fail.
“Running” is printed and the program exits.
第4题:
B
The code runs with no output.
An exception is thrown at runtime.
Compilation fails because of an error in line 15.
Compilation fails because of an error in line 18.
Compilation fails because of an error in line 19.
第5题:
Objects are deleted when they can no longer be accessed through any reference.
The finalize() method will eventually be called on every object.
The finalize() method will never be called more than once on an object.
An object will not be garbage collected as long as it is possible for an active part of the program to access it through a reference.
The garbage collector will use a mark and sweep algorithm.
第6题:
put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java
put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java/*.jar
Put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java/Poker.jar
put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java
put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuffijava/*.jar
put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java/Poker.jar
第7题:
True
Not true
An exception is thrown at runtime.
Compilation fails because of an error at line 12.
Compilation fails because of an error at line 19.
第8题:
Int foo = (int) Math.max(bar);
Int foo = (int) Math.min(bar);
Int foo = (int) Math.abs(bar);
Int foo = (int) Math.ceil(bar);
Int foo = (int) Math.floor(bar);
Int foo = (int) Math.round(bar);
第9题:
line 1
line 2
line 5
line 8
第10题:
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;
第11题:
est
es
str
st
s
第12题:
Compilation fails.
Compilation succeeds and no exceptions are thrown.
An exception is thrown at line 5 in ClassTest.java.
An exception is thrown at line 6 in ClassTest.java.
第13题:
Java.io.InputStream.
Java.io.EncodedReader.
Java.io.InputStreamReader.
Java.io.InputStreamWriter.
Java.io.BufferedInputStream.
第14题:
第15题:
java.lang.RuntimeException: Problem
run. java.lang.RuntimeException: Problem
End of method. java.lang.RuntimeException: Problem
End of method. run. java.lang.RuntimeException: Problem
run. java.lang.RuntimeException: Problem End of method.
第16题:
public void aMethod() {}
private void aMethod() {}
public void aMethod(String s) {}
private Y aMethod() { return null; }
public X aMethod() { return new Y(); }
第17题:
420 is the output.
An exception is thrown at runtime.
All constructors must be declared public.
Constructors CANNOT use the private modifier.
Constructors CANNOT use the protected modifier.
第18题:
Compilation succeeds.
An exception is thrown.
Compilation fails because of an error at line 2.
Compilation fails because of an error at line 6.
第19题:
Objects instantiated from Panel do not have a default layout manager.
Objects instantiated from Panel have FlowLayout as default layout manager.
Objects instantiated from Applet have BorderLayout as default layout manager.
Objects instantiated from Dialog have BorderLayout as default layout manager.
Objects instantiated from Window have the same default layout manager as instances of Applet.
第20题:
int addValue( int a, int b ){// do something...}
public void addValue (){// do something...}
public int addValue( int a ){// do something...}
public int addValue( int a, int b )throws MyException {//do something...}
第21题:
a.wait();
t.wait();
t.join();
t.yield();
t.notify();
a.notify();
t.interrupt();
第22题:
public int change(){}
int chang(int i){}
private int change(){}
abstract int chang(){}
第23题:
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.
第24题:
public class Employee extends Info implements Data { public void load() { /*do something*/ } }
public class Employee implements Info extends Data { public void load() { /*do something*/ } }
public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }
public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }
public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }
public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }