139k views
2 votes
Public classes are accessible by all objects, which means that public classes can be ____, or used as a basis for any other class.

a.
copied

b.
used

c.
saved

d.
extended

2 Answers

6 votes

Answer:

d.extended

Step-by-step explanation:

The answer is d.

You usually has a top public class, for example, animals, with it's own attibutes. Then you can have other classes extending animals, for example, cats. These classes have both the attributes of the parent class, and their own attributes.

So the code goes something like this

public class Animals{

public Animals(){

\\constructor with attributes

}

\\code

}

public class Cats extends Animals{

public Cats(){

\\constructor with the extra attributes.

}

\\code

}

User GtAntoine
by
5.5k points
1 vote

Answer:

The correct answer is d.extended.

Step-by-step explanation:

In order to have a superclass in Java, it is indispensable to extend, or inherit from, a class. It means that a subclass is created by an extended class. All the classes in Java only need one superclass from which it inherits some of its fields and methods.

User Kevin Andrid
by
4.8k points