Interfaces And Abstract Classes - Study Mode

[#246] Which of the following class definitions defines a legal abstract class?
Correct Answer

(C) abstract class A { abstract void unfinished() }

[#247] Which of the following declares an abstract method in an abstract Java class?
Correct Answer

(B) public abstract void method()

[#248] Suppose A is an abstract class, B is a concrete subclass of A, and both A and B have a default constructor. Which of the following is correct? 1. A a = new A()
2. A a = new B()
3. B b = new A()
4. B b = new B()
Correct Answer

(B) 2 and 4

[#249] Which of the following is a correct interface?
Correct Answer

(D) interface A { void print() }

[#250] 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")
}
}
Correct Answer

(D) b is an instance of A followed by b is an instance of C.