Instantiation in Object Oriented Programming (OOPs) MCQ Questions and Answers

1. In object-oriented programming, what does the term “instantiation” refer to?
A) The process of defining a class
B) The process of copying a function
C) The process of creating an object from a class
D) The process of compiling code
Answer: C

2. What is created when a class is instantiated in Java?
A) A constructor
B) A class template
C) An object
D) A static variable
Answer: C

3. Which keyword is used in Java to instantiate a class?
A) create
B) new
C) init
D) make
Answer: B

4. In C++, which operator is used for dynamic instantiation?
A) malloc
B) calloc
C) new
D) dynamic
Answer: C

5. What happens during instantiation?
A) Class definition is loaded
B) Function overloading occurs
C) Memory is allocated for the object
D) The compiler links the class
Answer: C

6. When a class is instantiated, which method is typically called automatically?
A) Destructor
B) Static method
C) Constructor
D) Virtual method
Answer: C

7. In Python, which syntax is used to instantiate a class Dog?
A) Dog.create()
B) d = Dog()
C) Dog.new()
D) instantiate(Dog)
Answer: B

8. What is required before a class can be instantiated?
A) The class must inherit another class
B) The class must be abstract
C) The class must be defined
D) The class must be static
Answer: C

9. What does the process of instantiation NOT involve?
A) Allocating memory
B) Calling a constructor
C) Defining methods
D) Initializing data members
Answer: C

10. If Student s1 = new Student(); is executed, what occurs?
A) Class definition is overwritten
B) Object s1 becomes static
C) Object s1 is instantiated from class Student
D) Constructor is skipped
Answer: C

11. Which of the following cannot be instantiated?
A) Normal class
B) Abstract class
C) Static class
D) Final class
Answer: B

12. Which keyword prevents a class from being subclassed but allows instantiation?
A) abstract
B) final
C) static
D) virtual
Answer: B

13. What happens if an abstract class is instantiated directly?
A) It creates a null object
B) A compile-time error occurs
C) It runs without issue
D) It creates an empty object
Answer: B

14. In C++, when is an object instantiated automatically?
A) When declared inside a function
B) When declared static
C) When declared on the stack
D) When declared as a pointer
Answer: C

15. What type of instantiation occurs when objects are created at runtime?
A) Static instantiation
B) Dynamic instantiation
C) Temporal instantiation
D) Recursive instantiation
Answer: B

16. In Java, what is the result of calling a constructor during instantiation?
A) Memory deallocation
B) Object initialization
C) Type casting
D) Garbage collection
Answer: B

17. Which of the following statements correctly instantiates a class Person in C++?
A) Person.create();
B) Person p1;
C) new Person();
D) create(Person);
Answer: B

18. What is instantiated when the new operator is used in Java?
A) Method
B) Package
C) Object
D) Interface
Answer: C

19. What will happen if a class without a constructor is instantiated?
A) Instantiation fails
B) Default constructor is provided by compiler
C) Runtime error occurs
D) Object is not created
Answer: B

20. In C++, what does Student *s = new Student(); do?
A) Declares a function
B) Dynamically allocates memory for an object
C) Initializes static data
D) Deletes an object
Answer: B

21. When an object is instantiated, which of the following is true?
A) Only static members exist
B) Class definition is destroyed
C) Instance variables are created
D) Class becomes private
Answer: C

22. In Java, what is the output type of instantiation new String(“Hi”)?
A) char array
B) null reference
C) String object
D) Function pointer
Answer: C

23. What happens to memory allocated during instantiation after program termination?
A) It persists in RAM
B) It’s manually freed
C) It’s automatically released
D) It’s saved to disk
Answer: C

24. Which type of class cannot be instantiated in Java?
A) Final
B) Abstract
C) Public
D) Private
Answer: B

25. What is the difference between class definition and instantiation?
A) Both allocate memory
B) Both compile code
C) Definition declares, instantiation creates
D) Definition executes methods
Answer: C

26. Which concept allows multiple objects to be instantiated from the same class?
A) Polymorphism
B) Abstraction
C) Reusability
D) Encapsulation
Answer: C

