Java Viva Questions
Created by: MS
Unit I: Introduction to Java
1. What are the main features of Java that make it platform-independent?
2. What is the difference between JDK, JRE, and JVM?
3. How are command-line arguments used in Java?
4. What is the purpose of the main() method in Java?
5. Define the term "Wrapper class" with examples. Why we need wrapper class ?
6. What is the use of static in “public static void main(String[] args)” ?
Unit II: Control Structures and OOP Basics
7. How can we iterate through multi-dimensional arrays?
8. What is the purpose of varargs in method definitions?
9. How do you define and use an enumeration (enum) in Java?
10. What is the significance of the this keyword?
11. What is method overloading work in Java?
12. What is an initializer block, static block in java?
13. Differentiate between String and StringBuilder.
14. How can we access private members of a class from another class ?
Unit III: Inheritance and Interfaces
15. What is method overriding and how is it implemented?
16. Overriding vs overloading ?
17. Explain the use of the super keyword with an example.
18. How do equals() and toString() methods work in Java?
19. What are the uses of final keyword in java?
20. How is an interface different from an abstract class?
21. What are default and static methods in interfaces?
Unit IV: Lambda and Nested Classes
22. What is a functional interface? Give an example.
23. How are lambda expressions used in java?
24. What are anonymous classes and when should they be used?
25. Differentiate between static and non-static nested classes.
26. How do you work with date and time in Java?
Unit V: Exception Handling and I/O
27. Difference between exception and error ?
28. What are the different types of exceptions in Java?
29. How do try, catch, and finally blocks work?
30. Explain the difference between throw and throws.
31. Difference between Byte Stream vs Character Stream ?
32. What is the difference between serialization and deserialization ?
Unit VI: Collections and Generics
33. What is the use of generics in Java collections?
34. How do you implement an ArrayList using generics?
35. What is the difference between TreeSet and HashSet?
36. Explain the use of Comparable and Comparator interfaces.
37. What is a Deque and how is it used?
38. What is wildcard ? How does Java handle bounded and unbounded wildcards in generics?