Oracle Certified Associate Java Se 8 Programmer · Free Practice Question Medium
Question 31
Consider the following code:
- interface Interf//Line-1
- {
- abstract void m1(); //Line-2
- }
- abstract class ChildClass implements Interf //Line-3
- {
- abstract void m1();//Line-4
- }
- class ParentClass extends ChildClass //Line-5
- {
- void m1(){} //Line-6
- }
Which of the following Lines causes compile time error ?
-
A
Line-3
-
B
Line-4
-
C
Line-5
-
D
Line-1
-
E
Line-2
-
F
Line-6
Reveal correct answers
Correct answers: B, F
Explanation
Every method present in interface is by default public. Hence at the time of overriding/implementing that method, compulsory we should declare that method as public. We didn't declare method as public at Line-4 and Line-6. Hence we will get compile time errors.Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
You must be logged in to post a comment.
