PRACTICE • LEARN • GROW
Module 2 Final Quiz: Classes and Objects MCQs
Solve topic-wise placement questions and improve your skills.
Module 2 Final Quiz: Classes and Objects Progress
0 of 11 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
What happens in memory when executing 'Car myCar = new Car();' in Java or C#?
A.
The object fields and method code are all duplicated in stack memory
B.
A reference pointer is created on the stack while the actual object state is allocated on the heap
C.
Only static memory is allocated
D.
The entire process space is remapped
Explanation & Key
Correct Answer:
2
Which access modifier restricts member visibility strictly to within the declaring class itself?
A.
public
B.
protected
C.
private
D.
package-private
Explanation & Key
Correct Answer:
3
What is the return type of a constructor in languages like C++ and Java?
A.
void
B.
int
C.
Constructors have no return type, not even void
D.
pointer to this
Explanation & Key
Correct Answer:
4
If a developer declares a parameterized constructor in a Java class, what happens to the default zero-argument constructor?
A.
The compiler continues to provide the default constructor automatically
B.
The compiler no longer provides the implicit zero-argument constructor; it must be written explicitly if needed
C.
A compilation error occurs immediately
D.
All fields become immutable
Explanation & Key
Correct Answer:
5
Which constructor is specifically designed to initialize a new object using the state of an existing object?
A.
Static constructor
B.
Copy constructor
C.
Abstract constructor
D.
Virtual constructor
Explanation & Key
Correct Answer:
6
How do C++ and Java differ regarding object destruction and resource release?
A.
Java has deterministic destructors; C++ relies purely on automatic garbage collection
B.
C++ provides deterministic destructors (~ClassName) executed upon scope exit, while Java relies on non-deterministic Garbage Collection
C.
Neither language supports memory reclamation
D.
C++ cannot free dynamic heap memory
Explanation & Key
Correct Answer:
7
Which access modifier allows members to be accessed by derived subclasses, even if the subclass is in a different package (in Java)?
A.
private
B.
protected
C.
default
D.
transient
Explanation & Key
Correct Answer:
8
What is the primary role of the 'this' reference pointer inside an instance method?
A.
Points to the OS kernel thread
B.
Refers to the current invoking instance on which the method was called
C.
Points to the superclass metadata table
D.
Allocates a new heap segment
Explanation & Key
Correct Answer:
9
What is Constructor Chaining?
A.
Calling a constructor from another constructor within the same class (using this()) or superclass (using super())
B.
Creating an infinite loop of new instances
C.
Compiling multiple classes in a single command
D.
Chaining arithmetic operators together
Explanation & Key
Correct Answer:
10
What occurs if an unhandled NullPointerException or null reference dereference happens in OOP?
A.
The CPU automatically allocates a blank object
B.
A runtime exception is thrown because a reference variable pointing to null was invoked
C.
The compiler rewrites the code to use zero
D.
The disk drive shuts down
Explanation & Key
Correct Answer:
11
In C++, if dynamic memory is allocated using 'new' inside a constructor, what must be implemented to prevent memory leaks?
A.
A static initializer
B.
A custom Destructor that executes 'delete' / 'delete[]'
C.
An interface implementation
D.
A volatile modifier
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong