ant2009
ant2009

Reputation: 22526

What are direct and indirect subclasses?

I was looking at Android development documentation, and I saw this:

public abstract class Buffer
extends Object

Known Direct Subclasses:
ByteBuffer, CharBuffer, DoubleBuffer, FloatBuffer, IntBuffer, LongBuffer, ShortBuffer

Known Indirect Subclasses:
MappedByteBuffer

Buffer is a abstract class that cannot be instantiated. It inherits (extends) Object.

But I am confused about the direct and indirect subclasses. My best guess would be: Direct extend directly from the superclass. Indirect extends from a superclass that directly extends the class in question.

Many thanks for any suggestions,

Upvotes: 18

Views: 8434

Answers (2)

Mercury
Mercury

Reputation: 7988

Given class A:

class B extends A // B is direct subclass of A
class C extends B // C is indirect subclass of A
class D extends C // D is indirect subclass of A

you get the point.


Another way to look at it is using this inheritance chain graph (A is the superclass, the rest inherits):

A->B->C->D

B is a direct subclass of A, the rest are indirect subclass of A.

Upvotes: 9

Elliott Frisch
Elliott Frisch

Reputation: 201447

You are correct. A known direct relationship implies that the class is the immediate ancestor. A known in-direct relationship implies that the class is known to be a sub-class, but it may in fact be many levels below the parent.

Upvotes: 18

Related Questions