Java Questions Bank
Short Answer Type:
1. What is the difference between compiler and Interpreter?
2. What are the features of object oriented programming language?
3. What is bytecode?
4. What is JVM?
5. Write different types of operators in java?
6. What is java token and different data types?
7. What are different types of variables in java?
8. What are different control structures or statements in Java?
9. What are jumping statements in Java?
10. Write syntax for single and multi dimensional array?
11. What is command line argument in Java. Give example?
12. Write the usage of Scannner class and BufferedReader Class using syntax and example?
13. Write difference between class and object?
14. What is constructor. Give example?
15. Write the use of static and this keywords using example?
16. What is array of objects?
17. What are access modifiers. Give example?
18. What is inheritance and types of inheritance?
19. What is polymorphism and differentiate static and dynamic polymorphism?
20. Differentiate method overloading and constructor overloading?
21. What is the purpose of ‘this’ keyword? Give an example
22. Explain the concept of inheritance with a real-life example.
23. How is encapsulation different from data abstractionWhat is the output of the following
Java code. int x = 10; if (x > 5) { if (x > 8) { System.out.println("x is greater than 8"); } else {
System.out.println("x is greater than 5 but less than or equal to 8"); } } else {
System.out.println("x is less than or equal to 5"); }
24. Create a Java program to manage student attendance. Define a class Student with
attributes for student name and attendance count. Include methods to mark attendance
and display attendance details. Demonstrate the functionality in the main method
25. Explain the following with an example: (a) Local variables in Java (b) Static variables in Java
(c) Class variables in Java (d) Static method in Java
26. Illustrate the use of variable-length arguments and command-line arguments in Java with
examples.
27. Explain the steps needed to connect to a database using JDBC.
28. Give the differences between checked and unchecked exceptions in Java.
29. Write a Java program to find the second largest element in an integer array.
30. Describe the concept of recursion in Java and its practical applications.
31. Create a Shape base class with a draw () method. Derive two Circle and Rectangle classes
that override the draw () method
32. Explain the difference between run time and compile time polymorphism using examples
33. Write a Program to accept N integer numbers from the command line. Raise and handle
exceptions when a number is greater than 1000 and less than 2000
34. Write a Program to demonstrate type-casting
35. What is the output of the following Java program? class Automobile { private String drive() {
return "Driving vehicle"; } } class Car extends Automobile { protected String drive() { return
"Driving car"; } } public class ElectricCar extends Car { @Override public final String drive() {
return "Driving an electric car"; } public static void main(String[] wheels) { final Car car =
new ElectricCar(); System.out.print(car.drive()); } }
36. What is a method overriding and how it is related to dynamic method dispatching?
37. Explain different string classes in java?
38. What is wrapper class?
39. What is the difference between Auto Boxing and Un-Boxing?
40. What is data abstraction and give example of an abstract class?
41. What is a package and java API package?
42. What is interface. Why is needed?
43. What is user defined package?
44. Write a syntax to access the package in java?
45. What is Exception?
46. What is the difference between exception and error. Give examples.
47. What are different types of exceptions?
48. What is runtime stack mechanism in Exception?
49. Explain hierarchy of exception class?
50. What is the difference between multithreading and multiprocessing?
51. What is a thread in java?
52. What is daemon thread?
53. What is thread synchronization?
54. What is inter thread communication?
55. What is deadlock? Why it arises?
56. What is an inner class?
57. What is the use of java.io and java.util (collection framework) packages?
58. What is AWT and GUI?
59. Write description of component and container? Why they are used?
60. What is an event?
61. What is adapter classes?
62. What is Java Swing? Why it is used?
63. What is the difference between AWT and Swing?
64. What is Java FX and use of Scene Builder?
Long Answer Type Questions
65. Write the advantages and all features of object oriented programming? Explain it?
66. Draw complete architecture of JVM. Describe the use of each component in JVM?
67. Describe different data types and operators in java with all examples?
68. Write a program to show the use of Scanner class and Buffered Reader Class?
69. Write a program to show the use of Array of Objects?
70. Describe the use of Access Modifiers in Java? Draw a table showing the scope of
accessibility?
71. Write programs to show the use of access modifiers?
72. Write programs to show the use of Inheritence single, multilevel and hierarchical?
73. Write a program to show the use of constructor call in Inheritence?
74. Write a program to show the use of super keywork in Inheritence?
75. Explain and describe with a program the implementation of multiple inheritance using
Interfaces in Java.
76. Write a program to show the use of method overloading and method
overriding or dynamic method dispatching?
77. Write a program to show the use of constructor overloading?
78. Write a program to show auto boxing and unboxing?
79. What are different exception handling mechanisms? Explain each with a program?
80. Write a program to create a user defined exception class?
81. Describe the complete lifecycle of a thread and explain the use of sleep(), yield(), join() with
a program?
82. Explain thread priority with a program?
83. Write short notes on:
a. Inner class
b. Member Inner class
c. Static Inner class
d. Local Inner class
e. Anonymous Inner class
84. Write short notes on:
f. List
g. Set
h. Map
i. Setter Interfaces
j. List Interfaces