27. During instantiation, which component assigns initial values to data members?
A) Destructor
B) Static method
C) Constructor
D) Main function
Answer: C

28. What does the term “instance” mean?
A) A template
B) A specific object created from a class
C) A variable type
D) A static function
Answer: B

29. When does static memory allocation occur?
A) At compile time
B) At runtime
C) During execution of constructor
D) During garbage collection
Answer: A

30. When an object is instantiated dynamically, what must eventually happen?
A) Memory deallocation manually
B) Constructor re-execution
C) Memory must be freed using delete or GC
D) Reassignment to null
Answer: C

31. Which of the following statements about object instantiation is true?
A) Instantiation creates a new class definition
B) Instantiation creates an object from a class
C) Instantiation deletes an existing object
D) Instantiation copies static variables
Answer: B

32. Which memory area in Java stores instantiated objects?
A) Stack
B) Heap
C) Register
D) Static segment
Answer: B

33. Which of the following cannot be instantiated directly?
A) Normal class
B) Interface
C) Public class
D) Inner class
Answer: B

34. Which method in Java is called during object instantiation?
A) finalize()
B) static()
C) constructor()
D) start()
Answer: C

35. When a subclass is instantiated, which constructor runs first?
A) Subclass constructor
B) Superclass constructor
C) Both simultaneously
D) None
Answer: B

36. What does the keyword this refer to during instantiation?
A) Static data of the class
B) The current object instance
C) Parent class
D) Method arguments
Answer: B

37. What does the new operator return in Java?
A) Constructor value
B) Method reference
C) Reference to the created object
D) Null value
Answer: C

38. Which of these can be instantiated using an anonymous class in Java?
A) Static methods
B) Packages
C) Interfaces
D) Namespaces
Answer: C

39. What will happen if a class has a private constructor?
A) It cannot be subclassed
B) It cannot be instantiated outside the class
C) It causes a syntax error
D) It can be instantiated only once
Answer: B

40. Which OOP feature allows multiple objects to be instantiated with different states?
A) Inheritance
B) Encapsulation
C) Polymorphism
D) Data hiding
Answer: B

41. Which function is automatically called when an object is instantiated in C++?
A) init()
B) allocate()
C) Constructor
D) delete()
Answer: C

42. What is true about dynamic instantiation?
A) It allocates memory at compile-time
B) It always uses stack memory
C) It uses heap memory and runtime allocation
D) It is faster than static allocation
Answer: C

43. Which of these statements creates an object named car from class Vehicle in Java?
A) Vehicle car()
B) Vehicle new car
C) Vehicle car = new Vehicle();
D) car = Vehicle()
Answer: C

44. In C++, when an array of objects is instantiated, which constructor is called?
A) Final constructor
B) Default constructor for each element
C) Only first constructor
D) No constructor
Answer: B

45. What will happen if a constructor is declared private in a singleton class?
A) The class cannot be instantiated at all
B) The class can be instantiated multiple times
C) Only one instance can be created internally
D) Memory leak occurs
Answer: C

46. Which of the following ensures that instantiation happens only once?
A) Abstract class
B) Interface
C) Singleton pattern
D) Inheritance
Answer: C

47. What is an instance variable?
A) Variable declared inside a static block
B) Variable shared by all objects
C) Variable created during object instantiation
D) Variable used by constructors only
Answer: C

48. What happens if delete is used on a statically instantiated object in C++?
A) Memory leak occurs
B) Constructor is re-invoked
C) Undefined behavior occurs
D) Object remains unchanged
Answer: C

49. What type of instantiation is done using stack memory?
A) Heap instantiation
B) Static or automatic instantiation
C) Dynamic instantiation
D) Manual instantiation
Answer: B

50. When does a destructor execute in relation to instantiation?
A) Before instantiation
B) During instantiation
C) After the object goes out of scope
D) During class loading
Answer: C

51. Which of the following represents an instantiated object in Java?
A) class Car {}
B) Car;
C) Car c = new Car();
D) Car()
Answer: C

