209k views
4 votes
2 What Java keyword is used to create a subclass? interface. extends. implements. inherits.

1 Answer

5 votes

Answer:

extends

Step-by-step explanation:

When you create a subclass, you basically say "I'm creating a new class, but for now it will look and behave the same as that other class", then you add its own personality.

The syntax is:

class SubClass extends SuperClass

Where SubClass is your new subclass what inherits methods and variables from the SuperClass.

So, if you add nothing to the SubClass, it will be a carbon copy of the SuperClass. But you can add methods and variables exclusive to this SubClass that the SuperClass won't have.

User DSA
by
5.1k points