Knowee
Questions
Features
Study Tools

Select the correct answerPredict the correct results of below given code snippet: abstract class CT {   public int x;   CT() {     x = 39;   }   abstract public void showTime();     abstract final public void funTime();  }  class Main extends CT {   public void showTime(int a) {     this.x = a;   }   final public void funTime() {     System.out.println(x);   }   public static void main(String[] args) {     Main object = new Main();     object.showTime(144);     object.funTime();   } }OptionsError3914439144

Question

Select the correct answerPredict the correct results of below given code snippet: abstract class CT {   public int x;   CT() {     x = 39;   }   abstract public void showTime();     abstract final public void funTime();  }  class Main extends CT {   public void showTime(int a) {     this.x = a;   }   final public void funTime() {     System.out.println(x);   }   public static void main(String[] args) {     Main object = new Main();     object.showTime(144);     object.funTime();   } }OptionsError3914439144

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

Solution

The code will result in an error. The reason is that the method showTime() in the abstract class CT does not take any parameters, but in the Main class, it is overridden with a parameter. This is not allowed in Java. Also, abstract methods cannot be declared as final.

Similar Questions

Select the correct answerDecode the code and choose the correct results: abstract class A { final void showTime() { System.out.println("3900"); } } class B extends A {   static void funTime() {     System.out.println("7766");   } } public class Main { public static void main(String args[]) { A object = new B(); object.showTime(); B.funTime(); } }Options7766390077667766Error3900390039007766

Select the correct answerPredict the correct results of below given code snippet: abstract class B { B() { System.out.println("38"); } void funTime() {   System.out.println("94"); } } class D extends B {  D() { System.out.println("103"); } } class Main { public static void main(String args[]) { D object = new D(); object.funTime(); } }Options10394381033894Error: Violating concept of abstract classes38103949410338

Select the correct answerPredict the correct results of below given code snippet: abstract class B { abstract void funTime(); } class D extends B { final void funTime() { System.out.println("47"); } } class Main { public static void main(String args[]) { B object = new D(); object.funTime(); } }OptionsClean code with 47 printed as output.Error : overriding method is finalCode gives warning due to use of final method , but also prints 47Code ex

What is the result of the following code? 1: public abstract class Bird { 2: private void fly() { System.out.println("Bird is flying"); } 3: public static void main(String[] args) { 4: Bird bird = new Pelican(); 5: bird.fly(); 6: } 7: } 8: class Pelican extends Bird { 9: protected void fly() { System.out.println("Pelican is flying"); } 10: }  *1 pointA. Bird is flyingB. Pelican is flyingC. The code will not compile because of line 4.D. The code will not compile because of line 5.E. The code will not compile because of line 9.

Select the correct answerPredict the output of the following program.? class CT{    int i = 1;    int j = 2;    CT func(CT obj)    {        CT obj3 = new CT();        obj3 = obj;        obj3.i = obj.i++ + ++obj.j;        obj.j = obj.j;        return obj3;    }    public static void main(String[] args)    {        CT obj1 = new CT();        CT obj2 = obj1.func(obj1);        System.out.println("obj1.i = " + obj1.i + "  obj1.j = " + obj1.j);        System.out.println("obj2.i = " + obj2.i + "  obj1.j = " + obj2.j);    }}OptionsCompilation errorobj1.i = 4 obj1.j = 3obj2.i = 4 obj2.j = 3obj1.i = 1 obj1.j = 2obj2.i = 4 obj2.j = 3non of these

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.