Discussion
Which two of the following are legal declarations for nonnested classes and interfaces?
1.final abstract class Test {}
2.public static interface Test {}
3.final public class Test {}
4.protected abstract class Test {}
5.protected interface Test {}
6.abstract public class Test {}
Answer: C
(3), (6). Both are legal class declarations.
(1) is wrong because a class cannot be abstract and final-there would be no way to use such a class. (2) is wrong because interfaces and classes cannot be marked as static. (4) and (5) are wrong because classes and interfaces cannot be marked as protected.
No comment is present. Be the first to comment.
Loading…
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