Unit-04 Java MCQ - 16944662 - 2023 - 03 - 24 - 19 - 51
Unit-04 Java MCQ - 16944662 - 2023 - 03 - 24 - 19 - 51
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
2 CTH EDUCATION
6. A variable, which gets memory at runtime when an object is created is called?
a) static variable
b) local variable
c) instance variable
d) all of the above
Answer: C
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
3 CTH EDUCATION
11. The keyword __________ is required to declare a class.
a) Public
b) Private
c) Class
d) All of the above
Answer: C
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
4 CTH EDUCATION
16. A Java constructor is like a method without ___.
a) statements
b) return type
c) argument list
d) None
Answer: B
17. The name of a constructor and the name of a class are ___.
a) Same
b) Different
c) -
d) -
Answer: A
20. Memory is allocated to an object once the execution of ___ is over in Java language.
a) main method
b) constructor
c) destructor
d) None
Answer: B
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
5 CTH EDUCATION
21. In Java, a constructor with no parameters or no arguments is called ___ constructor.
a) Default constructor
b) User-defined constructor
c) -
d) -
Answer: A
22. In Java, a constructor with one or more arguments or parameters is called a ___
constructor.
a) Default constructor
b) User-defined constructor or Non-default constructor
c) -
d) -
Answer: B
24. Overloading of constructors in Java means adding more than ___ constructors with the
different argument list.
a) 1
b) 2
c) 3
d) 8
Answer: A
25. A constructor can call another overloaded constructor using the ___ keyword in Java.
a) super
b) local
c) con
d) this
Answer: D
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
6 CTH EDUCATION
26. In Java, you can pass __ variables from one constructor to another overloaded
constructor.
a) local variables
b) static variables
c) non-static variables
d) local and static variables
Answer: D
30. 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: d
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
7 CTH EDUCATION
31. 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: a
32. What is the process of defining two or more methods within same class that have same
name but different parameters declaration?
a) method overloading
b) method overriding
c) method hiding
d) none of the mentioned
Answer: a
34. What is the process of defining a method in terms of itself, that is a method that calls
itself?
a) Polymorphism
b) Abstraction
c) Encapsulation
d) Recursion
Answer: d
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
8 CTH EDUCATION
36. Which of the following is a garbage collection technique?
a) Cleanup model
b) Mark and sweep model
c) Space management model
d) Sweep model
Answer: b
37. What happens to the thread when garbage collection kicks off?
a) The thread continues its operation
b) Garbage collection cannot happen until the thread is running
c) The thread is paused while garbage collection runs
d) The thread and garbage collection do not interfere with each other
Answer: c
39. What is the return type of a method that does not return any value?
a) int
b) float
c) void
d) double
Answer: c
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)