Inheritance - Basics QuizJ8 Home « Inheritance - Basics Quiz

OO Concepts Quiz 3

The quiz below tests your knowledge of the material learnt in OO Concepts - Lesson 3 - Inheritance - Basics.

Question 1 : In inheritance the general class that holds the group of common characteristics is known as what?
- In inheritance the general class that holds the group of common characteristics is known as the <i>superclass</i>.
Question 2 : Is the following code snippet valid?

package info.java8;
public class A {
}

package info.java8.sub;
import info.java8.A;
public class AA extends A {
}
- The code snippet IS valid as class <code>A</code> is <code>public</code> and so class <code>AA</code> can inherit from it.
Question 3 : How is inheritance achieved?
- Inheritance is achieved using the <code>extends</code> keyword.
Question 4 : Classes that inherit are less 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;
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 snippet doesn't compile as class <code>AA</code> cannot access class <code>A</code> as it isn't in the same package.
Question 6 : We can inherit any class?
- We CANNOT inherit any class, as an example we cannot inherit a class outside the package this class is in that isn't <code>public</code>.
Question 7 : In inheritance the inheriting class is known as what?
- In inheritance the inheriting class is known as the <i>subclass</i>.
Quiz Progress Bar Please select an answer


What's Next?

In the next quiz we test your knowledge of using the extends keyword.