Java Interview Questions & Answers
1. What is Java?
Answer: Java is a programming language used to develop applications.
2. Who developed Java?
Answer: Java was developed by Sun Microsystems.
3. Is Java platform independent?
Answer: Yes, Java is platform independent.
4. What is JVM?
Answer: JVM runs Java bytecode on any system.
5. What is JDK?
Answer: JDK is used to develop Java programs.
6. What is JRE?
Answer: JRE is used to run Java programs.
7. What is bytecode?
Answer: Bytecode is the compiled code of Java.
8. What is a class?
Answer: A class is a blueprint for objects.
9. What is an object?
Answer: An object is an instance of a class.
10. What is the main method?
Answer: It is the starting point of a Java program.
11. Is Java case-sensitive?
Answer: Yes, Java is case-sensitive.
12. What is a variable?
Answer: A variable stores data.
13. What is a data type?
Answer: It defines the type of data.
14. Name any primitive data type.
Answer: int
15. What is int?
Answer: It stores integer numbers.
16. What is float?
Answer: It stores decimal values.
17. What is char?
Answer: It stores a single character.
18. What is boolean?
Answer: It stores true or false.
19. What is a string?
Answer: String is a sequence of characters.
20. Is String mutable?
Answer: No, String is immutable.
21. What is an array?
Answer: An array stores multiple values of same type.
22. What is a loop?
Answer: A loop repeats a block of code.
23. Name one loop in Java.
Answer: for loop
24. What is if statement?
Answer: It is used for decision making.
25. What is switch statement?
Answer: It selects execution based on value.
26. What is inheritance?
Answer: One class acquires another class properties.
27. What is polymorphism?
Answer: One method having many forms.
28. What is encapsulation?
Answer: Wrapping data and methods together.
29. What is abstraction?
Answer: Hiding implementation details.
30. What is method?
Answer: A method is a block of code.
31. What is constructor?
Answer: It initializes an object.
32. Does constructor have return type?
Answer: No, constructor has no return type.
33. What is static keyword?
Answer: It belongs to class, not object.
34. What is final keyword?
Answer: It cannot be changed.
35. What is this keyword?
Answer: It refers to current object.
36. What is super keyword?
Answer: It refers to parent class object.
37. What is exception?
Answer: An error during program execution.
38. What is try-catch?
Answer: It handles exceptions.
39. What is package?
Answer: A group of related classes.
40. What is access modifier?
Answer: It controls visibility.
41. Name one access modifier.
Answer: public
42. What is public?
Answer: Accessible everywhere.
43. What is private?
Answer: Accessible within same class.
44. What is protected?
Answer: Accessible in same package or subclass.
45. What is default access?
Answer: Accessible within same package.
46. What is interface?
Answer: It contains abstract methods.
47. Can Java support multiple inheritance?
Answer: Yes, using interface.
48. What is garbage collection?
Answer: Automatic memory cleanup.
49. What is null?
Answer: It means no object reference.
50. What is Java used for?
Answer: Web apps, mobile apps, and software.