Core Java Interview Questions

S.No Question
1. What is Java? Explain its key features.
2. How is Java platform-independent? Explain the role of the Java Virtual Machine (JVM).
3. What is the JVM? Explain its role in executing Java programs.
4. What is the JDK? What components does it consist of?
5. What is the JRE? What is its purpose?
6. What are JavaDocs? How do you generate and use them?
7. Explain the structure of a Java program. What are the main components?
8. How do you compile and run a simple "HelloWorld" program in Java?
9. What are the different data types in Java? Explain their sizes and ranges.
10. How do you declare and use variables in Java?
11. What are constants in Java? How do you declare and use them?
12. Explain arithmetic operators in Java and provide examples.
13. What are relational operators in Java? How do you use them for comparison?
14. What are logical operators in Java? How do you use them for logical operations?
15. How do you use the increment and decrement operators in Java?
16. Explain the assignment operators in Java and provide examples.
17. What are bitwise operators in Java? How do you use them for bitwise operations?
18. Explain the operator precedence and evaluation order in Java.
19. Provide examples to illustrate the precedence and order of evaluation.
20. What is type conversion in Java? Explain implicit and explicit type conversions.
21. How do you perform type casting in Java?
22. Explain the boolean data type in Java. What are its possible values?
23. How do you declare and use variables of type char in Java?
24. How do you read user input in Java? Explain the usage of the Scanner class.
25. How do you use the if-else statement in Java? Provide examples.
26. What is the conditional operator in Java? How do you use it?
27. What is the switch statement in Java? How do you use it? Provide examples.
28. How do you use the for loop in Java? Explain its syntax and usage.
29. What are the while and do-while loops in Java? How do you use them?
30. Explain the usage of the break and continue statements in Java loops.
31. What is an array in Java? How do you declare and initialize arrays?
32. How do you find the length of an array in Java?
33. Explain one-dimensional arrays in Java. How do you access and modify array elements?
34. What are multi-dimensional arrays in Java? How do you declare and use them?
35. What is a jagged array in Java? Provide an example and explain its usage.
36. What are objects and classes in Java? Explain their relationship.
37. How do you create objects and define classes in Java?
38. What is encapsulation in Java? How does it achieve data hiding?
39. Explain the concept of inheritance in Java. How do you implement it?
40. What is polymorphism in Java? Explain static and dynamic polymorphism.
41. How do you declare a class in Java? Explain the steps involved in compilation, loading, and execution of a Java program.
42. How do object references work in Java? Explain object allocation and the role of the heap.
43. What are instance variables and class variables in Java? How are they different?
44. Explain instance methods and class methods in Java. How do you define and use them?
45. What is a constructor in Java? Explain default and parameterized constructors.
46. What is the "this" keyword in Java? How is it used?
47. What is a static block in Java? Explain the purpose of default initialization blocks.
48. How does polymorphism work in Java? Explain method overloading.
49. How do you define and use methods that take objects as arguments in Java?
50. What is the "has-a" relationship in Java? Explain its significance in object-oriented programming.
51. How do you create an array of objects in Java? How do you iterate over it using the for-each loop?
52. How do you define and use methods that take arrays as arguments in Java?
53. What are variable argument methods in Java? How do you declare and use them?
54. What are inner classes in Java? Explain static, member, and local inner classes.
55. Explain the concept of inheritance in Java. How do you declare and use inheritance using the "extends" keyword?
56. What is method overriding in Java? How do you use the "super" keyword in method overriding?
57. Can constructors be overridden in Java? Explain the role of the "super" keyword in constructor overriding.
58. How does multilevel inheritance work in Java? Explain constructor chaining in inheritance.
59. What are references of super types in Java? How does dynamic polymorphism work with these references?
60. What is the "instanceof" operator in Java? How is the "final" keyword used?
61. What are abstract classes in Java? How do you define and use them?
62. What is an interface in Java? How do you define and implement interfaces?
63. What are anonymous inner classes in Java? How do you use them?
64. How do you organize classes in packages in Java? Explain the purpose of packages.
65. What are the different access protection levels in Java? Explain private access and the use of getters and setters.
66. Explain protected and public access modifiers in Java.
67. How do you create subpackages in Java? Explain their purpose.
68. How do you compile Java packages? How do you create and run a .jar file?
69. Explain the java.lang package in Java. What are the methods available in the String class?
70. What is the Object class in Java? Explain the methods provided by the Object class, such as toString, equals, and hashCode.
71. What are wrapper classes in Java? Explain the purpose of Integer, Float, Boolean, and other wrapper classes.
72. How do you pass command-line arguments to a Java program? Explain their usage.
73. What is an exception in Java? Explain the role of the JVM in exception handling. What are the types of exceptions in Java?
74. How do you handle exceptions in Java using try, catch, and finally blocks? Explain common exceptions like NullPointerException, ArrayIndexOutOfBoundsException, and FileNotFoundException.
75. What is the difference between throw and throws in Java exception handling?
76. How do you create custom exceptions in Java? Explain checked and unchecked exceptions.
77. How do you handle multiple exceptions in Java? Explain the usage of multiple catch blocks.
78. What is multithreading in Java? Explain the concepts of the operating system, process, application, and thread.
79. How do you create and execute threads using the Thread class in Java?
80. How do you create and execute threads using the Runnable interface in Java?
81. Explain the methods sleep, join, and interrupt in Java thread handling.
82. What is thread synchronization in Java? How do you achieve thread synchronization?
83. How do you set thread names and priorities in Java? Explain the different thread states.
84. What is the concept of streams in Java IO? Explain the types of streams.
85. How do you read text and binary input streams in Java? Explain the usage of standard input.
86. How do you write text and binary output streams in Java? Explain the usage of standard output.
87. How do you read and write text files in Java?
88. How do you read and write binary files in Java?
89. What are DataInputStream and DataOutputStream in Java IO? How do you use them?
90. How do you read and write objects using ObjectInputStream and ObjectOutputStream in Java?
91. Explain serialization in Java. How do you serialize and deserialize objects? Discuss other streams in Java IO.
92. What are generics in Java? Explain their purpose in type safety and code reusability.
93. How do you define and use generic types in Java?
94. How do you define and use generic methods in Java?
95. What are bounded type parameters in Java generics? Explain their usage.
96. How does inheritance work with generic types in Java? Explain subtyping.
97. What are wildcards in Java generics? How do you use them?
98. What is the concept of collections in Java? Explain the class hierarchy of collections.
99. Explain the List interface and its subclasses in Java collections.
100. How do you iterate over collections in Java? Explain the usage of the for-each loop and Iterator.
101. What is the Queue interface in Java collections? Explain its subclasses and their usage.
102. Explain the Set interface and its subclasses in Java collections.
103. What is the Map interface in Java collections? Explain its subclasses and their usage.
104. What are Comparator and Comparable in Java collections? How do you use them for sorting?
105. Explain the collection algorithms available in Java. How do you use them for searching, sorting, and manipulating collections?

Contact Us

Our Address

Office no.- 401,Shekhar Central Building ,Palasiya, Pin-code:452001, Indore

Email Us

contact@codebetter.in

Call Us

+91 88230 75444, +91 99939 28766

Loading
Your message has been sent. Thank you!