Recall & Review
beginner
What is an abstract method in TypeScript?
An abstract method is a method declared in an abstract class without an implementation. Subclasses must provide their own implementation of this method.Click to reveal answer
beginner
Can you create an instance of an abstract class that contains abstract methods?No, you cannot create an instance of an abstract class. Abstract classes are meant to be extended by other classes that implement the abstract methods.
Click to reveal answer
beginner
How do you declare an abstract method in TypeScript?
Use the keyword
abstract before the method name and do not provide a method body. For example: abstract greet(): void;Click to reveal answer
intermediate
Why use abstract methods in a class?
Abstract methods enforce that subclasses implement specific methods, ensuring a consistent interface while allowing different behaviors in each subclass.
Click to reveal answer
intermediate
What happens if a subclass does not implement all abstract methods from its abstract superclass?The TypeScript compiler will give an error because the subclass must implement all abstract methods or be declared abstract itself.Click to reveal answer
Which keyword is used to declare an abstract method in TypeScript?
✗ Incorrect
The keyword
abstract is used to declare abstract methods in TypeScript.Can you instantiate an abstract class directly?
✗ Incorrect
Abstract classes cannot be instantiated directly in TypeScript.
What must a subclass do if it extends an abstract class with abstract methods?
✗ Incorrect
Subclasses must implement all abstract methods or be declared abstract themselves.
Which of the following is true about abstract methods?
✗ Incorrect
Abstract methods have no implementation in the abstract class and must be implemented in subclasses.
What error occurs if a subclass does not implement an abstract method?
✗ Incorrect
TypeScript compiler throws an error if a subclass does not implement all abstract methods.
Explain what an abstract method is and why it is useful in TypeScript classes.
Think about how abstract methods guide subclasses.
You got /4 concepts.
Describe the rules for subclassing an abstract class with abstract methods in TypeScript.
Focus on what the subclass must do with abstract methods.
You got /3 concepts.