1. What is Java's principle of platform independence?
Answer: Java is platform-independent because it uses the Java Virtual Machine
(JVM) to convert Java code into bytecode, which can be interpreted by the
JVM at runtime. This allows Java code to be written once and run on multiple
platforms without recompiling.
2. What are the differences between abstract classes and interfaces in
Java?
Answer:
� An abstract class can have both abstract and non-abstract methods,
whereas an interface can only have abstract methods.
� A class can inherit from only one abstract class, but it can implement
multiple interfaces.
� Abstract classes can have constructors, while interfaces cannot.
� Abstract classes can have instance variables, while interfaces can only
have constants (static final variables).
� Interfaces can be used to achieve multiple inheritance in Java, while
abstract classes cannot.
3. What is the difference between a checked exception and an unchecked
exception in Java?
Answer: