1.

Does Below Code Compile Successfully? If Not, Why? Interface A { Int I = 111; } Class B Implements A { Void Methodb() { I = 222; } }

Answer»

No, because interface fields are static and FINAL by default and you can’t change their VALUE once they are initialized. In the above code, METHODB() is changing value of interface field A.i. It shows COMPILE time error.

No, because interface fields are static and final by default and you can’t change their value once they are initialized. In the above code, methodB() is changing value of interface field A.i. It shows compile time error.



Discussion

No Comment Found

Related InterviewSolutions