Frequently asked questions and answers of Java in Programming Technologies of Computer Science to enhance your skills, knowledge on the selected topic. We have compiled the best Java Interview question and answer, trivia quiz, mcq questions, viva question, quizzes to prepare. Download Java FAQs in PDF form online for academic course, jobs preparations and for certification exams .
Intervew Quizz is an online portal with frequently asked interview, viva and trivia questions and answers on various subjects, topics of kids, school, engineering students, medical aspirants, business management academics and software professionals.
Question-1. What are Java's primitive data types?
Answer-1: Primitive types include byte, short, int, long, float, double, char, and boolean.
Question-2. What is method overloading in Java?
Answer-2: Method overloading is defining multiple methods with the same name but different parameters.
Question-3. What is method overriding in Java?
Answer-3: Method overriding occurs when a subclass provides a specific implementation of a method from its superclass.
Question-4. What is the final keyword in Java?
Answer-4: The final keyword is used to define constants, prevent method overriding, or inheritance.
Question-5. What is a static method in Java?
Answer-5: A static method belongs to the class rather than an instance of the class.
Question-6. What is Java's exception hierarchy?
Answer-6: The hierarchy starts with Throwable, which has two branches: Error and Exception.
Question-7. How do you handle exceptions in Java?
Answer-7: Use try, catch, finally, and throw to handle exceptions.
Question-8. What is the difference between throw and throws?
Answer-8: throw is used to explicitly throw an exception; throws declares exceptions in a method signature.
Question-9. What are Java's control statements?
Answer-9: Control statements include if, else, switch, for, while, and do-while.
Question-10. What is a Java thread?
Answer-10: A thread is a lightweight process in Java for performing concurrent tasks.
Question-11. What is the difference between Runnable and Thread?
Answer-11: Runnable is an interface; Thread is a class. Implementing Runnable is preferred for better flexibility.
Question-12. What is synchronization in Java?
Answer-12: Synchronization ensures that only one thread accesses critical sections at a time.
Question-13. What are Java's memory areas?
Answer-13: Memory areas include Heap, Stack, Code, and Method Area.
Question-14. What is garbage collection in Java?
Answer-14: Garbage collection is the process of reclaiming unused memory automatically.
Question-15. What are Java's collections?
Answer-15: Collections are frameworks like ArrayList, HashMap, and HashSet for managing data structures.
Question-16. What is a HashMap in Java?
Answer-16: A HashMap is a collection that maps keys to values using hashing.
Question-17. What is the difference between HashMap and Hashtable?
Answer-17: HashMap is unsynchronized and allows null keys; Hashtable is synchronized and doesn't allow null keys.
Question-18. What is the transient keyword in Java?
Answer-18: The transient keyword prevents serialization of certain fields.
Question-19. What is the volatile keyword in Java?
Answer-19: volatile ensures that changes to a variable are visible to all threads.
Question-20. What are Java's functional interfaces?
Answer-20: Functional interfaces have a single abstract method and are used in lambda expressions.
Question-21. What is the Stream API in Java?
Answer-21: The Stream API allows processing sequences of data with functional programming techniques.
Question-22. What is the difference between Comparable and Comparator?
Answer-22: Comparable is used for natural ordering; Comparator is used for custom ordering.
Question-23. What is reflection in Java?
Answer-23: Reflection is the ability to inspect and modify classes, methods, and fields at runtime.
Question-24. What is the purpose of the super keyword?
Answer-24: super is used to refer to the immediate parent class.
Question-25. What is polymorphism in Java?
Answer-25: Polymorphism allows methods to perform differently based on the object that calls them.
Question-26. What are Java's design patterns?
Answer-26: Common patterns include Singleton, Factory, Observer, and Strategy.
Question-27. What is Java's this keyword?
Answer-27: this refers to the current instance of a class.
Question-28. What is a marker interface in Java?
Answer-28: A marker interface has no methods and is used for metadata purposes (e.g., Serializable).
Question-29. What is Java's Optional class?
Answer-29: Optional is a container object to avoid null and handle values that may be absent.
Question-30. What is Java's Stream lazy evaluation?
Answer-30: Streams process elements only when a terminal operation is invoked.
Question-31. What is the difference between == and equals() for strings?
Answer-31: == checks reference equality; .equals() checks value equality of strings.
Question-32. How do you compile and run a Java program?
Answer-32: Use javac
Question-33. What are the key features of Java?
Answer-33: Key features include platform independence, object-oriented programming, robustness, and security.
Question-34. What is the Java Virtual Machine (JVM)?
Answer-34: JVM is the runtime environment in Java that executes Java bytecode.
Question-35. What is the Java Runtime Environment (JRE)?
Answer-35: JRE is the runtime environment that provides libraries and JVM for running Java applications.
Question-36. What is the Java Development Kit (JDK)?
Answer-36: JDK is a software development kit that includes tools like the compiler, debugger, and JRE.
Question-37. What is the difference between JDK, JRE, and JVM?
Answer-37: JDK includes development tools and JRE; JRE includes libraries and JVM; JVM executes bytecode.
Question-38. What is bytecode in Java?
Answer-38: Bytecode is an intermediate code generated after compiling Java source code.
Question-39. What is the significance of the main() method in Java?
Answer-39: The main() method is the entry point of a Java application.
Question-40. What is a Java ClassLoader?
Answer-40: A ClassLoader is a subsystem of JVM that loads classes and interfaces into memory.
Question-41. What is the difference between == and .equals() in Java?
Answer-41: == compares object references, while .equals() compares the actual content of objects.
Question-42. What is a constructor in Java?
Answer-42: A constructor is a special method used to initialize objects.
Question-43. What are Java's access modifiers?
Answer-43: Access modifiers include public, private, protected, and default (no modifier).
Question-44. What is the difference between ArrayList and LinkedList?
Answer-44: ArrayList uses dynamic arrays, while LinkedList uses doubly linked lists.
Question-45. What is the difference between String, StringBuilder, and StringBuffer?
Answer-45: String is immutable; StringBuilder is mutable and non-synchronized; StringBuffer is synchronized.
Question-46. What is a Java interface?
Answer-46: An interface is a reference type that contains abstract methods and constants.
Question-47. What is an abstract class in Java?
Answer-47: An abstract class is a class that cannot be instantiated and may contain abstract methods.
Question-48. Can you use multiple inheritance in Java?
Answer-48: Java doesn't support multiple inheritance with classes, but it does with interfaces.
Question-49. What is Java?
Answer-49: Java is a high-level, object-oriented programming language designed to have as few implementation dependencies as possible.
Question-50. Who developed Java and when?
Answer-50: Java was developed by James Gosling at Sun Microsystems in 1995.
Frequently Asked Question and Answer on Java
Java Interview Questions and Answers in PDF form Online
Java Questions with Answers
Java Trivia MCQ Quiz