A. public
B. private
C. protected
D. transient
E. default access
您可能感兴趣的试卷
你可能感兴趣的试题
int i = 1,j = 10;
do {
if(i>j) {
break;
}
j--;
} while (++i <5);
System.out.println(“i =” +i+” and j = “+j);
What is the result?()
A. i = 6 and j = 5
B. i = 5 and j = 5
C. i = 6 and j = 4
D. i = 5 and j = 6
E. i = 6 and j = 6
class A {
A() { }
}
class B extends A {
}
Which two statements are true?()
A. Class B’s constructor is public.
B. Class B’s constructor has no arguments.
C. Class B’s constructor includes a call to this().
D. Class B’s constructor includes a call to super().
interface Animal {
void soundOff();
}
class Elephant implements Animal {
public void soundOff() {
System.out.println(“Trumpet”);
}
}
class Lion implements Animal {
public void soundOff() {
System.out.println(“Roar”);
}
}
class Alpha1 {
static Animal get( String choice ) {
if ( choice.equalsIgnoreCase( “meat eater” )) {
return new Lion();
} else {
return new Elephant();
}
}
}
Which compiles?()
A. new Animal().soundOff();
B. Elephant e = new Alpha1();
C. Lion 1 = Alpha.get(“meat eater”);
D. new Alpha1().get(“veggie”).soundOff();
1. class Test {
2. private Demo d;
3. void start() {
4. d = new Demo();
5. this.takeDemo(d);
6. }
7.
8. void takeDemo(Demo demo) {
9. demo = null;
10. demo = new Demo();
11. }
12. }
When is the Demo object, created on line 3, eligible for garbage collection?()
A. After line 5.
B. After line 9.
C. After the start() method completes.
D. When the takeDemo() method completes.
E. When the instance running this code is made eligible for garbage collection.
A. float[] = new float(3);
B. float f2[] = new float[];
C. float[] f1 = new float[3];
D. float f3[] = new float[3];
E. float f5[] = { 1.0f, 2.0f, 2.0f };
F. float f4[] = new float[] { 1.0f. 2.0f. 3.0f};
public class Test {
public static void main(String args[]) {
class Foo {
public int i = 3;
}
Object o = (Object)new Foo();
Foo foo = (Foo)o;
System.out.println(“i = “ + foo.i);
}
}
What is the result?()
A. i = 3
B. Compilation fails.
C. A ClassCastException is thrown at line 6.
D. A ClassCastException is thrown at line 7.
A. Java.util.Map.
B. Java.util.List.
C. Java.util.Hashable.
D. Java.util.Collection.
A. Java.util.Map.
B. Java.util.Set.
C. Java.util.List.
D. Java.util.StoredSet.
E. Java.util.StoredMap.
F. Java.util.Collection.
public class X {
public object m () {
object o = new float (3.14F);
object oa = new object [1];
oa[0]= o;
o = null;
oa[0] = null;
return o;
}
}
When is the float object created in line 3, eligible for garbage collection?()
A. Just after line 5.
B. Just after line 6.
C. Just after line 7.
D. Just after line 8(that is, as the method returns).
A. A static inner class requires a static initializer.
B. A static inner class requires an instance of the enclosing class.
C. A static inner class has no reference to an instance of the enclosing class.
D. A static inner class has access to the non-static members of the outer class.
E. Static members of a static inner class can be referenced using the class name of the static inner class.
最新试题
A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key?()
Which two of statements are true?()
What can be a result?()
Which three changes should be made to adapt this class to be used safely by multiple threads?()
Given that t1 is a reference to a live thread, which is true?()
What is the result?()
Given that Triangle implements Runnable, and:Which two statements, inserted independently at both lines 35 and 41, tend to allow both threads to temporarily pause and allow the other thread to execute?()
What is the result?()
What is the result?()
Which statement is true?()