Java OOP – MCQs on Key Topics
1. What happens if an exception is not handled in Java?
• A. The program continues normally
• B. The program terminates abruptly
• C. The compiler throws an error
• D. The garbage collector is called
Correct Answer: B
2. Which keyword is used to manually throw an exception?
• A. catch
• B. throws
• C. finally
• D. throw
Correct Answer: D
3. What is the superclass of all exception-type classes in Java?
• A. Exception
• B. Throwable
• C. Object
• D. RuntimeException
Correct Answer: B
4. What method is used to begin execution of a thread?
• A. execute()
• B. run()
• C. begin()
• D. start()
Correct Answer: D
5. Which of the following can create a thread?
• A. Extending Thread class
• B. Implementing Runnable interface
• C. Both A and B
• D. Only ThreadPoolExecutor
Correct Answer: C
6. What is the purpose of the super keyword in Java?
• A. To create a new class
• B. To refer to the immediate parent class
• C. To inherit from another interface
• D. To call a child class method
Correct Answer: B
7. Which type of inheritance is not supported directly by Java classes?
• A. Single
• B. Multilevel
• C. Hierarchical
• D. Multiple
Correct Answer: D
8. What is method overriding in Java?
• A. Declaring two methods with same name and different return type
• B. Redefining a method of the parent class in the child class
• C. Using the super keyword
• D. Declaring a method final
Correct Answer: B
9. Which keyword is used to create an interface in Java?
• A. interface
• B. abstract
• C. class
• D. implements
Correct Answer: A
10. Which of the following is TRUE for interfaces?
• A. Methods can have bodies
• B. Variables can be non-final
• C. Supports multiple inheritance
• D. Cannot be extended
Correct Answer: C
11. What does AWT stand for?
• A. Abstract Web Toolkit
• B. Abstract Window Toolkit
• C. Advanced Window Toolkit
• D. Applet Window Tool
Correct Answer: B
12. Which layout manager arranges components in a grid-like structure?
• A. FlowLayout
• B. GridLayout
• C. BorderLayout
• D. BoxLayout
Correct Answer: B
13. Which class represents a window in Java AWT?
• A. Applet
• B. Panel
• C. Frame
• D. Component
Correct Answer: C
14. Which event occurs when a button is clicked?
• A. WindowEvent
• B. MouseEvent
• C. KeyEvent
• D. ActionEvent
Correct Answer: D
15. What Swing component is used to create a clickable button?
• A. JTextField
• B. JLabel
• C. JButton
• D. JCheckBox
Correct Answer: C
16. What type of exception is NullPointerException?
• A. Checked
• B. Unchecked
• C. Compile-time
• D. User-defined
Correct Answer: B
17. Which block is always executed whether an exception occurs or not?
• A. try
• B. catch
• C. throw
• D. finally
Correct Answer: D
18. Which of the following is a checked exception?
• A. ArithmeticException
• B. ArrayIndexOutOfBoundsException
• C. FileNotFoundException
• D. NullPointerException
Correct Answer: C
19. What is the purpose of the throws keyword in Java?
• A. To catch exceptions
• B. To declare possible exceptions
• C. To handle exceptions
• D. To throw runtime errors
Correct Answer: B
20. Which method causes the currently executing thread to pause and allow others to
execute?
• A. wait()
• B. sleep()
• C. yield()
• D. stop()
Correct Answer: C
21. What is the default priority of a Java thread?
• A. 1
• B. 10
• C. 0
• D. 5
Correct Answer: D
22. Which method is used to wait for a thread to die?
• A. wait()
• B. stop()
• C. join()
• D. terminate()
Correct Answer: C
23. Which method is used to interrupt a thread?
• A. stop()
• B. break()
• C. interrupt()
• D. yield()
Correct Answer: C
24. What principle binds data and methods into a single unit?
• A. Inheritance
• B. Abstraction
• C. Polymorphism
• D. Encapsulation
Correct Answer: D
25. What is the main use of abstraction in Java?
• A. For method overloading
• B. To reduce execution time
• C. To hide implementation details
• D. To extend a class
Correct Answer: C
26. Which type of polymorphism is method overriding an example of?
A. Compile-time
B. Runtime
C. Static
D. Operator
Answer: B
27. Which keyword is used to include built-in packages?
A. use
B. include
C. import
D. extends
Answer: C
28. What is the default access modifier in Java if none is specified?
A. private
B. public
C. protected
D. package-private (default)
Answer: D
29. Which package is automatically imported in every Java program?
A. java.util
B. java.io
C. java.lang
D. java.awt
Answer: C
30. Which of the following statements is TRUE about abstract classes?
A. They can be instantiated
B. They must contain only abstract methods
C. They can contain both abstract and non-abstract methods
D. They must implement an interface
Answer: C
31. Which method is invoked by the JVM to execute a thread?
A. run()
B. execute()
C. start()
D. main()
Answer: C
32. Which keyword is used to inherit a class in Java?
A. implements
B. inherits
C. extends
D. instanceOf
Answer: C
33. Which of the following is not a valid Java access modifier?
A. public
B. private
C. internal
D. protected
Answer: C
34. Which concept allows multiple methods in the same class with the same name but
different parameters?
A. Inheritance
B. Polymorphism
C. Method Overriding
D. Method Overloading
Answer: D
35. Which of these cannot be declared as abstract?
A. Class
B. Interface
C. Method
D. Constructor
Answer: D
36. Which of the following statements is TRUE about constructors in Java?
A. They have a return type
B. They can be abstract
C. They must have the same name as the class
D. They can be called like regular methods
Answer: C
37. Which type of polymorphism does method overloading represent?
A. Compile-time
B. Runtime
C. Static binding
D. Both A and C
Answer: D
38. What does the instanceof operator do?
A. Checks object memory size
B. Checks if an object belongs to a specific class
C. Creates a new instance
D. Checks inheritance
Answer: B
39. Which statement is used to define a package in Java?
A. import java.util.*;
B. package myPackage;
C. include package java.util;
D. namespace myPackage;
Answer: B
40. Which layout manager places components in a single row or column?
A. GridLayout
B. BorderLayout
C. FlowLayout
D. BoxLayout
Answer: D
41. What is the default package for every Java program?
A. java.io
B. java.util
C. java.lang
D. java.awt
Answer: C
42. Which interface should be implemented for a class to become a thread in Java?
A. Serializable
B. Runnable
C. Clonable
D. Comparable
Answer: B
43. Which method is used to pause a thread for a specified time?
A. wait()
B. yield()
C. sleep()
D. pause()
Answer: C
44. Which method notifies a waiting thread in Java?
A. interrupt()
B. notify()
C. resume()
D. wakeup()
Answer: B
45. Which keyword is used to prevent method overriding?
A. static
B. private
C. final
D. abstract
Answer: C
46. Which class is the parent of all Java classes?
A. Object
B. System
C. Class
D. Main
Answer: A
47. How is an abstract class different from an interface in Java?
A. Abstract class can’t have methods
B. Interface supports constructors
C. Abstract class can have implemented methods
D. Interface supports multiple inheritance, abstract class doesn't
Answer: C
48. Which of the following is not a Java primitive type?
A. byte
B. string
C. float
D. char
Answer: B
49. Which method is used to compare two strings for equality in Java?
A. ==
B. equals()
C. compareTo()
D. isEqual()
Answer: B
50. What is the output of System.out.println(10 + "20"); in Java?
A. 30
B. 1020
C. Error
D. 10 20
Answer: B