What is polymorphism, and what are its types?
Draft your answer mentally or on paper, then check the points you hit:
The 40 OOP questions, ranked by how many of the surveyed prep sources list each one.
Interview one-liner: Polymorphism lets one interface or method call behave differently depending on the object or arguments, mainly through overloading at compile time and overriding at run time.
Interview one-liner: Object-oriented programming organises a program as objects that combine data and the operations on that data, built from classes.
Interview one-liner: A constructor is a special method, named after its class with no return type, that the runtime calls automatically to initialise a new object.
Interview one-liner: An object is a runtime instance of a class that holds its own field values and responds to the methods its class defines.
Interview one-liner: Inheritance lets a new class reuse and extend the members of an existing class, modelling an is-a relationship between them.
Interview one-liner: Encapsulation keeps an object's data private and changes it only through methods that can enforce the class's own rules.
Interview one-liner: Abstraction exposes only the essential behaviour of an object and hides the implementation details behind it.
Interview one-liner: A class is a user-defined blueprint that declares the fields and methods every object of that type will have.
Interview one-liner: The four pillars of OOP are encapsulation, abstraction, inheritance and polymorphism, which together structure code around objects and their behaviour.
Interview one-liner: Overloading gives one class several methods with the same name and different parameters, while overriding replaces an inherited method's behaviour in a subclass.
Interview one-liner: A C++ destructor, written as a tilde and the class name, runs automatically when an object's lifetime ends to release what it holds.
Interview one-liner: The private modifier restricts a Java member to the class that declares it, which is the strictest of the four access levels.
Interview one-liner: The default constructor is the no-argument constructor that Java supplies only when a class declares no constructor of its own.
Interview one-liner: In C++, a struct and a class are nearly identical, and the one default difference is that struct members are public while class members are private.
Interview one-liner: Hierarchical inheritance is the form where one base class has several derived classes that each extend it directly.
Interview one-liner: An abstract class can share state and code with its subclasses, while an interface defines a contract that any unrelated class can implement.
Interview one-liner: In C++ a class becomes abstract when it has at least one pure virtual function, declared with = 0 after the function.
Interview one-liner: OOP improves reuse, modularity and maintenance, but its extra design structure can add complexity and overhead when a problem is small.
Interview one-liner: A Java class can implement any number of interfaces but extend only one superclass, which is how Java offers multiple types of behaviour.
Interview one-liner: An abstract class in Java cannot be instantiated directly, but it can hold constructors, fields and concrete methods for its subclasses to use.
Interview one-liner: Unlike procedural code that separates data from functions, OOP organises a program around objects that bundle their data with their operations.
Interview one-liner: A Java subclass method overrides its parent's method only when the name and parameter list match and access is not narrowed.
Interview one-liner: OOP helps organise large programs into reusable, self-contained units whose internal details can change without breaking the rest of the code.
Interview one-liner: Common object-oriented languages include Java, C++, C#, Python and Ruby, with Smalltalk as an early pioneer of the style.
Interview one-liner: Inheritance couples a subclass tightly to its parent, can break encapsulation, and in Java allows only one superclass, so composition is sometimes better.
Interview one-liner: A Java class declaration stores shared type information once, while each object gets memory only for its own instance fields.
Interview one-liner: In Java a static method can be called through the class name with no object, but an instance method needs an object to run against.
Interview one-liner: Abstraction hides complexity by exposing only essential behaviour, while encapsulation protects an object's data by restricting direct access to it.
Interview one-liner: Aggregation is a whole-part link where the part can exist independently of the whole, unlike composition where the part's lifetime depends on it.
Interview one-liner: In Java, dynamic dispatch picks the overriding method at run time based on the object's actual class, while overloads are fixed at compile time.
Interview one-liner: A valid Java overload needs the same name in one class with a different parameter list, meaning different types or number of parameters.
Interview one-liner: The diamond problem is ambiguity when a class inherits the same base through two paths, so Java allows one superclass and uses interfaces instead.
Interview one-liner: A copy constructor in Java is a constructor you write that builds a new object from an existing object of the same class.
Interview one-liner: A superclass is the class being extended, and a subclass is the class that extends it, inheriting its accessible members and adding its own.
Interview one-liner: In Java the finally block runs whether or not an exception was thrown, so it is the place for cleanup such as closing resources.
Interview one-liner: A class is the blueprint that declares fields and methods, and an object is an instance created from that blueprint with its own values.
Interview one-liner: In Java, super(...) calls a superclass constructor, and before JDK 25 it had to be the first statement in the subclass constructor.
Interview one-liner: The final keyword fixes a variable to one assignment, stops a method being overridden, and stops a class being extended.
Interview one-liner: Java's garbage collector automatically reclaims objects that can no longer be reached, at a time the runtime chooses.
Interview one-liner: In a Java constructor, this.name = name; copies the parameter into the object's field, because this points to the current object.
Completed
0 / 40
Due today
0
Subject
Object-Oriented Programming
Draft your answer mentally or on paper, then check the points you hit:
Draft your answer mentally or on paper, then check the points you hit:
Draft your answer mentally or on paper, then check the points you hit:
Draft your answer mentally or on paper, then check the points you hit:
Draft your answer mentally or on paper, then check the points you hit:
Draft your answer mentally or on paper, then check the points you hit:
Draft your answer mentally or on paper, then check the points you hit:
Draft your answer mentally or on paper, then check the points you hit:
Draft your answer mentally or on paper, then check the points you hit:
Draft your answer mentally or on paper, then check the points you hit:
Draft your answer mentally or on paper, then check the points you hit:
Draft your answer mentally or on paper, then check the points you hit:
Draft your answer mentally or on paper, then check the points you hit:
Draft your answer mentally or on paper, then check the points you hit:
Draft your answer mentally or on paper, then check the points you hit:
Draft your answer mentally or on paper, then check the points you hit: