Object Oriented Programming - I (3140705) MCQs

MCQs of Objects and Classes

Showing 11 to 20 out of 36 Questions
11.
Which of the following is a method having same name as that of its class?
(a) finalize
(b) delete
(c) class
(d) constructor
Answer:

Option (d)

12.
Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed?
(a) delete
(b) free
(c) new
(d) none of the mentioned
Answer:

Option (d)

13.
Which function is used to perform some action when the object is to be destroyed?
(a) finalize()
(b) delete()
(c) main()
(d) none of the mentioned
Answer:

Option (a)

14.
Which of the following statements are incorrect?
(a) default constructor is called at the time of object declaration
(b) constructor can be parameterized
(c) finalize() method is called when a object goes out of scope and is no longer needed
(d) finalize() method must be declared protected
Answer:

Option (c)

15.
What is true about private constructor?
(a) Private constructor ensures only one instance of a class exist at any point of time
(b) Private constructor ensures multiple instances of a class exist at any point of time
(c) Private constructor eases the instantiation of a class
(d) Private constructor allows creating objects in other classes
Answer:

Option (a)

16.
What is true about constructor?
(a) It can contain return type
(b) It can take any number of parameters
(c) It can have any non access modifiers
(d) Constructor cannot throw an exception
Answer:

Option (b)

17.
Abstract class cannot have a constructor.
(a) TRUE
(b) FALSE
Answer:

Option (b)

18.
What is true about protected constructor?
(a) Protected constructor can be called directly
(b) Protected constructor can only be called using super()
(c) Protected constructor can be used outside package
(d) Protected constructor can be instantiated even if child is in a different package
Answer:

Option (b)

19.
What would be the behaviour if one parameterized constructor is explicitly defined?
(a) Compilation error
(b) Compilation succeeds
(c) Runtime error
(d) Compilation succeeds but at the time of creating object using default constructor, it throws compilation error
Answer:

Option (d)

20.
What would be behaviour if the constructor has a return type?
(a) Compilation error
(b) Runtime error
(c) Compilation and runs successfully
(d) Only String return type is allowed
Answer:

Option (a)

Showing 11 to 20 out of 36 Questions