Java MCQ Question Bank-2022
1. The data, or variables, defined within a class are called variables.
A. object B. class. C. instance. D. schema.
2. To prevent any method from overriding, we declare the method as,
A. static B. const C. final D. abstract
3. What would happen if "String[]args" is not included as argument in the main method?
A. No error.B. Compilation error.C. Program won't run.D. Program exit.
4. Which of the following are primitive types?
A. Byte. B. String. C. Integer. D. Float.
5. Which of the function is used to convert String to Number in java program?
A. toNumber(). B. conString(). C. valueOf(). D. toString().
6. Which of the following is not a wrapper class?
A. String. B. Integer. C. Boolean. D. Character.
7. Which of the following components generate action events?
A. Buttons. B. Labels. C. Check boxes. D. Windows.
8. Which of the following components generate action events?
A. Buttons. B. Labels. C. Check boxes. D. Windows.
9. Which of the following are passed as an argument to the paint() method?
A. A Canvas object. B. A Graphics object. C. An Image object. D. A Paint object.
10. Which of the following methods are invoked by the AWT to support paint and repaint
operations?
A. paint( ). B. repaint( ). C. draw( ). D. redraw( ).
11. is a feature that allows one interface to be used for a general class of actions.
A. Class. B. Inheritance. C. Polymorphism. D. Interface.
12. The term _ refers to a class's direct ancestor or to any of its ascendant classes.
A. sub class B. super class. C. class hierarchy. D. class instance.
13. finalize( ) is only called just prior to .
A. initialization. B. runtime C. garbage collection. D. destruction.
14. The methods wait() and notify() are defined in .
A. java.lang.String. B. java.lang.Object. C. java.lang.Runnable. D. java.lang.Thread.
15. Exception that is identified during compile time is called exception.
A. user defined. B. checked. C. undefined. D. defined.
16. Methods having same name and different type signature are called methods.
A. overwrite. B. overread. C. overreading. D. overloading.
17. Methods having same name, same type signature are called methods.
A. overriding. B. overloading. C. overwriting. D. overreading.
18. Methods declared as static .
A. can call all other methods. B. must only access static data.
C. cannot call any methods. D. can refer to this or super.
19.Can a final variable be added? final a = 10; final b = 20; System.out.println(a+b);
A. error. B. 30. C. 10 20. D. 0.
20. Java is designed for environment of the internet.
A. development. B. deducting. C. distributed.D. web design.
[KK ]-CMPICA Page 1
21. A class may not have any abstract method.
A. abstract. B. static. C. final. D. public.
[KK ]-CMPICA Page 2
22. The term byte code refers to .
A. the type of code generated by a Java compiler.
B. the type of code generated by a Java Virtual Machine.
C. another name for a Java source file.
D. the code written within the instance methods of a class.
23. Static keyword can be used on .
A. Class only B. Methods and Classes C. Variables only D. Methods and Variables
24. Final keyword can be used on .
A. Classes B. Methods C. Variables D. All the above
25. Which of these keywords can be used to prevent Method overriding?
A. static B. constant C. protected D. final
26. Which of these is supported by method overriding in Java?
A. Abstraction B. Encapsulation C. Polymorphism D. None of the mentioned
27. Which method can be defined only once in a program?
A. main method B. finalize method C. static method D. private method
28. Container is a for component class
A. derived B. base C. interface D. package
29. Which method is used to change the name of a thread?
A. public String getName()B. public void setName(String name)
C. public void getName() D. public String setName(String name)
30. is the process of hiding all the internal details of an object from the outside
world.
A. Idea. B. Knowledge. C. Capsulation. D. Encapsulation.
31. An is a location in memory having a value and referenced by an identifier.
A. object. B. data. C. information. D. directory.
32. is one of the java features that enables java program to run anywhere
anytime.
A. Objected-Oriented. B. Multithreaded.
C. Platform-Independent.D. Dynamic & Extensible.
33. Java does not support .
A. operator overloading. B. global variable. C. multiple inheritance. D. all the above
34. Which method executes only once
A. start() method B. init() method C. stop() method D. destroy() method
35. defines only abstract methods and final fields.
A. Interface. B. Final class. C. Abstract class. D. Class.
36. Which of these keywords is used to generate an exception explicitly?
A. try B. finally C. throw D. catch
37. Which of these method can be used to make the main thread to be executed last among all the
threads?
A. stop() B. sleep() C. join() D. call()
38. What is the default value of priority variable MIN_PRIORITY AND MAX_PRIORITY?
A. 0 & 256 B. 0 & 1 C. 1 & 10 D. 1 & 256
39. Which of these method waits for the thread to terminate?
A. sleep() B. isAlive() C. join()D. stop()
40. Which of these clause will be executed even if no exceptions are found?
A. throwsB. finallyC. throwD. catch
[KK ]-CMPICA Page 3
41. Why we use array as a parameter of main method
A. it is syntax B. Can store multiple values
C. it is syntax and Can store multiple values D. None
42. You want subclasses in any package to have access to members of a superclass. Which is the
most restrictive access that accomplishes this objective?
A. public B.private
C.protected D.transient
43. What is the most restrictive access modifier that will allow members of one class to have
access to members of another class in the same package?
A. public B.protected
C.synchronized D.default access
44. Which of the following will directly stop the execution of a Thread?
A.wait() B.notify()
C.notifyall() D.exits synchronized code
45. Which method must be defined by a class implementing the java.lang.Runnable interface?
A.void run() B.public void run()
C.public void start() D.void run(int priority)
46. Which class or interface defines the wait(), notify(),and notifyAll() methods?
A.Object B.Thread
C.Runnable D.Class
47. Which of these class is superclass of every class in Java?
A.String class B.Object class
C.Abstract class D.ArrayList class
48. Which of these class is used to create an object whose character sequence is mutable?
A.String() B.StringBuffer()
C.Both of the mentioned D.None of the mentioned
49. Which of these is a super class of wrappers Double & Integer?
A.Long B.Digits
C.Float D.Number
50. Which of these is a super class of all exceptional type classes?
A.String B.RuntimeExceptions
C.Throwable D.Cachable
51. Which of these class is related to all the exceptions that cannot be caught?
A.Error B.Exception
C.RmuntimeExecption D.All of the mentioned
52. Which of these handles the exception when no catch is used?
A.Default handler B.finally
C.throw handler D.Java run time system
[KK ]-CMPICA Page 4
53. Which of these keywords is used to generate an exception explicitly?
A.try B.finally
C.throw D.catch
54. Which of these method can be used to make the main thread to be executed last among all the
threads?
A. stop() B. sleep()
C.join() D.call()
55. Program which executes applet is known as
A. applet engine B. virtual machine
C. JVM D. None of above
56. Converting a primitive type data into its corresponding wrapper class object instance is called
A. boxing B.wrapping
C.instantiation D.autoboxing
57. Which concept of Java is a way of converting real world objects in terms of class?
A.Polymorphism B. Encapsulation
C.Abstraction D. Inheritance
58. Which component is used to compile, debug and execute java program?
A. JVM b. JDK
c. JIT d. JRE
59. Which component is responsible for converting bytecode into machine specific code?
A. JVM B. JDK
C. JIT D. JRE
60. Which component is responsible to run java program?
A. JVM B. JDK
C. JIT D. JRE
61. Which component is responsible to optimize bytecode to machine code?
A. JVM B. JDK
C. JIT D. JRE
62. Which of the below is invalid identifier with the main method?
A. public B.static
C.private D. final
63. What is the stored in the object b in following lines of code?
Box b;
A. Memory address of allocated memory of object B. NULL
C. Any arbitrary pointer D. Garbage
64. Which among the following can be viewed as combination of abstraction of data and code.
A. Class B.Object
C.Inheritance D. Interfaces
65. Which of these class is used to create an object whose character sequence is mutable?
A. String() B. StringBuffer()
C. Both a & b. D. None of these
[KK ]-CMPICA Page 5
66. Which of these can be used to fully abstract a class from its implementation?
A. Objects B. Packages
C. Interfaces D. None of these
67. Which of these is a super class of all exceptional type classes?
A. String B. RuntimeExceptions
C. Throwable D.Exception
68. Which of these method waits for the thread to terminate?
A. sleep() B. isAlive()
C. join() D. stop()
69. What is the process of defining more than one method in a class differentiated by method
signature?
A. Method overriding B. Method overloading
C. Method doubling D. None of the mentioned
70. Which of these is an incorrect statement?
A. String objects are immutable, they cannot be changed
B. String object can point to some other reference of String variable
C. StringBuffer class is used to store string in a buffer for later use
D. None of the mentioned
[KK ]-CMPICA Page 6