MCQs
Total Questions : 20
| Page 1 of 2 pages
Answer: Option C. -> Class School must be defined abstract.
Answer: Option D. -> public abstract void method();
Answer: Option B. -> All of these
Answer: Option C. -> 2 and 4
Answer: Option B. -> abstract class A { abstract void unfinished(); }
Answer: Option C. -> interface A { void print(); }
Answer: Option B. -> This code will compile without any errors.
Question 8. What will be the output?interface A{public void method();}class One{public void method(){System.out.println("Class One method");}}class Two extends One implements A{public void method(){System.out.println("Class Two method");}}public class Test extends Two{public static void main(String[] args){A a = new Two();a.method();}}
Answer: Option D. -> will print Class Two method
Answer: Option B. -> When it doesn't make sense to have objects of that class.
Question 10. Determine output of the following code.interface A { }class C { }class D extends C { }class B extends D implements A { }public class Test extends Thread{ public static void main(String[] args){ B b = new B(); if (b instanceof A) System.out.println("b is an instance of A"); if (b instanceof C) System.out.println("b is an instance of C"); }}
Answer: Option D. -> b is an instance of A followed by b is an instance of