0
0
Javaprogramming~5 mins

Abstract vs concrete classes in Java - Quick Revision & Key Differences

Choose your learning style9 modes available
Recall & Review
beginner
What is an abstract class in Java?
An abstract class in Java is a class that cannot be instantiated directly. It can have abstract methods (without body) that must be implemented by subclasses, and it can also have concrete methods with implementations.
Click to reveal answer
beginner
What is a concrete class in Java?
A concrete class in Java is a class that can be instantiated. It provides implementations for all its methods and can be used to create objects.
Click to reveal answer
beginner
Can you create an object of an abstract class directly?
No, you cannot create an object of an abstract class directly. You must create an object of a subclass that extends the abstract class and implements its abstract methods.
Click to reveal answer
intermediate
Why use abstract classes instead of concrete classes?
Abstract classes are used to define a common template or blueprint for subclasses. They allow you to enforce certain methods to be implemented while sharing common code, promoting code reuse and design clarity.
Click to reveal answer
intermediate
What happens if a concrete class does not implement all abstract methods from its abstract superclass?
If a concrete class does not implement all abstract methods from its abstract superclass, the concrete class must also be declared abstract. Otherwise, the code will not compile.
Click to reveal answer
Which of the following statements is true about abstract classes in Java?
AAbstract classes are the same as interfaces.
BAbstract classes cannot have any methods with implementation.
CYou cannot create an instance of an abstract class.
DAbstract classes must be final.
What must a concrete subclass do when it extends an abstract class?
ADeclare itself abstract.
BHave no constructors.
COverride all concrete methods of the abstract class.
DImplement all abstract methods of the abstract class.
Which keyword is used to declare an abstract class in Java?
Aconcrete
Babstract
Cstatic
Dfinal
Can a concrete class extend an abstract class?
AYes, and it must implement all abstract methods.
BNo, only abstract classes can extend abstract classes.
CYes, but it cannot add new methods.
DNo, concrete classes cannot extend any class.
If a class has at least one abstract method, what must be true?
AThe class must be declared abstract.
BThe class must be final.
CThe class must be concrete.
DThe class must have no constructors.
Explain the difference between abstract and concrete classes in Java.
Think about whether you can create objects and if methods have bodies.
You got /4 concepts.
    Describe why and when you would use an abstract class instead of a concrete class.
    Consider design and code reuse benefits.
    You got /4 concepts.