Question 11
EasyWhat must a concrete (non-abstract) subclass of an abstract class do?
- A.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Object-Oriented Programming
What must a concrete (non-abstract) subclass of an abstract class do?
Declare itself abstract too
Implement all of the inherited abstract methods
Have no fields
Delete the parent's methods
Sign up free to see the answer and a step-by-step explanation.
In Java, can an abstract class contain ordinary methods with bodies?
No, only abstract methods
Only static methods
Yes
Only if it has no fields
Sign up free to see the answer and a step-by-step explanation.
In C++, what is a pure virtual function?
A function that cannot be called
A function with no parameters
A function that is inline
A virtual function declared with = 0, which makes the class abstract
Sign up free to see the answer and a step-by-step explanation.
Which keyword does a Java interface use to build on another interface?
uses
implements
inherits
extends
Sign up free to see the answer and a step-by-step explanation.
In Python, which decorator marks a method as abstract?
@virtual
@abstractmethod
@abstract
@interface
Sign up free to see the answer and a step-by-step explanation.
What happens when you try to create an object of a Python class that still has an unimplemented @abstractmethod?
A TypeError is raised
The method runs and returns None
The object is created normally
A SyntaxError is raised
Sign up free to see the answer and a step-by-step explanation.
In a Java interface (before Java 8), what were all its methods implicitly?
static
final
public and abstract
private
Sign up free to see the answer and a step-by-step explanation.
What does a well-designed API's abstraction hide from the code that uses it?
The implementation details
The return types
The method names
The documentation
Sign up free to see the answer and a step-by-step explanation.
A Shape class declares an abstract area() method, and Circle and Square implement it. What does this design allow?
Avoiding any calculations
Making all shapes the same size
Treating all shapes uniformly through Shape while each computes its own area
Creating objects of Shape directly
Sign up free to see the answer and a step-by-step explanation.
Since Java 8, besides default methods, which other kind of method can an interface contain with a body?
Abstract constructors
Static methods
Constructors
Destructors
Sign up free to see the answer and a step-by-step explanation.