多项选择题
Which two are benefits of fully encapsulating a class?()
A. Performance of class methods is improved.
B. Implementation details of the class are hidden.
C. Access modifiers can be omitted on class data members.
D. Code that uses the encapsulation class can access data members directly.
E. Internal operation of the class can be modified without impacting clients of that class.
相关考题
-
单项选择题
class A { public byte getNumber() { return 1; } } class B extends A { public short getNumber() { return 2; } public static void main(String args[]) { B b = new B(); System.out.println(b.getNumber()); } } What is the result?()
A. 1
B. 2
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 8.
E. Compilation fails because of an error in line 14. -
多项选择题
1. class BaseClass { 2. private float x = 1.of; 3. protected float getVar() { return x; } 4. } 5. class SubClass extends BaseClass { 6. private float x = 2.Of; 7. // insert code here 8. } Which two are valid examples of method overriding when inserted at line 7?()
A. float getVar() { return x; }
B. public float getVar() { return x; }
C. public double getVar() { return x; }
D. protected float getVar() { return x; }
E. public float getVar(float f) { return f; } -
多项选择题
Whichthreedemonstratean“isa”relationship?()
A. public class X { } public class Y extends X { }
B. public interface Shape { } public interface Rectangle extends Shape{ }
C. public interface Color { } public class Shape { private Color color; }
D. public interface Species { } public class Animal { private Species species; }
E. public class Person { } public class Employee { public Employee(Person person) { }
F. interface Component { } class Container implements Component { private Component[] children; }
