多项选择题
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; } -
单项选择题
try { if ((new Object))(.equals((new Object()))) { System.out.println(“equal”); }else{ System.out.println(“not equal”); } }catch (Exception e) { System.out.println(“exception”); } What is the result? ()
A. equal
B. not equal
C. exception
D. Compilation fails. -
单项选择题
public class Test { public static void main(String [] args) { System.out.println(args.length > 4 &&  args[4].equals(“-d”)); } } If the program is invoked using the command line: java Test One Two Three –d What is the result?()
A. true
B. false
C. Compilation fails.
D. An exception is thrown at runtime.
