Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Object-Oriented Programming (OOP)Easy
Q1. What is the 'new' keyword used for?
- A.Deleting an existing object from memory
- B.Declaring a new variable in the scope
- C.Defining a new method in the class
- D.Creating a new instance of a class✓ Correct
Explanation
The 'new' keyword allocates memory and creates a new instance of a class by invoking its constructor.
Report an error in this question
Object-Oriented Programming (OOP)Easy
Q2. What is a class in OOP?
- A.A variable type for storing data
- B.A blueprint for creating objects✓ Correct
- C.A loop construct for iteration
- D.A reusable function for operations
Explanation
A class defines the structure (attributes) and behavior (methods) that its objects will have.
Report an error in this question
Object-Oriented Programming (OOP)Easy
Q3. What is encapsulation?
- A.Inheriting properties from a parent class definition
- B.A sorting method that orders elements in a collection
- C.A type of iterative loop control structure in code
- D.Bundling data and methods while restricting direct access✓ Correct
Explanation
Encapsulation bundles data and methods together while hiding internal details, controlling access through public interfaces.
Report an error in this question
Object-Oriented Programming (OOP)Easy
Q4. What is a constructor?
- A.A static method belonging to the class itself
- B.A getter method that returns a field value
- C.A destructor that cleans up object state
- D.A special method called when creating an object✓ Correct
Explanation
A constructor is automatically invoked when a new object is instantiated, used to set up initial values.
Report an error in this question
Object-Oriented Programming (OOP)Easy
Q5. What is an object in OOP?
- A.A standalone function
- B.A class definition in code
- C.A primitive data type
- D.An instance of a class✓ Correct
Explanation
An object is a concrete instance of a class, with its own state and behavior.
Report an error in this question
Object-Oriented Programming (OOP)Easy
Q6. What is inheritance in OOP?
- A.Acquiring properties and methods from a parent class✓ Correct
- B.Creating a new object instance from a class
- C.A form of encapsulation that hides internal details
- D.A design pattern for structuring application code
Explanation
Inheritance allows a child class to reuse fields and methods of a parent class, promoting code reuse.
Report an error in this question
Object-Oriented Programming (OOP)Easy
Q7. What does the 'this' keyword refer to?
- A.The current object instance✓ Correct
- B.A static method reference
- C.The class definition itself
- D.The parent class reference
Explanation
'this' refers to the current object instance, used to access its own fields and methods within the class.
Report an error in this question
Object-Oriented Programming (OOP)Easy
Q8. What is an access modifier?
- A.A keyword controlling member visibility level✓ Correct
- B.A data type for storing numeric values only
- C.A type of loop construct in the language
- D.A constructor for initializing object state
Explanation
Access modifiers like public, private, and protected control which parts of the program can access a class's members.
Report an error in this question
Object-Oriented Programming (OOP)Easy
Q9. What is a method in OOP?
- A.A standalone function not tied to any class
- B.A function defined inside a class for objects✓ Correct
- C.A variable that stores data in the program
- D.A data type that defines value constraints
Explanation
A method is a function associated with a class that defines behavior and can access the object's attributes.
Report an error in this question
Object-Oriented Programming (OOP)Medium
Q10. What is an interface?
- A.A class with full method implementations provided
- B.A contract defining method signatures without bodies✓ Correct
- C.An abstract class with some methods implemented
- D.A type of variable for storing object references
Explanation
An interface defines a set of method signatures without implementation; classes implementing the interface must provide the method bodies.
Report an error in this question
Object-Oriented Programming (OOP)Easy
Q11. What is polymorphism?
- A.A class relationship defined by inheritance hierarchy
- B.A type of encapsulation hiding internal data details
- C.Different objects responding differently to same method✓ Correct
- D.Having only one single form of behavior always
Explanation
Polymorphism allows objects of different classes to be treated uniformly through a common interface while each provides its own implementation.
Report an error in this question
Object-Oriented Programming (OOP)Medium
Q12. What is the difference between method overloading and method overriding?
- A.They are the same concept with different names in different languages
- B.Overloading requires an inheritance hierarchy between the classes involved
- C.Overriding changes the method parameter list in the parent class definition
- D.Overloading: same name different params; overriding: same signature in subclass✓ Correct
Explanation
Overloading defines multiple methods with the same name but different parameters; overriding redefines a parent's method with the same signature in a subclass.
Report an error in this question
Object-Oriented Programming (OOP)Medium
Q13. What is a static method?
- A.A method belonging to the class not any specific instance✓ Correct
- B.A constructor method for initializing new object state
- C.A method that can never be overridden by subclasses
- D.A private method accessible only within the same class
Explanation
A static method belongs to the class itself, not to instances, and can be invoked without creating an object.
Report an error in this question
Object-Oriented Programming (OOP)Medium
Q14. What is the super keyword?
- A.A global variable accessible everywhere in code
- B.A reference to parent class for calling its members✓ Correct
- C.The main class that serves as program entry point
- D.A type of access modifier restricting member access
Explanation
'super' refers to the parent class and is used to call the parent's constructor, methods, or access parent fields.
Report an error in this question
Object-Oriented Programming (OOP)Medium
Q15. What is the difference between composition and inheritance?
- A.Composition is always slower than inheritance in performance
- B.Inheritance is an is-a relationship; composition is has-a✓ Correct
- C.They are exactly the same concept with no difference at all
- D.Inheritance is more flexible and loosely coupled overall
Explanation
Inheritance creates an 'is-a' relationship; composition creates a 'has-a' relationship, generally offering more flexibility.
Report an error in this question
Object-Oriented Programming (OOP)Medium
Q16. What are getter and setter methods?
- A.Static methods belonging to the class directly
- B.Methods for controlled field read and write access✓ Correct
- C.Loop constructs for iterating over collections
- D.Constructor types for initializing objects
Explanation
Getters return the value of private fields; setters allow controlled modification, enforcing encapsulation.
Report an error in this question
Object-Oriented Programming (OOP)Medium
Q17. What is an abstract class?
- A.A fully implemented class with all methods defined
- B.A static class that only contains class-level members
- C.A final class that cannot be extended by other classes
- D.A class that cannot be instantiated with abstract methods✓ Correct
Explanation
An abstract class cannot be instantiated directly and may contain abstract methods that concrete subclasses must override.
Report an error in this question
Object-Oriented Programming (OOP)Hard
Q18. What is the SOLID principle in OOP?
- A.A coding style guide for naming conventions in code
- B.A data structure for organizing elements efficiently
- C.Five design principles: SRP, OCP, LSP, ISP, and DIP✓ Correct
- D.A testing framework for validating software behavior
Explanation
SOLID comprises five principles for creating maintainable OOP software: SRP, OCP, LSP, ISP, and DIP.
Report an error in this question
Object-Oriented Programming (OOP)Hard
Q19. What is a mixin?
- A.A class that mixes different data types together randomly
- B.A class providing methods to others without being standalone✓ Correct
- C.A type of interface that defines a strict method contract
- D.A structural design pattern for building complex objects
Explanation
A mixin provides reusable methods to other classes via multiple inheritance or similar mechanisms, without being intended for standalone instantiation.
Report an error in this question
Object-Oriented Programming (OOP)Hard
Q20. What is the object slicing problem in C++?
- A.Splitting an object into smaller component parts for storage
- B.When assigning derived to base variable, derived data is lost✓ Correct
- C.A memory allocation issue caused by fragmented heap storage
- D.A threading problem from concurrent access to shared objects
Explanation
Object slicing occurs when a derived class object is copied to a base class variable by value, losing the derived class's additional data members.
Report an error in this question
Object-Oriented Programming (OOP)Medium
Q21. What is the Liskov Substitution Principle (LSP)?
- A.A design pattern for constructing complex object hierarchies
- B.A principle for sorting elements in a collection efficiently
- C.A rule for managing memory allocation in large applications
- D.Subclass objects should be substitutable for superclass objects✓ Correct
Explanation
LSP states that subclass objects must be substitutable for their parent class objects without altering the desirable properties of the program.
Report an error in this question
Object-Oriented Programming (OOP)Hard
Q22. What is a virtual method table (vtable)?
- A.A hash table for caching method results quickly
- B.A debug table for tracking method execution and logging
- C.A lookup table for resolving dynamic method calls at runtime✓ Correct
- D.A method list defined in the source code of the program
Explanation
A vtable is a compiler-generated table of function pointers used at runtime to resolve virtual method calls.
Report an error in this question
Object-Oriented Programming (OOP)Hard
Q23. What is the fragile base class problem?
- A.A compilation error from missing method implementations
- B.A memory leak caused by improper object disposal code
- C.A class that is too small to be useful on its own
- D.Base class changes can break derived classes unexpectedly✓ Correct
Explanation
The fragile base class problem occurs when modifications to a base class unintentionally break subclasses.
Report an error in this question
Object-Oriented Programming (OOP)Medium
Q24. What is the diamond problem?
- A.An error related to geometric shapes in rendering code
- B.A memory leak issue caused by circular object references only
- C.An ambiguity when inheriting from classes with common ancestor✓ Correct
- D.A compilation warning about unused variables in the program
Explanation
The diamond problem occurs when class D inherits from B and C, both inheriting from A, creating ambiguity about which version of A's members D should use.
Report an error in this question
Object-Oriented Programming (OOP)Hard
Q25. What is the difference between prototype-based and class-based OOP?
- A.Prototype-based OOP is always slower than class-based OOP overall
- B.Class-based uses blueprints; prototype-based clones existing objects✓ Correct
- C.They are the same approach with no meaningful differences at all
- D.Class-based OOP cannot support any form of inheritance at all
Explanation
Class-based OOP creates objects from class blueprints; prototype-based OOP creates objects by cloning prototypes and using delegation chains.
Report an error in this question
Object-Oriented Programming (OOP)Medium
Q26. What is multiple inheritance and which languages support it?
- A.Creating multiple instances of the same class simultaneously
- B.Inheriting from a single parent class in a linear hierarchy
- C.Inheriting from multiple parents; supported by C++ and Python✓ Correct
- D.All programming languages support this feature universally
Explanation
Multiple inheritance allows a class to inherit from more than one parent. C++ and Python support it; Java uses interfaces instead.
Report an error in this question
Object-Oriented Programming (OOP)Hard
Q27. What is the difference between association, aggregation, and composition?
- A.Association is general; aggregation weak; composition strong ownership✓ Correct
- B.They are all identical concepts with just different names used
- C.Composition is always the better design choice in every single case
- D.Only naming differences exist with no behavioral distinctions at all
Explanation
Association is a loose relationship; aggregation implies ownership but parts can exist independently; composition implies the part's lifecycle depends on the whole.
Report an error in this question
Object-Oriented Programming (OOP)Hard
Q28. What is covariant return type?
- A.A generic type parameter used in collection class definitions
- B.Allowing an overriding method to return a more specific subtype✓ Correct
- C.Always returning the exact same type as the parent declares
- D.A type error that occurs when return types do not match up
Explanation
Covariant return types allow an overriding method to narrow the return type to a subtype of the original.
Report an error in this question
Object-Oriented Programming (OOP)Hard
Q29. What is double dispatch and how does it differ from single dispatch?
- A.Single dispatch uses two methods while double dispatch uses only one
- B.There is no practical difference between the two dispatch mechanisms
- C.Single dispatch selects by one type; double dispatch by two types✓ Correct
- D.Double dispatch is twice as fast in execution as single dispatch
Explanation
Single dispatch resolves the method based on the receiver's type. Double dispatch considers both the receiver and the argument's types.
Report an error in this question
Object-Oriented Programming (OOP)Hard
Q30. What is metaclass programming?
- A.Creating graphical user interfaces programmatically
- B.Writing classes whose instances are themselves classes✓ Correct
- C.A commonly used structural design pattern for code
- D.Programming about programs in general terms
Explanation
A metaclass is a class whose instances are classes. Metaclass programming allows customizing class creation, adding behaviors, or enforcing constraints.
Report an error in this question