PRACTICE • LEARN • GROW
Module 7 Final Quiz: Other Important OOP Concepts & SOLID Principles MCQs
Solve topic-wise placement questions and improve your skills.
Module 7 Final Quiz: Other Important OOP Concepts & SOLID Principles Progress
0 of 14 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
Where is a 'static' variable stored in memory, and how many copies exist?
A.
On the call stack of each thread; one copy per thread
B.
In the Metaspace/Class data area; exactly one copy shared across all instances
C.
In CPU L1 cache only
D.
On the heap; duplicated inside every instance
Explanation & Key
Correct Answer:
2
Why can't a static method directly access an instance variable like 'this.balance'?
A.
Static methods execute before the operating system boots
B.
Static methods belong to the class and do not execute in the context of any particular object instance (no implicit 'this' pointer)
C.
Static methods are written in C, not Java
D.
Instance variables are encrypted
Explanation & Key
Correct Answer:
3
What is the primary benefit of Generics in Java or Templates in C++?
A.
To encrypt network packets
B.
To enable compile-time type safety and code reusability without unsafe runtime type casts
C.
To speed up garbage collection cycles
D.
To bypass access modifiers
Explanation & Key
Correct Answer:
4
What does the 'Single Responsibility Principle' (SRP) mandate?
A.
Every developer must write only one function per day
B.
A class should have one, and only one, reason to change (a single cohesive responsibility)
C.
A program should run on only a single CPU core
D.
All methods must take only one parameter
Explanation & Key
Correct Answer:
5
Which SOLID principle states that software entities should be open for extension, but closed for modification?
A.
Single Responsibility Principle
B.
Open/Closed Principle (OCP)
C.
Liskov Substitution Principle
D.
Dependency Inversion Principle
Explanation & Key
Correct Answer:
6
What does the 'Liskov Substitution Principle' (LSP) require?
A.
Subclasses must always throw more exceptions than parent classes
B.
Objects of a superclass should be replaceable with objects of a subclass without breaking application correctness
C.
All base classes must be declared abstract
D.
Subclasses must duplicate parent methods
Explanation & Key
Correct Answer:
7
Which SOLID principle advises that 'clients should not be forced to depend upon interfaces they do not use'?
A.
Dependency Inversion Principle
B.
Interface Segregation Principle (ISP)
C.
Open/Closed Principle
D.
Single Responsibility Principle
Explanation & Key
Correct Answer:
8
What does the 'Dependency Inversion Principle' (DIP) state?
A.
Low-level modules should control high-level architecture
B.
High-level modules should not depend on low-level modules; both should depend on abstractions (interfaces)
C.
Code must be compiled in reverse order
D.
Functions must invert boolean return values
Explanation & Key
Correct Answer:
9
In exception handling, which block is GUARANTEED to execute regardless of whether an exception was thrown or caught?
A.
try
B.
catch
C.
finally
D.
throw
Explanation & Key
Correct Answer:
10
What is Type Erasure in Java Generics?
A.
Deleting variables when they are unreferenced
B.
The compiler removes generic type arguments during compilation and inserts casts, ensuring backward compatibility with older JVMs
C.
Erasing disk cache during compiling
D.
Converting all classes into primitive types
Explanation & Key
Correct Answer:
11
Which exception type in Java must either be caught in a try-catch block or declared in a throws clause?
A.
Unchecked Exceptions (RuntimeException)
B.
Checked Exceptions (Exception subclasses outside RuntimeException)
C.
Error subclasses (OutOfMemoryError)
D.
NullPointerExceptions
Explanation & Key
Correct Answer:
12
Why does the classic 'Square extends Rectangle' hierarchy violate the Liskov Substitution Principle?
A.
Square uses more memory than Rectangle
B.
Setting the width of a Square also alters its height, violating the behavioral expectations established by Rectangle's independent setters
C.
Square cannot be drawn on screen
D.
C++ does not allow geometric inheritance
Explanation & Key
Correct Answer:
13
In OOP, how are exceptions represented?
A.
As integer error return codes (-1, 0, 1)
B.
As first-class objects instantiated from Exception classes
C.
As raw processor interrupt vectors
D.
As text files written to /tmp
Explanation & Key
Correct Answer:
14
What design pattern is commonly used to implement the Dependency Inversion Principle?
A.
Singleton Pattern
B.
Dependency Injection (DI) / Factory Pattern
C.
Flyweight Pattern
D.
Prototype Pattern
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong