0
0
Javaprogramming~5 mins

Abstract classes in Java - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is an abstract class in Java?
An abstract class is a class that cannot be instantiated on its own and is meant to be a base class. It can have abstract methods (without body) that must be implemented by subclasses.
Click to reveal answer
beginner
Can an abstract class have concrete (non-abstract) methods?
Yes, an abstract class can have both abstract methods and concrete methods with full implementations.
Click to reveal answer
beginner
What keyword is used to declare an abstract class and an abstract method in Java?
The keyword <code>abstract</code> is used before the class name to declare an abstract class and before a method signature to declare an abstract method.
Click to reveal answer
beginner
Why can't you create an object of an abstract class?
Because abstract classes are incomplete by design (they may have abstract methods without implementation), Java prevents creating objects from them to avoid errors.
Click to reveal answer
intermediate
How do subclasses relate to abstract classes?
Subclasses must provide implementations for all abstract methods of the abstract class, or they must also be declared abstract.
Click to reveal answer
Which of the following is true about abstract classes in Java?
AYou cannot create an instance of an abstract class.
BAbstract classes cannot have any methods with implementation.
CAbstract classes are the same as interfaces.
DAbstract classes must have at least one abstract method.
What happens if a subclass does not implement all abstract methods of its abstract superclass?
AThe subclass will compile without errors.
BThe subclass must be declared abstract.
CThe subclass becomes a final class automatically.
DThe program will throw a runtime exception.
Which keyword is used to declare an abstract method?
Aabstract
Bfinal
Cstatic
Dvoid
Can an abstract class have constructors?
AOnly if all methods are abstract.
BNo, abstract classes cannot have constructors.
CYes, abstract classes can have constructors.
DOnly if the class has no abstract methods.
Which statement about abstract classes is false?
AAbstract classes can have fields and methods with implementations.
BAbstract methods must be implemented by subclasses unless the subclass is abstract.
CAbstract classes can be extended by other classes.
DYou can create an object of an abstract class using the new keyword.
Explain what an abstract class is and why it is useful in Java.
Think about a blueprint that is incomplete but guides other classes.
You got /5 concepts.
    Describe the rules for subclassing an abstract class in Java.
    Focus on what the subclass must do with abstract methods.
    You got /4 concepts.