单项选择题
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
相关考题
-
单项选择题
public class X { public static void main(String [] args) { try { badMethod(); System.out.print(“A”); } catch (Exception ex) { System.out.print(“C”); } finally { System.out.print(“B”); } System.out.print(“D”); } public static void badMethod() { throw new Error(); } } What is the result?()
A. ABCD
B. Compilation fails.
C. C is printed before exiting with an error message.
D. BC is printed before exiting with an error message.
E. BCD is printed before exiting with an error message. -
多项选择题
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(); } -
单项选择题
Whichfragmentisanexampleofinappropriateuseofassertions?()
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);
