Qtr No. 213, New Town Yehlanka
Indore 454775, India
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 Telegram Group https://rebrand.ly/lex-telegram-236dee