1. class super { 2. public float getNum() {return 3.0f;} 3. } 4. 5. public class Sub extends Super { 6. 7. } Which method, placed at line 6, will cause a compiler error?()
A、 Public float getNum() {return 4.0f; }
B、 Public void getNum () { }
C、 Public void getNum (double d) { }
D、 Public double getNum (float d) {retrun 4.0f; }
相关问题推荐
-
35. String #name = “Jane Doe”; 36. int$age=24; 37. Double_height = 123.5; 38. double~temp = 37.5; Which two are true?()
ALine 35 will not compile.
BLine 36 will not compile.
CLine 37 will not compile.
DLine 38 will not compile.
-
public void test(int x) { int odd = x%2; if (odd) { System.out.println(“odd); } else { System.out.println(“even”); } } Which statement is true?()
A、Compilation fails.
B、 “odd” will always be output.
C、 “even” will always be output.
D、 “odd” will be output for odd values of x, and “even” for even values.
E、 “even” will be output for add values of x, and “odd” for even values.
-
public class X implements Runnable ( private int x; private int y; public static void main(String [] args) ( X that = new X(); (new Thread(that)) . start( ); (new Thread(that)) . start( ); ) public synchronized void run( ) ( for (;;) ( x++; y++; System.out.printIn(“x = “ + x + “, y = “ + y); ) ) ) What is the result?()
A、 An error at line 11 causes compilation to fail.
B、 Errors at lines 7 and 8 cause compilation to fail.
C、 The program prints pairs of values for x and y that might not always be the same on the same line (for example, “x=2, y=1”)
D、 The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by “x=1, y=1”)
E、 The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by “x=2s, y=2”)
-
public class Pass { public static void main(String [1 args) { int x 5; Pass p = new Pass(); p.doStuff(x); System.out.print(” main x = “+ x); } void doStuff(int x) { System.out.print(” doStuff x = “+ x++); } } What is the result?()
A、 Compilation fails.
B、 An exception is thrown at runtime.
C、 doStuffx = 6 main x = 6
D、 doStuffx = 5 main x = 5
E、 doStuffx = 5 main x = 6
F、 doStuffx = 6 main x = 5
-
What is the result?()
A、 Compilation fails.
B、 An exception is thrown at runtime.
C、 The code executes normally and prints "sleep".
D、 The code executes normally, but nothing is printed.