Discussion
interface DoMath
{
double getArea(int rad);
}
interface MathPlus
{
double getVol(int b, int h);
}
/* Missing Statements ? */
which two code fragments inserted at end of the program, will allow to compile?
1.class AllMath extends DoMath { double getArea(int r); }
2.interface AllMath implements MathPlus { double getVol(int x, int y); }
3.interface AllMath extends DoMath { float getAvg(int h, int l); }
4.class AllMath implements MathPlus { double getArea(int rad); }
5.abstract class AllMath implements DoMath, MathPlus { public double getArea(int rad) { return rad * rad * 3.14; } }
Answer: C
(3) are (5) are correct because interfaces and abstract classes do not need to fully implement the interfaces they extend or implement (respectively).
(1) is incorrect because a class cannot extend an interface. (2) is incorrect because an interface cannot implement anything. (4) is incorrect because the method being implemented is from the wrong interface.
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