Instantiation MCQs: 6 Solved MCQs Plus 3 Object-Creation Problems
Solve six published MCQs and three short object-creation problems. Each answer uses a concrete state, construction or lifetime trace.
KnowledgeGate Team
Exam prep & CS education

Object creation questions mix four events: storage allocation, state initialization, reference binding and resource release. Treating them as one event makes even a short new or constructor question easy to miss. Choose an option or write the state trace before checking each explanation. If the class-object distinction is blurred, revisit Object Oriented Technology Explained.
1. Separate class, object, reference and lifetime before solving

Term | Concrete meaning in the worked example |
|---|---|
Class |
|
Object |
|
Reference or variable |
|
Constructor |
|
Destructor or cleanup | releases owned resources when that language's lifetime rules trigger it |
Create g1 = Gauge("inlet", 42) and g2 = Gauge("outlet", 73). State:
Reference | Per-instance state |
|---|---|
|
|
|
|
Run g1.reading = g1.reading - 7: 42 - 7 = 35, while g2.reading remains 73. Set alias = g1, then run alias.reading += 4: 35 + 4 = 39. Both alias.reading and g1.reading now read 39 because the references identify one object. Runtime metadata may be shared, but ordinary instance fields belong to each object. For a broader refresher, use OOP for Teaching CS Exams.
2. Instantiation MCQs 1-2: runtime creation and constructor purpose
Question 1
Choose first.
When is the object created with new keyword?
A. At run time
B. At compile time
C. Depends on the code
D. None
Correct answer: A. At run time.
A compiler can translate Gauge g1 = new Gauge("inlet", 42), but the object-creation request occurs when execution reaches that expression. Before the line runs, g1 reaches no object. Afterwards, it reaches an object initialized with reading 42. Allocation machinery varies by language and runtime; the answer remains runtime creation.
Question 2
Source: Bihar STET 2025, Computer Science. Choose.
What is the purpose of a constructor in OOP?
A. To destroy objects
B. To create instances of abstract classes
C. To initialize object properties
D. To define abstract methods
Correct answer: C. To initialize object properties.
In Gauge("inlet", 42), the constructor assigns label = "inlet" and reading = 42, giving the new object a valid initial state. A destructor concerns cleanup. An abstract class cannot ordinarily be instantiated directly, while an abstract method describes part of a type's behavioural contract. Those alternatives do not express the constructor's purpose.
3. Instantiation MCQs 3-4: overloading and resource cleanup
Question 3
Source: Bihar STET 2025, Computer Science. Choose.
What is the term for the ability of a class to provide different implementations of a method based on the input parameters?
A. Overloading
B. Polymorphism
C. Inheritance
D. Encapsulation
Correct answer: A. Overloading.
Suppose one class defines area(int side) and area(int length, int width). For input 4, the first computes 4 x 4 = 16. For inputs 4, 6, the second computes 4 x 6 = 24. One method name with different parameter lists is overloading. Polymorphism is broader; inheritance and encapsulation describe different OOP relationships.
Question 4
Source: Bihar STET 2025, Computer Science. Choose.
What is the purpose of a destructor in OOP?
A. To create instances of classes
B. To handle exceptions
C. To free up resources when an object is destroyed
D. To define default values for properties
Correct answer: C. To free up resources when an object is destroyed.
Picture a C++ owner object holding file descriptor 7 and a 4096-byte buffer. When its lifetime ends, its destructor closes descriptor 7 and releases the owned buffer. Constructors establish initial state; exception handling is separate; default property values concern initialization. Destructor and garbage-collection rules differ across languages, so this C++-style cleanup sequence is not universal OOP behaviour.
4. Instantiation MCQs 5-6: one virtual base and Java construction order
Question 5
Source: BPSC TGT 2023, Computer Science. Trace, then choose.
What is virtual inheritance in C++?
A. C++ technique to enhance multiple inheritance
B. C++ technique to ensure that a private member of the base class can be accessed somehow
C. C++ technique to avoid multiple copies of the base class into children/derived class
D. More than one of the above
E. None of the above
Correct answer: C. C++ technique to avoid multiple copies of the base class into children/derived class.
Let Device { id = 42 } be the base, Printer and Scanner the intermediate classes, and AllInOne the final class. Without virtual inheritance, AllInOne can contain two Device base subobjects. If both intermediates inherit virtual public Device, it contains one shared Device base subobject with id = 42. Option A is vague, and virtual inheritance does not bypass private access.
Question 6

