Inheritance - Using extends QuizJ8 Home « Inheritance - Using extends Quiz

OO Concepts Quiz 4

The quiz below tests your knowledge of the material learnt in OO Concepts - Lesson 4 - Inheritance - Using extends.

Question 1 : What is output from the following code snippet?

package info.java8;
    public class A {
}
package info.java8;
    public class B {
}
package info.java8.sub;
import info.java8.A;
import info.java8.B;
public class AA extends A, B {
    public static void main(String[] args) {
        System.out.println("In class AA");
    }
}
- The code snippet doesn't compile as class <code>AA</code> cannot extend more than one class.
Question 2 : When using inheritance we use the extends keyword on the superclass?
- When using inheritance we use the <code>extends</code> keyword on the <i>subclass</i>.
Question 3 : How many classes can extend a class?
- Any number of classes can extend a class although each class can only extend one class.
Question 4 : Classes that inherit are more specialized versions of the general class?
- Classes that inherit are MORE specialized versions of the general class.
Question 5 : What is output from the following code snippet?

package info.java8;
public class A {
}

package info.java8.sub;
import info.java8.A;
public class AA extends A {
    public static void main(String[] args) {
        System.out.println("In class AA");
    }
}
- The code compiles and outputs <code>In class AA</code>.
Question 6 : Which is more abstract?
- The <i>superclass</i> is more abstract?.
Question 7 : How many classes can you extend in a Java class definition?
- You can only extend one class in a Java class definition.
Quiz Progress Bar Please select an answer


What's Next?

In the next quiz we test your knowledge of overriding methods when using inheritance.