Explore topic-wise MCQs in Java.

This section includes 12 Mcqs, each offering curated multiple-choice questions to sharpen your Java knowledge and support exam preparation. Choose a topic below to get started.

1.

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» B. Runtime error
2.

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» E.
3.

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» C. Protected constructor can be used outside package
4.

What is true about Class.getInstance()?

A. Class.getInstance calls the constructor
B. Class.getInstance is same as new operator
C. Class.getInstance needs to have matching constructor
D. Class.getInstance creates object if class does not have any constructor
Answer» E.
5.

What is false about constructor?

A. Constructors cannot be synchronized in Java
B. Java does not provide default copy constructor
C. Constructor can have a return type
D. “this” and “super” can be used in a constructor
Answer» D. “this” and “super” can be used in a constructor
6.

What would be the behaviour if this() and super() used in a method?

A. Runtime error
B. Throws exception
C. compile time error
D. Runs successfully
Answer» D. Runs successfully
7.

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» B. Private constructor ensures multiple instances of a class exist at any point of time
8.

Which of the following are implemented as classes containing constructor, destructor, copy constructor and overloaded assignment operator?

A. float data type
B. int data type
C. all the above
D. double data type
Answer» D. double data type
9.

Which is used to make a copy of one class object from another class object of the same class type.

A. copy constructor
B. constructor
C. default constructor
D. destructor
Answer» B. constructor
10.

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» B. Runtime error
11.

What is not the use of “this” keyword in Java?$

A. Passing itself to another method
B. Calling another constructor in constructor chaining
C. Referring to the instance variable when local variable has the same name
D. Passing itself to method of the same class
Answer» E.
12.

Abstract class cannot have a constructor.

A. True
B. False
Answer» C.