Java | Abstract Class and Interface | Question 3

Last Updated :
Discuss
Comments

Predict the output of the following program.

Java
abstract class demo {     public int a;     demo()     {         a = 10;     }      abstract public void set();          abstract final public void get();  }  class Test extends demo {      public void set(int a)     {         this.a = a;     }      final public void get()     {         System.out.println("a = " + a);     }      public static void main(String[] args)     {         Test obj = new Test();         obj.set(20);         obj.get();     } }   

a = 10

a = 20

Compilation error

Share your thoughts in the comments