Question 41
MediumWhich kind of polymorphism is method overloading?
- A.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Object-Oriented Programming
Which kind of polymorphism is method overloading?
Parametric polymorphism only
Run-time polymorphism
It is not polymorphism
Compile-time (static) polymorphism
Sign up free to see the answer and a step-by-step explanation.
Which feature is required for run-time polymorphism in C++?
Function overloading
Templates
Virtual functions called through a pointer or reference to the base class
Static functions
Sign up free to see the answer and a step-by-step explanation.
A Java method is declared void pay(Employee e). It is called with a Manager object, where Manager extends Employee and overrides calculateBonus(). Which calculateBonus() runs inside pay?
Both
Neither
Employee's
Manager's
Sign up free to see the answer and a step-by-step explanation.
Which pair is an overload, not an override?
speak() in Animal and in Dog
add(int a, int b) and add(double a, double b) in the same class
draw() in Shape and draw() in Circle with the same signature
toString() in Object and in Student
Sign up free to see the answer and a step-by-step explanation.
Can static methods be overridden in Java?
Only in interfaces
Only if they are final
Yes, exactly like instance methods
No; a subclass's static method with the same signature hides the parent's
Sign up free to see the answer and a step-by-step explanation.
What does the C++ keyword 'override' do?
Makes a function static
Makes a function virtual
Prevents overriding
Makes the compiler check that the function really overrides a virtual base function
Sign up free to see the answer and a step-by-step explanation.
What does 'final' on a C++ virtual function mean?
Derived classes cannot override it further
It is the last function in the class
It is a pure virtual function
It cannot be called
Sign up free to see the answer and a step-by-step explanation.
Why should a base class with virtual functions usually have a virtual destructor?
Destructors must always be virtual
So that deleting a derived object through a base pointer runs the derived destructor too
To speed up deletion
To make the class abstract
Sign up free to see the answer and a step-by-step explanation.
Which of these is an example of operator overloading in everyday Java?
&& on booleans
== comparing two ints
++ on an int
Sign up free to see the answer and a step-by-step explanation.
Templates in C++ and generics in Java provide which kind of polymorphism?
Parametric polymorphism
Run-time polymorphism by virtual dispatch
No polymorphism
Ad-hoc polymorphism by overloading
Sign up free to see the answer and a step-by-step explanation.