1.

All the variables of interface should be?(a) default and final(b) default and static(c) public, static and final(d) protect, static and finalI had been asked this question in an internship interview.My query is from Access Control topic in chapter Classes and Methods of Java

Answer»

Right option is (c) public, STATIC and FINAL

Easiest explanation: Variables of an interface are public, static and final by default because the interfaces cannot be instantiated, final ENSURES the value assigned cannot be CHANGED with the implementing CLASS and public for it to be accessible by all the implementing classes.



Discussion

No Comment Found

Related InterviewSolutions