52. In OOP, which statement is true about a class before instantiation?
A) It occupies memory for variables
B) It runs constructors automatically
C) It is only a blueprint without allocated memory
D) It performs garbage collection
Answer: C

53. How can an interface be instantiated indirectly in Java?
A) Through multiple inheritance
B) By declaring it static
C) By implementing it in a class and instantiating that class
D) By using default methods
Answer: C

54. Which constructor is called when a derived object is instantiated in C++?
A) Destructor of base class
B) Base class constructor first, then derived
C) Derived class constructor only
D) No constructor is called
Answer: B

55. Which keyword in C# is used to instantiate an object?
A) instance
B) new
C) init
D) make
Answer: B

56. What is the output type of instantiation if a constructor returns nothing?
A) void
B) Reference to the object
C) Null
D) int
Answer: B

57. Which of these is a necessary condition for instantiation?
A) Constructor must be overloaded
B) Class must be abstract
C) Class must be concrete (non-abstract)
D) Class must be static
Answer: C

58. Which of the following involves instantiation during program execution?
A) Variable declaration
B) Function definition
C) Object creation
D) Class compilation
Answer: C

59. Which type of instantiation is performed when creating objects with new keyword in Java?
A) Static instantiation
B) Compile-time instantiation
C) Dynamic instantiation
D) Recursive instantiation
Answer: C

60. Which of the following statements is TRUE regarding static classes?
A) They can be instantiated directly
B) They can be inherited
C) They cannot be instantiated
D) They always contain constructors
Answer: C

61. What does “copy instantiation” mean in C++?
A) Creating a class from another class
B) Creating a pointer to an object
C) Creating a new object as a copy of an existing one
D) Creating an abstract object
Answer: C

62. Which function in C++ handles copy instantiation?
A) Assignment operator
B) Default constructor
C) Copy constructor
D) Destructor
Answer: C

63. In which of the following scenarios does lazy instantiation occur?
A) When objects are created during compilation
B) When constructors are overloaded
C) When objects are created only when first needed
D) When static members are declared
Answer: C

64. Lazy instantiation is most used in which design pattern?
A) Factory Pattern
B) Singleton Pattern
C) Observer Pattern
D) Adapter Pattern
Answer: B

65. What does eager instantiation mean?
A) Creating objects after first access
B) Instantiating objects on demand
C) Creating objects as soon as the class is loaded
D) Creating objects using recursion
Answer: C

66. Which of the following is true about static object instantiation in C++?
A) It requires the new operator
B) It occurs at runtime
C) Memory is allocated on the stack
D) The object must be deleted manually
Answer: C

67. Which function releases memory after instantiation in C++?
A) Constructor
B) Destructor
C) Allocator
D) Free()
Answer: B

68. What happens if a constructor throws an exception during instantiation?
A) Object is still created
B) Object creation fails
C) Destructor is called
D) Compiler retries instantiation
Answer: B

69. What is the purpose of the super() keyword in Java instantiation?
A) To destroy objects
B) To call an interface method
C) To call the superclass constructor
D) To create static variables
Answer: C

70. Which constructor is called first when a derived class is instantiated in Java?
A) Derived class constructor
B) Base class constructor
C) Default class constructor
D) Virtual constructor
Answer: B

71. Which of the following allows multiple objects of the same class to exist independently?
A) Static members
B) Singletons
C) Separate instantiation of the class
D) Class templates
Answer: C

72. Which of the following keywords cannot instantiate an interface in Java?
A) implements
B) new
C) class
D) public
Answer: B

73. What happens if you try to instantiate an abstract class in Java?
A) It returns null
B) It creates an empty object
C) It causes a compile-time error
D) It calls a default constructor
Answer: C

74. What is an “anonymous object”?
A) An object with a null reference
B) An object created without storing its reference
C) An object that can’t call methods
D) A static instance
Answer: B

75. In Java, which code correctly demonstrates an anonymous object?
A) Student s = new Student();
B) new Student();
C) Student();
D) create(Student);
Answer: B

