Discussion
Which of the following is/are legal method declarations?
1.protected abstract void m1();
2.static final void m1(){}
3.synchronized public final void m1() {}
4.private native void m1();
Answer: D
Correct answer: All of them are legal declarations.
Each combination is permitted. protected abstract is legal in an abstract class, since only private, static and final conflict with abstract. static final is legal and merely redundant, a static method not being overridable in the first place. Modifier order is free, so synchronized public final is fine. And private native is legal - a native method has no body and its implementation is supplied elsewhere.
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