JAVA QUICK REVISION NOTES
1. Class, Object, Method
- Class: Blueprint for creating objects.
Example: class Car { String color; void drive() { } }
- Object: Instance of a class.
Example: Car myCar = new Car();
- Method: Block of code to perform a task.
Example: void drive() { System.out.println("Driving"); }
2. Method Overloading
- Same method name, different parameters.
- Possible for: Constructors, Static Methods, Final Methods.
Example:
void add(int a, int b);
void add(double a, double b);
3. Constructors
- Special method to initialize objects.
- Types: Default, Parameterized, Copy Constructor (manual).
- Rule: Cannot be static or final.
4. Type Conversion vs Type Casting
Type Conversion: Automatic, by compiler.
Type Casting: Manual, by programmer.
Examples:
Type Conversion -> int to double automatically.
Type Casting -> double to int manually.
5. Access Specifiers
public: Everywhere
private: Inside the class
protected: Same package + subclasses
Default: Same package only
6. Platform Independence (Java)
- Compiles to Bytecode.
- JVM executes Bytecode on any OS.
- "Write Once, Run Anywhere".
7. Static, Final and Main Method
- public static void main(String args[])
- public: Accessible everywhere.
- static: No object needed.
- void: No return.
- Main must be static.
8. Web Application Language Choice
- Prefer Object-Oriented Programming (OOP).
- Modular, Secure, Maintainable, Scalable.
9. Immutable String in Java
- String cannot be changed once created.
- Reason: Security, Thread Safety, Memory Efficiency.
Example:
String s = "Hello";
s = "World"; // New object created.
10. Wrapper Classes, Boxing & Unboxing
- Wrapper Class: Converts primitive to object.
- Boxing: Integer i = Integer.valueOf(5);
- Unboxing: int a = i.intValue();
QUICK REVISION FORMULAS
- OOP: Class + Object + Method
- Overloading: Same name, different parameters
- Platform Independence: Bytecode + JVM
- Constructor Rule: No static or final
- Access Specifiers: Public > Protected > Default > Private
ALL THE BEST FOR YOUR EXAMS!