java面试题
1. class A { 2. protected int method1(int a, int b) { return 0; } 3. } Which two are valid in a class that extends class A? (Choose two) A. public int method1(int a, int b) { return 0; } B. private int method1(int a, int b) { return 0; } C. private int method1(int a, long b) { return 0; } D. public short method1(int a, int b) { return 0; } E. static protected int method1(int a, int b) { return 0; } 答案:A,CB:Cannot reduce the visibility of the inherited method from A
D:Multiple markers at this line
- The return type is incompatible with
A.method1(int, int)
E:This static method cannot hide the instance method from A
页:
[1]