The correct answer is: A. subclass.
A subclass is a class that inherits from another class, called the superclass. The superclass is also called the parent class. The subclass can add new members, override existing members, and use the members of the superclass.
For example, the following code shows a class called Animal
and a subclass called Dog
:
“`class Animal {
public void eat() {
System.out.println(“Eating”);
}
}
class Dog extends Animal {
public void bark() {
System.out.println(“Woof!”);
}
}
“`
In this example, the Dog
class inherits from the Animal
class. The Dog
class can use all of the members of the Animal
class, including the eat()
method. The Dog
class can also add new members, such as the bark()
method.
The following code shows how to create an instance of a Dog
object and call the eat()
and bark()
methods:
Dog dog = new Dog();
dog.eat();
dog.bark();
This code will print the following output:
Eating
Woof!