76. Which keyword in C++ is used to explicitly destroy an object instantiated with new?
A) free
B) delete
C) remove
D) clear
Answer: B

77. What is true about instantiation of static classes in C#?
A) They can be instantiated like normal classes
B) They cannot be instantiated at all
C) They can only be instantiated once
D) They require virtual constructors
Answer: B

78. Which operator allocates memory for object instantiation in C++?
A) malloc
B) calloc
C) new
D) alloc
Answer: C

79. When an object is instantiated using the new keyword, what is returned?
A) Object ID
B) Function pointer
C) Address of the object
D) Copy of the class
Answer: C

80. What is “object reference” in the context of instantiation?
A) Memory allocated to class methods
B) A variable that holds the address of the instantiated object
C) The constructor’s return value
D) The destructor call
Answer: B

81. What is instantiated when ArrayList<Integer> list = new ArrayList<>(); is executed?
A) Generic type
B) Interface
C) Concrete implementation of ArrayList
D) Wrapper class
Answer: C

82. What will happen if a class has no constructor and is instantiated in Java?
A) Compilation fails
B) Object is not created
C) Compiler inserts a default constructor
D) JVM throws exception
Answer: C

83. Which type of class is designed to prevent multiple instantiations?
A) Abstract
B) Static
C) Singleton
D) Final
Answer: C

84. What ensures thread-safe instantiation in a singleton pattern?
A) Static blocks
B) Synchronization mechanisms
C) Copy constructor
D) Virtual functions
Answer: B

85. Which design pattern defers instantiation to subclasses?
A) Singleton
B) Factory Method
C) Builder
D) Prototype
Answer: B

86. In which design pattern is object instantiation centralized?
A) Observer
B) Factory Pattern
C) Adapter
D) Bridge
Answer: B

87. Which pattern duplicates existing objects instead of instantiating new ones?
A) Factory
B) Builder
C) Prototype
D) Decorator
Answer: C

88. When is a copy constructor called in C++?
A) During object destruction
B) During inheritance
C) When an object is initialized using another object
D) When a static variable is declared
Answer: C

89. Which of these can instantiate a class with private constructor?
A) Another unrelated class
B) Static method inside the same class
C) Derived class
D) External package
Answer: B

90. Which process follows instantiation immediately in an object’s lifecycle?
A) Compilation
B) Initialization
C) Garbage collection
D) Deallocation
Answer: B

91. What happens if a class contains only static methods?
A) It can be instantiated
B) Instantiation is unnecessary
C) It must be abstract
D) It will throw runtime error
Answer: B

92. What ensures that each object has its own copy of instance variables?
A) Static binding
B) Inheritance
C) Instance-based memory allocation during instantiation
D) Compilation
Answer: C

93. Which type of instantiation occurs when an object is declared globally in C++?
A) Heap instantiation
B) Static instantiation
C) Dynamic instantiation
D) Recursive instantiation
Answer: B

94. Which of the following is created only after instantiation?
A) Class methods
B) Static blocks
C) Instance methods and variables
D) Inheritance hierarchy
Answer: C

95. What will happen if delete is called twice on the same instantiated object?
A) It resets the pointer
B) Undefined behavior occurs
C) Memory is reclaimed safely
D) Destructor runs twice correctly
Answer: B

96. Which object is automatically instantiated by the JVM in every Java program?
A) Object of main class
B) String array for command-line arguments
C) Scanner object
D) Thread object
Answer: B

97. What is the purpose of constructors in object instantiation?
A) Destroy objects
B) Allocate stack memory
C) Initialize object’s data members
D) Manage garbage collection
Answer: C

98. Which type of instantiation is used when objects are created at runtime based on user input?
A) Static instantiation
B) Predefined instantiation
C) Dynamic instantiation
D) Parallel instantiation
Answer: C

99. Which operator in Java triggers object instantiation and memory allocation simultaneously?
A) alloc
B) malloc
C) new
D) init
Answer: C

100. Which of the following best defines instantiation?
A) Declaring a method
B) Initializing a loop variable
C) Creating an object from a class definition
D) Defining a package
Answer: C