– JDK (Java Development Kit): Tools for developing Java programs, including the compiler and debugger. – JRE (Java Runtime Environment): Provides libraries and JVM to run Java applications. – JVM (Java Virtual Machine): Executes Java bytecode, enabling platform independence.
– Encapsulation: Binding data and code together. – Abstraction: Hiding implementation details. – Inheritance: Code reuse through parent-child relationships. – Polymorphism: One name, multiple forms (method overloading/overriding
==: Checks reference equality. .equals(): Checks content equality.
A constructor is a special method used to initialize objects. It has the same name as the class and no return type.
String a = new String("Java"); String b = new String("Java"); System.out.println(a == b); // false System.out.println(a.equals(b)); // true
– Overloading: Same method name with different parameters (compile-time). – Overriding: Subclass provides a specific implementation of a method already defined in its superclass (runtime)
ArrayList – Uses a dynamic array internally. – Provides fast random access – Insertion and deletion are slow,because elements may need to be shifted. – Better suited for read-heavy operations. – Resizes dynamically – Not efficient for frequent insertions/removals in the middle of the list.
LinkedList – Uses a doubly linked list internally. – Access time is slower due to sequential traversal. – Insertion and deletion are faster, especially at the beginning or end – Consumes more memory – Better suited for write-heavy operations (frequent adds/removes). – No resizing cost, as elements are linked individually.
– Interface = 100% abstraction – Abstract = partial abstraction Java 8+ lets interfaces have default methods!
Threads = multitasking. Use Thread or Runnable to run code in parallel. Avoid Thread.sleep() without need!
– public: everywhere – private: class only – protected: package + subclass – default: package-level