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.
Interfaces can’t be local members of a method.
Yes, program is written is correctly. But, it will throw StackOverflowError at run time. Because, methodOne() and methodTwo() are cyclicly called.
Yes, program is written correctly. Output will be,
4
Yes, program is written correctly. Output will be,
2
False. Interfaces don’t extend Object class.
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
Yes, program compiles successfully.
Cycle detected. Any class can not extend itself or it’s member types.
Illegal modifier for field i. Only public, static and final are allowed.
No. An interface can extend another interface not the class.
AAABBB
BBBAAA
DDDBBBAAA
BBBAAA
Yes, from Java 8, interfaces can have static methods
Yes, program is correct. Output will be,
3
2
1
3
2
3
3
Number
Object
Number
NOT FINALFINAL
FINAL
Yes, from Java 8, interfaces can have static methods and default methods other than abstract methods.
No. Interfaces can’t have constructors.
QQQQPPPP
PPPPQQQQ
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.
Interfaces can’t have initializers.
Class Z must implement methodX() also.