Knowee
Questions
Features
Study Tools

Predict the output of the following program: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();    }}Select one:a.a = 10b.a = 20c.Compilation error

Question

Predict the output of the following program: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();    }}Select one:a.a = 10b.a = 20c.Compilation error

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

c. Compilation error

Similar Questions

Select the correct answerAssuming all the necessary imports are done, predict the output of the following program. abstract class demo {     public int marks;     demo() {         marks = 20;     }     abstract public void set();     abstract final public void get(); }  class Test extends demo {     public void set(int marks) {         this.marks = marks;     }     final public void get() {         System.out.println("marks = " + marks);      }     public static void main(String[] args) {         Test obj = new Test();         obj.set(10);         obj.get();     } }Optionsmarks = 20marks = 10Compilation error

What is the Output of following Java Program?abstract class Demo{    public int a;    Demo()    {        a = 10;    }     abstract public void set(); }class Test extends Demo{     final public void get()    {        System.out.println("a = " + a);    }     public static void main(String[] args)    {        Test obj = new Test();        obj.get();    }}Select one:a.Compile Time Errorb.a=10c.Runtime Exception

What will be the output of the following program?class test {int a;int b;test(int i, int j) {a = i;b = j;}void meth(test o) {o.a *= 2;o.b /= 2;}          }   class Output{public static void main(String args[]){test obj = new test(10 , 20);obj.meth(obj);System.out.println(obj.a + " " + obj.b);        }}Select one:40 2010 2020 1020 40

What will be the output of the following program ?class FourWheeler{    public FourWheeler()    {        System.out.println("Class FourWheeler");    }}class Car extends FourWheeler{    public Car()     {        System.out.println("Class Car");        }}class Audi extends Car{   public Audi()    {        super();        System.out.println("Class Audi");    }}class Driver{    public static void main(String args[])    {        Audi cc=new Audi();    }}Select one:a.Class AudiClass CarClass FourWheelerb.Compile Time Errorc.Class FourWheelerClass CarClass Audid.Exception occurs

Predict the outputabstract class Vehicle{    abstract void calcPremium(Number N);}interface Insurance{    abstract void calcPremium (Object O);}class Car extends Vehicle implements Insurance{                 public void calcPremium (Object O)                    {                        System.out.println("Object");                    }    void calcPremium (Number N)     {        System.out.println("Number");    } }public class Test{    public static void main(String[] args)    {        Vehicle a = new Car();         a. calcPremium (new Integer(121));          Insurance b = new Car();           b. calcPremium (new Integer(121));           Car c = new Car();            c. calcPremium (new Integer(121));    }}Select one:a.NumberObjectNumberb.NumberNumberObjectc.Run time errord.Compile time error

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.