Qtr No. 213, New Town Yehlanka Indore 454775
Which access specifiers should be placed at Line1 and Line2 to generate ‘I am HR true’ as the output of the given code?
class Employee{
protected void role() {
System.out.print("I am an Employee ");
}
protected boolean onRole() {
return false;
}
}
class HR extends Employee{
void role() { //Line1
System.out.print("I am HR ");
}
boolean onRole() { //Line2
return true;
}
}
public class Tester {
public static void main(String args[]) {
Employee h= new HR();
h.role();
System.out.println(h.onRole());
}
}
public at Line1 and default at Line2
private at Line1 and Line2
default at Line1 and public at Line2
protected at Line1 and default at Line2
To get all Infosys Certified Java SE11 Developer Exam questions Join Group https://bit.ly/infy_premium_group
We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.
Qtr No. 213, New Town Yehlanka Indore 454775
admin@prepflix.in