Vidyalelo
Java Programming · Q47

Interfaces and Abstract Classes

Programming · Java Programming · question 47

Q47

What will be the output? public interface InfA protected String getName(); public class Test implements InfA public String getName() return "test-name"; public static void main (String[] args) Test t = new Test(); System.out.println(t.getName());

A.
test-name
B.
Compilation fails due to an error on lines 2
Answer
C.
Compilation fails due to an error on lines 1
D.
Compilation succeed but Runtime Exception
E.
None of these

Answer: Option B

Solution

Answer: Option B
Solution:

Illegal modifier for the interface method InfA.getName(); only public and abstracts are permitted.