1. class Boo { Boo(String s) { } Boo() { } } class Bar extends Boo { Bar() { } Bar(String s) {super(s);} void zoo() { // insert code here } } which one create an anonymous inner class from within class Bar?





Ask Your Doubts Here

Type in
(Press Ctrl+g to toggle between English and the chosen language)

Comments

  • By: guest on 02 Jun 2017 01.26 am
    Option B is correct because anonymous inner classes are no different from any other class when it comes to polymorphism. That means you are always allowed to declare a reference variable of the superclass type and have that reference variable refer to an instance of a subclass type, which in this case is an anonymous subclass of Bar. Since Bar is a subclass of Boo, it all works. Option A is incorrect because it passes an int to the Boo constructor, and there is no matching constructor in the Boo class. Option C is incorrect because it violates the rules of polymorphism—you cannot refer to a superclass type using a reference variable declared as the subclass type. The superclass is not guaranteed to have everything the subclass has. Option D uses incorrect syntax.
Show Similar Question And Answers
QA->Who exhorted the world famous dictum "One caste, One religion, One clan, One world, One God"?....
QA->Average height of 10 students in a class is 150 cm. A boy of height 160 cm left the class and a boy of height 148 cm is admitted. Then what is the average height of the students in the class now?....
QA->There are 50 students in a class. In a class test 22 students get 25 marks each, 18 students get 30 marks each. Each of the remaining gets 16 marks. The average mark of the whole class is :....
QA->Anonymous (adj.)....
QA->Null and void....
MCQ->class Boo { Boo(String s) { } Boo() { } } class Bar extends Boo { Bar() { } Bar(String s) {super(s);} void zoo() { // insert code here } } which one create an anonymous inner class from within class Bar?....
MCQ->What will be the output of the program? class Super { public int i = 0; public Super(String text) / Line 4 / { i = 1; } } class Sub extends Super { public Sub(String text) { i = 2; } public static void main(String args[]) { Sub sub = new Sub("Hello"); System.out.println(sub.i); } }....
MCQ->What will be the output of the program? class Super { public Integer getLength() { return new Integer(4); } } public class Sub extends Super { public Long getLength() { return new Long(5); } public static void main(String[] args) { Super sooper = new Super(); Sub sub = new Sub(); System.out.println( sooper.getLength().toString() + "," + sub.getLength().toString() ); } }....
MCQ->What will be the output of the program? public class Foo { Foo() { System.out.print("foo"); } class Bar { Bar() { System.out.print("bar"); } public void go() { System.out.print("hi"); } } / class Bar ends / public static void main (String [] args) { Foo f = new Foo(); f.makeBar(); } void makeBar() { (new Bar() {}).go(); } }/ class Foo ends /....
MCQ->What will be the output of the program? class MyThread extends Thread { MyThread() { System.out.print(" MyThread"); } public void run() { System.out.print(" bar"); } public void run(String s) { System.out.println(" baz"); } } public class TestThreads { public static void main (String [] args) { Thread t = new MyThread() { public void run() { System.out.println(" foo"); } }; t.start(); } }....
Terms And Service:We do not guarantee the accuracy of available data ..We Provide Information On Public Data.. Please consult an expert before using this data for commercial or personal use | Powered By:Omega Web Solutions
© 2002-2017 Omega Education PVT LTD...Privacy | Terms And Conditions
Question ANSWER With Solution