Technical MCQ
OOP & Design
Encapsulation, inheritance, polymorphism, SOLID and design patterns.
6 questions
Answer each one before scrolling to the solution. The explanation names the mechanism, not just the choice.
01Method overloading is an example of:
- A.Runtime polymorphism
- B.Compile-time polymorphism
- C.Encapsulation
- D.Abstraction
Answer. Overloading is resolved by the compiler based on the method signature, so it is compile-time (static) polymorphism.
02The Liskov Substitution Principle states that:
- A.Classes should be open for extension but closed for modification
- B.Subtypes must be usable wherever their base type is expected
- C.An object should have only one reason to change
- D.Depend on abstractions, not concretions
Answer. LSP requires a derived class to honour the contract of its base class, so substituting it never breaks the caller.
03Which pattern ensures a class has only one instance with a global access point?
- A.Factory
- B.Observer
- C.Singleton
- D.Decorator
Answer. The Singleton pattern controls instantiation so exactly one object exists, usually via a private constructor and a static accessor.
04Encapsulation is best described as:
- A.Inheriting behaviour from a parent
- B.Hiding internal state and exposing a controlled interface
- C.Having many forms of a method
- D.Splitting a program into modules
Answer. Encapsulation bundles data with the methods that operate on it and restricts direct external access to internal state.
05Composition is often preferred over inheritance because:
- A.It runs faster
- B.It avoids tight coupling and fragile base-class problems
- C.It uses less memory
- D.It is required by compilers
Answer. Composition lets behaviour be assembled at runtime and avoids the rigid, breakage-prone hierarchies inheritance creates.
06An abstract class differs from an interface in that it:
- A.Cannot have methods
- B.Can contain state and concrete methods
- C.Cannot be extended
- D.Has no constructor
Answer. An abstract class may hold fields, constructors and implemented methods, whereas a traditional interface defines only a contract.
Practise here. Get placed there.
Prep+ is unlimited practice. When you are ready to turn it into an offer, TCC Placement Partner handles portfolio, resume and interviews.