Java short notes
Java short notes
1. Introduction to Java:
• Platform Independence: Java uses the "write once, run anywhere" philosophy, making
it platform-independent via the Java Virtual Machine (JVM).
• Inheritance: Enables one class to inherit the properties and methods of another class.
Allows for code reusability.
• Encapsulation: Hides the internal state of an object and only exposes necessary
methods. Achieved using private variables and public getter/setter methods.
• Abstraction: Hides complex implementation details from the user. Can be achieved
using abstract classes and interfaces.
3. Java Syntax:
• Every Java program begins with the main() method, which is the entry point of the
program.
System.out.println("Hello, World!");
4. Exception Handling:
try {
int result = 10 / 0;
} catch (ArithmeticException e) {
System.out.println("Error: " + e.getMessage());
} finally {
5. Java Features:
• Garbage Collection: Automatic memory management ensures that objects not in use
are removed to free memory space.
• Security: Java includes a range of security features such as bytecode verification and
secure class loaders.