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?
✗ Incorrect
Abstract classes cannot be instantiated directly, but they can have methods with implementation.
What must a concrete subclass do when it extends an abstract class?
✗ Incorrect
A concrete subclass must implement all abstract methods inherited from the abstract class.
Which keyword is used to declare an abstract class in Java?
✗ Incorrect
The keyword 'abstract' is used to declare an abstract class.
Can a concrete class extend an abstract class?
✗ Incorrect
Concrete classes can extend abstract classes but must implement all abstract methods.
If a class has at least one abstract method, what must be true?
✗ Incorrect
Any class with abstract methods must be declared abstract.
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.