Java Concepts Answers
Java Concepts Answers
- JVM (Java Virtual Machine): It runs Java bytecode and makes Java platform-independent.
- JDK (Java Development Kit): A package that includes JRE + tools for Java development (compiler,
debugger, etc.).
- JRE (Java Runtime Environment): It provides environment to run Java programs. Includes JVM +
libraries.
- IS-A: Represents inheritance. A child class IS-A parent class (e.g., Dog IS-A Animal).
- HAS-A: Represents composition. A class contains another class (e.g., Car HAS-A Engine).
- Java uses interfaces to avoid diamond problem. Since Java doesn't support multiple inheritance
with classes, interfaces are used and ambiguity is resolved using default methods.
4. What is polymorphism?
- Polymorphism means one thing behaves in different ways. In Java, it can be compile-time (method
- Also called method overloading. Same method name with different parameters.
7. What is run-time polymorphism?
- Also called method overriding. Method in subclass overrides parent class method at runtime.
- When we want to define a common structure and enforce some methods to be implemented in
child classes.