单项选择题You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?()  

A. public
B. private
C. protected
D. transient
E. default access


您可能感兴趣的试卷

你可能感兴趣的试题

2.多项选择题

public class X { 
public X aMethod() { return this;} 
} 
public class Y extends X { 
} 
Which two methods can be added to the definition of class Y?()

A. public void aMethod() {}
B. private void aMethod() {}
C. public void aMethod(String s) {}
D. private Y aMethod() { return null; }
E. public X aMethod() { return new Y(); }

3.单项选择题Which fragment is an example of inappropriate use of assertions? ()

A. assert (!(map.contains(x))); map.add(x);
B. if (x > 0){}else { assert (x==0); }
C. public void aMethod(int x) { assert (x > 0); }
D. assert (invariantCondition()); return retval;
E. switch (x) { case 1: break; case 2: creak; default: assert (x == 0);

4.单项选择题

int i = 1,j = 10; 
do{ 
if (i>j) { 
continue; 
} 
j--; 
} while (++i <6); 
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

6.多项选择题

class A { 
} 
class Alpha { 
private A myA = new A(); 
void dolt( A a ) { 
a = null; 
} 
void tryIt() { 
dolt( myA ); 
} 
} 
Which two statements are correct?()  

A. There are no instanced of A that will become eligible for garbage collection.
B. Explicitly setting myA to null marks that instance to be eligible for garbage collection.
C. Any call on tryIt() causes the private instance of A to be marked for garbage collection.
D. Private instances of A become eligible for garbage collection when instances of Alpha become eligible for garbage collection.

9.单项选择题

public void foo( boolean a, boolean b ){ 
if( a ) { 
System.out.println( “A” ); 
} else if ( a && b ) { 
System.out.println( “A&&B” ); 
} else { 17. if ( !b ) { 
System.out.println( “notB” ); 
} else { 
System.out.println( “ELSE” ); 
} 
}
} 
What is correct?()  

A. If a is true and b is true then the output is “A&&B”.
B. If a is true and b is false then the output is “notB”.
C. If a is false and b is true then the output is “ELSE”.
D. If a is false and b is false then the output is “ELSE”.