Discussion
What is the primary advantage of using interfaces over abstract classes in Java?
Answer: B
The main advantage is that a class can implement multiple interfaces.
Java allows a class to extend only one class, abstract or not, but to implement any number of interfaces. Interfaces are therefore Java's way of giving a class several types, a form of multiple inheritance of type.
The other options are false. Interfaces cannot have constructors, and they cannot have instance variables, since all their fields are implicitly public, static and final. They give no speed advantage. Abstract classes are the ones that can have constructors and instance state.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development