Top 32 Java Programmer Interview Questions You Must Prepare 08.Dec.2023

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.

Yes, program is written is correctly. But, it will throw StackOverflowError at run time. Because, methodOne() and methodTwo() are cyclicly called.

True. For every interface written in a java file, .class file will be generated after compilation.

False. Interfaces are abstract by default but not public.

Yes, we can define generic interface

Illegal modifier for field i. Only public, static and final are allowed.

Yes, from Java 8, interfaces can have static methods

Yes, from Java 8, interfaces can have static methods and default methods other than abstract methods.

No. Interfaces can’t have constructors.

Interface methods must be implemented as public. Because, interface methods are public by default and you should not reduce the visibility of any methods while overriding.

Yes, a class can implement more than one interfaces.