Which five methods, inserted independently at line 5, will compile? (Choose five.)

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.)

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; }

Explanation:
A: public int blipvert(int x) { return 0; }
compiled successfully

B: private int blipvert(int x) { return 0; }
Main.java:5: blipvert(int) in Vert cannot override blipvert(int) in Blip; attempting to assign weaker access privileges; was protected
private int blipvert(int x) { return 0; }
^
1 error

C: private int blipvert(long x) { return 0; }
compiled successfully

D: protected long blipvert(int x) { return 0; }
Main.java:5: blipvert(int) in Vert cannot override blipvert(int) in Blip; attempting to use incompatible return type
found : long
required: int
protected long blipvert(int x) { return 0; }
^
1 error

E: protected int blipvert(long x) { return 0; }
compiled successfully

F: protected long blipvert(long x) { return 0; }
compiled successfully

G: protected long blipvert(int x, int y) { return 0; }
compiled successfully



Leave a Reply 0

Your email address will not be published. Required fields are marked *