Inheritance in Object-Oriented Programming
Which principle is best demonstrated when an array of type Animal contains elements like Dog, Cat, and Bird that all extend from Animal?
Interface implementation
Class abstraction
Code encapsulation
Subtype polymorphism
After successfully instantiating an object with 'new', what must always be followed by this expression?
A semicolon indicating end-of-the statement unless used in creational expressions like array initialization.
A cast operator matching either an interface or abstract class implemented/extended by the instantiated class.
A reference type that matches or is a supertype of the instantiated class' type.
An integer specifying how many objects should be created.
Given a base class Animal and derived classes Mammal, Bird, and Fish, which instantiation correctly demonstrates polymorphism?
Bird myPet = null
Animal myPet = new Fish()
Mammal myPet = new Bird()
Fish myPet = new Animal()
Assuming multiple inheritance is allowed and classes FlyingObject and Watercraft both have a default void method named 'activate', which implementation will be inherited in class 'Seaplane' without explicit override, given that 'Seaplane' extends both?
The activate() from FlyingObject is inherited due to lexical order.
This situation results in a compilation error due to ambiguity between parent class methods.
The activate() from Watercraft takes precedence as it's considered more specialized.
Both methods are inherited but neither can be used unless disambiguated by Seaplane.
What is commonly used in object-oriented programming to ensure derived class methods behave correctly?
Polymorphism testing with superclass references.
Recursion analysis for base and derived classes.
Algorithmic time complexity comparison.
Loop unrolling within inheritance structures.
Given an unsorted array, which algorithm would not be recommended if you need to prioritize memory efficiency and the input size is large?
QuickSort with recursion
In-place QuickSort with iteration
Iterative Merge Sort
Heap Sort without recursion
If Class C is a superclass of Class B and a subclass of Class A, which of the following is NOT valid?
C c = new C();
C b = new B();
A c = new C();
B c = new C();

How are we doing?
Give us your feedback and let us know how we can improve
If Class J is a superclass of Class K and Class L, which of the following are valid?
“J j = new J();” and “J k = new K();”
“J j = new J();”, “J k = new K();”, and “J l = new L();”
“J j = new J();” and “J l = new L();”
“J k = new K();”, and “J l = new L();”
Given classes Vehicle, Car extends Vehicle, and ElectricCar extends Car, which statement allows for polymorphism when declaring an array to store objects of all three types?
ElectricCar[] garage = new ElectricCar[10];
Vehicle[] garage = new Vehicle[10];
Object[] garage = new Object[10];
Car[] garage = new Car[10];
Which method signature correctly overrides the toString method inherited from the Object class?
public void toString()
private String toString()
public String toString()
public String toString(int num)