Question) Given this code what is the output?
class Exam
{
protected String level = "Easy";
public void printLevel()
{
System.out.println(level);
}
}
Class IITExam extends Exam
{
private String level = "Difficult";
}
IITExam iitExam = new IITExam();
iitExam .printLevel();
Options)
Explanation) Methods can be overridden not the attributes. Rest is self explanatory.
class Exam
{
protected String level = "Easy";
public void printLevel()
{
System.out.println(level);
}
}
Class IITExam extends Exam
{
private String level = "Difficult";
}
IITExam iitExam = new IITExam();
iitExam .printLevel();
Options)
- Difficult
- Easy
Explanation) Methods can be overridden not the attributes. Rest is self explanatory.
No comments:
Post a Comment