Multiple choice

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();
 }
}

  1. 0

  2. Compile Time Error

  3. 20

  4. 020

  5. 200

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

since i is protected and it will be visible at all its sub classes