Java Programming & OOP Quick Revision
1. Java Basics
- Java: High-level, platform-independent, object-oriented programming language.
- History: Developed by Sun Microsystems (James Gosling) in 1995.
- Features: Platform Independent, Simple, Secure, Robust, Multithreaded, Portable.
- C++ vs Java: Java has no pointers, supports garbage collection, and is platform-independent.
- JDK, JRE, JVM: Development Kit, Runtime Env, Virtual Machine.
- Control Statements: if, else, switch, for, while, do-while.
2. OOP Concepts
- Class & Object: Blueprint and instance.
- Constructor: Initializes objects.
- this keyword: Refers to current object.
- static keyword: Belongs to class, not object.
- Inheritance: IS-A relationship.
- Aggregation: HAS-A relationship.
- Polymorphism: Overloading (compile-time), Overriding (runtime).
- super: Refers to parent class.
- final: Constant or prevent override.
- instanceof: Type check.
3. Abstraction
- Abstract Class: Cannot be instantiated; may have abstract/concrete methods.
- Interface: All methods abstract by default.
- Abstract vs Interface: Interface supports multiple inheritance.
4. Encapsulation & Access
- Encapsulation: Wrapping data with methods.
- Access Modifiers: public, private, protected, default.
- Packages: Organize classes.
5. Arrays & Strings
- Array: Fixed-size data structure.
- String: Immutable sequence of characters.
- Methods: length(), charAt(), substring(), equals(), etc.
6. Exception Handling
- try-catch-finally: Handle exceptions.
- throw: Manually throw exception.
- throws: Declare exception in method.
- final vs finally vs finalize: Const, always executed, GC method.
7. Multi-threading
- Thread: Independent execution path.
- Create using Thread class or Runnable interface.
8. IO & Collections
- IO: InputStream, OutputStream, Readers, Writers.
- Serialization: Save object state.
- Collections: List (ArrayList), Set (HashSet), Map (HashMap).