Java-Programming Solved MCQs (Set-2)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Java Programming MCQs [set-2]

26. Which of the following is a valid declaration of an object of class Box?

A. Box obj = new Box();

B. Box obj = new Box;

C. obj = new Box();

D. new Box obj;


o m
.c
Answer: A
te
a
q M
27. Name the keyword that makes a variable belong to a class, rather than
being defined for each instance of the class.
c
A. static M
B. final

C. abstract

D. public

Answer: A

28. Variables declared with in a class are called

A. Identifier

B. local variable

C. instance variable

D. global variable

Answer: C

29. Variables declared within a method or block are called

A. Static variable

Download more at McqMate.com


B. local variable

C. instance variable

D. global variable

Answer: B

30. Defining methods with same name and different no. of parameters are
called

A. Method overriding

o m
B. method overloading
.c
C. Dynamic method dispatch
te
a
D. none of the above

q M
Answer: B
c
M
31. _________ is used to initialize objects.

A. Methods

B. arguments

C. constructors

D. new keyword

Answer: C

32. What is the return type of Constructors?

A. int

B. float

C. void

D. None of the mentioned

Answer: D

Download more at McqMate.com


33. Which of the following is a method having same name as that of its
class?

A. finalize

B. delete

C. class

D. constructor

Answer: D

o m
.c
34. Which operator is used by Java run time implementations to free the
te
memory of an object when it is no longer needed?
a
A. delete
q M
B. free c
C. new M
D. None of the mentione

Answer: D

35. Which of these access specifiers must be used for main() method?

A. private

B. public

C. protected

D. None of the mentioned

Answer: B

36. Which of these is used to access member of class before object of that
class is created?

A. public

B. private

C. static

Download more at McqMate.com


D. protected

Answer: C

37. The keyword used to create an object

A. class

B. this

C. new

D. malloc
o m
Answer: C
.c
t e
a object
38. The keyword used to refer the current

q M
A. class
c
B. this M
C. new

D. malloc

Answer: B

39. The method which is automatically invoked during garbage collection.

A. destructor

B. terminate()

C. finalize()

D. destroy()

Answer: C

40. Which class cannot have a subclass in java

A. abstract class

B. parent class

Download more at McqMate.com


C. final class

D. None of above

Answer: C

41. Which is the keyword used to inherit a class to another?

A. Inherits

B. extends

C. implements
o m
D. import
.c
te
Answer: B
a
q M
42. The use of final keyword with method definition
c
A. Supports method overriding M
B. implements dynamic method dispatch

C. Prevents method overriding

D. none of these

Answer: C

43. Identify the type of inheritance when two or more subclasses inherit
the properties of a super class.

A. Multiple inheritance

B. Single inheritance

C. Multilevel inheritance

D. Hierarchical inheritance

Answer: D

44. The keyword used inside a class to refer to its immediate super class
is

Download more at McqMate.com


A. super

B. parent

C. base

D. none of these

Answer: A

45. Which of the following is true in the case of abstract class

A. Abstract constructors cannot be created.


o m
B. Abstract classes can not be inherited.
.c
te
a
C. An abstract class contains only abstract methods.

D. All of the above.


q M
Answer: A
c
M
46. Which of these keywords are used to define an abstract class?

A. abst

B. abstract

C. Abstract

D. abstract class

Answer: B

47. If a class inheriting an abstract class does not define all of its function
then it will be known as?

A. abstract

B. A simple class

C. Static class

D. None of the mentioned

Answer: A

Download more at McqMate.com


48. Which of these is not a correct statement?

A. Every class containing abstract method must be declared abstract.

B. Abstract class defines only the structure of the class not its implementation.

C. Abstract class can be initiated by new operator.

D. Abstract class can be inherited.

Answer: C

o m
49. Which method defined in Integer class can be used to convert a whole
number in string type to primitive int type. .c
te
A. valueOf() a
B. intValue()
q M
c
C. parseInt()

D. getInteger()
M
Answer: C

50. The method sqrt() is defined in the class

A. System

B. Root

C. Math

D. Arithmetic

Answer: C

Download more at McqMate.com


Take Quick Mock/Practice test on this topic HERE

For Discussion / Reporting / Correction of any MCQ please visit discussion page by clicking on
'answer' of respective MCQ.

McqMate is also available on

PlayStore

o m
.c
te
a
q M
c
M

Download more at McqMate.com

You might also like