1.

What happens when we access the same variable defined in two interfaces implemented by the same class?(a) Compilation failure(b) Runtime Exception(c) The JVM is not able to identify the correct variable(d) The interfaceName.variableName needs to be definedThe question was asked in an internship interview.Enquiry is from Interfaces in section Interfaces & Packages of Java

Answer»

Right OPTION is (d) The interfaceName.variableName needs to be defined

Easy EXPLANATION: The JVM needs to distinctly KNOW which value of VARIABLE it needs to use. To AVOID confusion to the JVM interfaceName.variableName is mandatory.



Discussion

No Comment Found

Related InterviewSolutions