What will be the output of the following code?
class Apple {
protected int i = 20;
}
class Banana extends Apple {
void show() {
System.out.println(i);
}
}
class Cat extends Banana {
void disp() {
System.out.println(i); //i is also available here
}
}
public class Fruit {
public static void main(String[] args) {
Cat c = new Cat();
c.disp();
}
}
Reveal answer
Fill a bubble to check yourself