Given:
1. public class Blip{
2. protected int blipvert(int x){return 0;}
3. }
4. class Vert extends Blip{
5. //insert code here
6. }
Which five methods, inserted independently at line 5, will compile? (Choose five.)
A. public int blipvert(int x){return 0;}
B. private int blipvert(int x){return 0;}
C. private int blipvert(long x){return 0;}
D. protected long blipvert(int x){return 0;}
E. protected int blipvert(long x){return 0;}
F. protected long blipvert(long x){return 0;}
G. protected long blipvert(int x, int y){return 0;}
答案:ACEFG
參考:6-5 繼承
-------------------------------------------------------------------------
public class Blip {
protected int blipvert(int x) {
return 0;
}
}
class Vert extends Blip{
public int blipvert(int x){return 0;}
private int blipvert(int x){return 0;} //Cannot reduce the visibility of the inherited method
private int blipvert(long x){return 0;}
protected long blipvert(int x){return 0;} //The return type is incompatible
protected int blipvert(long x){return 0;}
protected long blipvert(long x){return 0;}
protected long blipvert(int x, int y){return 0;}
}
沒有留言:
張貼留言