Write both outputs first.
Consider the following Java program:
// filename: Test2.java
class Test1 {
Test1(int x) {
System.out.println("Constructor called " + x);
}
}
// This class contains an instance of Test1
class Test2 {
Test1 t1 = new Test1(10);
Test2(int i) { t1 = new Test1(i); }
public static void main(String[] args) {
Test2 t2 = new Test2(5);
}
}What is the output of the above program?
A. error
B. Constructor called 10
Constructor called 5
C. 10 5
D. default value
Correct answer: B. Constructor called 10, then Constructor called 5, on separate lines.
First, new Test2(5) begins Test2 construction. Its field initializer runs before the constructor body, so new Test1(10) prints Constructor called 10. Then the body evaluates t1 = new Test1(i) with i = 5, printing Constructor called 5 and replacing the first reference. With no reference left, the first Test1 is eligible for garbage collection, not immediate deterministic destruction.
5. Practice problem 7: prove that two objects have separate state
Write the state trace first.
A beginner assumes that when multiple entities are created from the same class, they share the same memory location since they originate from a single definition. However, during testing, modifying one entity does not affect others.
- Evaluate whether this assumption is correct.
- Explain how memory is allocated for each entity.
- What relationship exists between the class definition and its entities in memory?
- Predict what would happen if only one entity is used repeatedly instead of creating multiple ones.
Answer format: written response, with no choices.
Model response: The assumption is incorrect for ordinary instance state. In the trace, g1 begins with reading 42 and g2 with 73. Subtracting 7 from g1 gives 42 - 7 = 35, while g2 stays at 73. The class defines structure and behaviour, but each object holds separate instance-field values. Shared class metadata and static fields are different from those per-object fields. If one object is reused for both records, assigning label = "outlet" and reading = 73 overwrites its earlier inlet, 35 state unless that earlier state was saved elsewhere.
6. Practice problem 8: connect a class definition to execution
Name both missing actions first.
A developer defines a class with multiple member functions but forgets to create any entity of that class in the program. As a result, the program runs but produces no meaningful output.
- Analyze why the functions are not executed.
- What essential step is missing in the program?
- How does this step connect the class definition to actual execution?
Answer format: written response, with no choices.
Model response: Declaring member functions defines available behaviour; it does not schedule those functions to run. In a C++-style example, Meter m; instantiates an object with reading = 0. The explicit call m.add(7); then calculates 0 + 7 = 7, and printing m.reading produces meaningful output. The missing steps are object instantiation and a method call, which connect the class definition to execution. A static member function can be called through the class, and some frameworks invoke lifecycle methods, but neither exception appears in this prompt, so it does not change the intended reasoning.
7. Practice problem 9: trace automatic and dynamic object lifetimes
Draw the ledger first.
A developer creates objects inside a function and observes that they are automatically destroyed when the function ends. In another case, objects created using a different approach persist even after function execution.
- Analyze the difference between these two memory behaviors.
- Identify which type of allocation is being used in both cases.
- Explain the impact on object lifetime and memory management.
- What risks arise if memory is not handled properly in the second case?
Answer format: written response, with no choices.
Model response: In this C++-specific ledger, function entry starts with live Widget count = 0. Creating Widget local{12}; with automatic storage changes the count to 1; leaving its block runs the destructor and returns it to 0. Creating Widget* p = new Widget{27}; uses dynamic allocation and changes the count to 1. Without delete p, it remains 1 after the function, and losing the pointer leaks the object. With delete p, it returns to 0. Poor manual ownership can also cause dangling pointers or double deletion. std::unique_ptr<Widget> is safer because it connects dynamic ownership to automatic cleanup.
8. Diagnose the misses and choose the next practice step
For Questions 1, 2 or 6, redraw creation and initialization. For Questions 3 or 5, separate overloading and virtual inheritance from broad OOP labels. For Question 4 or 9, rebuild the ownership ledger. For Questions 7 or 8, repeat the two-object trace and write the method call.
Retest: answer the 6 MCQs in 6 minutes, then use 9 minutes for the 3 problems, so 6 + 9 = 15 minutes. Continue with the Java Course, C++ Programming Course, or Coding & Skill Development Courses, according to your path.
Keep learning
Data Abstraction Explained: Hide Implementation Details with a Worked Java Example
See how a stable Account contract protects its invariant while the Java implementation changes from a running balance to a transaction ledger.
Programming Paradigms Explained: Concepts, Classifications and Worked Examples
Learn how imperative, procedural, object-oriented, functional and declarative styles organise the same computation, and how to classify code from visible evidence.
Introduction to Visual Basic (VB): Concepts, Worked Code and Exam Patterns
Learn how a VB.NET form turns text-box input and a button click into a traced result. Then practise operators, loops, procedures, scope and debugging.
Types of Programming Languages: Levels, Paradigms and Execution Models
Learn why low-level, object-oriented, compiled and dynamically typed describe different axes. Build a clear classification map through one result expressed three ways.





