Which is a valid abstract class?

Which is a valid abstract class?

Which is a valid abstract class?

A.
public abstract class Car {
protected void accelerate();
}

B.
public interface Car {
protected abstract void accelerate();
}

C.
public abstract class Car {
protected final void accelerate();
}

D.
public abstract class Car {
protected abstract void accelerate();
}

E.
public abstract class Car {
protected abstract void accelerate() {
//more car can do
}}



Leave a Reply 3

Your email address will not be published. Required fields are marked *


Noname

Noname

The only correct class declaration is D.

Why not A: the method in abstract class may miss it’s declaration ONLY if it is marked with the “abstract” modifier

Why not B: we can’t use methods with modifier other then public with interface methods (just to note: the default access mode of interface method is equivalent to the pulic)

Why not C: what is the reason to finalize methods provided for implementstion? 🙂

Why not E: abstract class can not have it’s abstract methods declaration.

Hans

Hans

A missing abstract or missing body.
B an interface is not an abstract class.
C missing body
E abtstact method cannot have a body.

Kurt

Kurt

Yes, The correct answer is D