OOP Using Java •
MCQ • OOP Concepts
Most Important 30 Objective Question - Object , Class, Constructor
Q1. Which of the following is a blueprint of an object?
A) Method
B) Constructor
C) Class
D) Package
Answer: C) Class
Explanation:A class is called the blueprint or template of an object because it defines properties and behaviors.
Q2. An object is an instance of:
A) Method
B) Class
C) Constructor
D) Interface
Answer: B) Class
Explanation:An object is a real-world entity created from a class.
Example:
Student s = new Student();
Q3. Which keyword is used to create an object in Java?
A) class
B) new
C) object
D) create
Answer: B) new
Explanation:The new keyword is used to allocate memory and create an object.
Q4. Which method has the same name as the class?
A) Main Method
B) Constructor
C) finalize()
D) Static Method
Answer: B) Constructor
Explanation:A constructor always has the same name as the class and is used to initialize objects.
Q5. Constructor is automatically called when:
A) Class is created
B) Object is created
C) Method is called
D) Program ends
Answer: B) Object is created
Explanation:When an object is created using the new keyword, the constructor is called automatically.
Q6. Which constructor has no parameters?
A) Parameterized Constructor
B) Copy Constructor
C) Default Constructor
D) Static Constructor
Answer: C) Default Constructor
Explanation:A constructor without parameters is called the default constructor.
Q7. Which constructor accepts parameters?
A) Default Constructor
B) Parameterized Constructor
C) Empty Constructor
D) Private Constructor
Answer: B) Parameterized Constructor
Explanation:A constructor that takes arguments is called a parameterized constructor.
Q8. Which concept allows multiple methods with same name but different parameters?
A) Overriding
B) Inheritance
C) Overloading
D) Encapsulation
Answer: C) Overloading
Explanation:Method overloading means same method name but different number or type of parameters.
Q9. Which keyword refers to the current object?
A) super
B) this
C) final
D) static
Answer: B) this
Explanation:The this keyword refers to the current object of the class.
Q10. Which keyword is used to share a common variable among all objects?
A) final
B) private
C) static
D) public
Answer: C) static
Explanation:A static variable belongs to the class, not to individual objects.
Q11. Which access modifier allows access only within the same class?
A) public
B) protected
C) private
D) default
Answer: C) private
Explanation:Private members are accessible only inside the same class.
Q12. Which access modifier allows access from anywhere?
A) public
B) private
C) protected
D) default
Answer: A) public
Explanation:Public members can be accessed from any class.
Q13. Which of the following is used to destroy unused objects?
A) delete()
B) remove()
C) Garbage Collection
D) destroy()
Answer: C) Garbage Collection
Explanation:Java automatically removes unused objects using Garbage Collection.
Q14. Which method is called before an object is destroyed?
A) main()
B) start()
C) finalize()
D) stop()
Answer: C) finalize()
Explanation:The finalize() method is called before garbage collection destroys the object.
Q15. Which class is used to handle text strings in Java?
A) Integer
B) String
C) Scanner
D) Object
Answer: B) String
Explanation:The String class is used to store and manipulate text in Java.
Q16. Which of the following is used to create multiple objects of a class?
A) Array of Objects
B) Package
C) Interface
D) Inheritance
Answer: A) Array of Objects
Explanation:When multiple objects of the same class are needed, we use an Array of Objects.
Q17. Which keyword is used to call the constructor of the same class?
A) super
B) this
C) static
D) final
Answer: B) this
Explanation:The this() keyword is used to call another constructor of the same class.
Q18. Which keyword is used to call static members?
A) object name
B) class name
C) this
D) super
Answer: B) class name
Explanation:Static members belong to the class, so they are accessed using the class name.
Example:
Student.count
Q19. Which of the following cannot be declared as static?
A) Variable
B) Method
C) Class (outer class)
D) Block
Answer: C) Class (outer class)
Explanation:Outer classes cannot be static, but nested classes can be static.
Q20. Which type of class is defined inside another class?
A) Main Class
B) Nested Class
C) Final Class
D) Abstract Class
Answer: B) Nested Class
Explanation:A class declared inside another class is called a nested class.
Q21. Which nested class requires an object of outer class?
A) Static Nested Class
B) Inner Class
C) Final Class
D) Package Class
Answer: B) Inner Class
Explanation:An inner class is a non-static nested class and needs an object of the outer class.
Q22. Which keyword is used to prevent variable value change?
A) static
B) private
C) final
D) public
Answer: C) final
Explanation:The final keyword makes the variable constant; its value cannot be changed.
Q23. Which keyword is used to allocate memory to an object?
A) class
B) new
C) create
D) malloc
Answer: B) new
Explanation:The new keyword creates an object and allocates memory in Java.
Q24. Which method can return an object in Java?
A) Constructor
B) Normal Method
C) finalize()
D) Static Block
Answer: B) Normal Method
Explanation:A normal method can return an object of a class.
Q25. Which of the following supports constructor overloading?
A) Same constructor name with different parameters
B) Same constructor with same parameters
C) Different constructor names
D) Same constructor without class
Answer: A) Same constructor name with different parameters
Explanation:Constructor overloading means same constructor name (same as class name) with different parameter lists.
Q26. Which access modifier is available only within the package?
A) public
B) private
C) default
D) protected
Answer: C) default
Explanation:Default access means accessible only inside the same package.
Q27. Which keyword is used to refer current class instance variable?
A) super
B) this
C) static
D) final
Answer: B) this
Explanation:The this keyword helps distinguish between local and instance variables.
Example:
this.name = name;
Q28. Which wrapper class is used for int?
A) Float
B) Integer
C) Character
D) Double
Answer: B) Integer
Explanation:The wrapper class for primitive data type int is Integer.
Q29. finalize() method belongs to which class?
A) String
B) Object
C) Scanner
D) System
Answer: B) Object
Explanation:The finalize() method is defined in the Object class.
Q30. Which class is the parent of all classes in Java?
A) Main
B) String
C) Object
D) System
Answer: C) Object
Explanation:Every class in Java directly or indirectly inherits from the Object class.
Google AdSense Ad Placement Here 📢