✅ UNIT-I: Java Basics, Arrays, Strings, and OOP
1. Features of Java
● Platform-Independent: Write Once, Run Anywhere (WORA) using bytecode.
● Object-Oriented: Everything is based on classes and objects.
● Robust & Secure: Strong memory management, exception handling, and no
pointers.
● Multithreaded: Supports multitasking using threads.
● High Performance: Just-In-Time (JIT) compiler optimizes bytecode at runtime.
● Dynamic & Portable: Adapts to changing environments and runs across platforms.
2. Bytecode and JVM
● Bytecode: Intermediate code generated after compiling Java source code (.java →
.class).
● JVM (Java Virtual Machine): Executes bytecode on any platform; handles memory
management, garbage collection, etc.
3. JDK
● Java Development Kit: Contains compiler (javac), JVM, libraries, and tools for
Java development.
4. Data Types
● Primitive Types: byte, short, int, long, float, double, char, boolean.
● Reference Types: Arrays, Strings, Objects.
● Each type defines memory size and allowed operations.
5. Operators
● Arithmetic (+, -, *, /, %)
● Relational (<, >, ==, !=)
● Logical (&&, ||, !)
● Bitwise, Assignment, Unary, Ternary
6. Control Statements
● if-else / nested if: Used for decision making.
● if-else ladder: Multiple conditions.
● switch-case: Cleaner multi-choice alternative.
● Loops:
○ while, do-while: Entry and exit-controlled.
○ for: Classic counting loop.
○ for-each: Simplified array/collection traversal.
● break, continue: Jump statements to exit or skip loop iterations.
7. Arrays
● Single-Dimensional: Linear structure; int[] a = new int[5];
● Multidimensional: Matrix-like structure; int[][] matrix = new int[3][3];
8. Strings
● String Class: Immutable, stored in String pool.
● Operations: .charAt(), .length(), .equals(), .compareTo(),
.substring(), .replace()
● StringBuffer: Mutable, thread-safe version of String.
● StringBuilder: Like StringBuffer but faster and non-synchronized.
9. Command Line Arguments
● Passed via main(String[] args); used to provide input at runtime through the
console.
10. Wrapper Classes
● Converts primitives into objects.
○ Example: int → Integer, char → Character
● Useful in collections, parsing (Integer.parseInt("123")), and autoboxing.
11. Classes, Objects, and Methods
● Class: Blueprint or template.
● Object: Instance of a class.
● Constructor: Special method to initialize object; same name as class.
● Constructor Overloading: Multiple constructors with different parameters.
● Method Overloading: Same method name, different parameters.
● Recursion: A method calling itself.
● Passing & Returning Object: Objects can be arguments and return types of
methods.
12. Keywords
● new: Creates object.
● this: Refers to current class instance.
● static: Belongs to class, shared among all instances.
● finalize(): Called before object is garbage collected.
13. Access Modifiers
● private, default, protected, public: Define visibility/scope.
14. Nested / Inner / Anonymous Classes
● Nested Class: Class inside another class.
● Inner Class: Non-static nested class.
● Anonymous Class: No name; declared and instantiated in one statement.
15. Abstract Class
● Cannot be instantiated.
● May contain abstract (no body) and concrete methods.
✅ UNIT-II: Inheritance, Interfaces, Packages, and
Exception Handling
1. Inheritance
● Extends base class to reuse code.
● Multilevel: Class extends another which itself extends another.
● Constructor Chaining: Using super() to call parent constructor.
● Method Overriding: Redefining a method in subclass.
2. Keywords in Inheritance
● super: Access superclass methods/constructors.
● final: Prevents inheritance or method overriding.
3. Interfaces
● Interface: Contains only abstract methods (until Java 8).
● Implemented using implements.
● Multiple Inheritance supported via interfaces.
● Interface Inheritance: One interface extends another.
● instanceof: Checks object type at runtime.
4. Dynamic Method Dispatch
● Runtime polymorphism: Method call is resolved at runtime based on the object.
5. Object Class
● Parent of all classes.
● Common methods: toString(), equals(), hashCode(), clone(), etc.
6. Abstract Class vs Interface
Feature Abstract Class Interface
Methods Can have All abstract (Java < 8)
implemented
Inheritance Single inheritance Multiple inheritance
Variables Any type public static final only
7. System.out.println
● System: Class; out: PrintStream object; println(): Method to print with a new
line.
8. Packages
● Package: Organizes classes.
● CLASSPATH: Location where JVM looks for packages/classes.
● Import Statement: Access classes from other packages.
● Static Import: Direct access to static members.
● Access Control: Regulates visibility (e.g., protected accessible in subclass).
9. Exception Handling
● Exception: Unexpected event that disrupts program flow.
● Error: Serious issues not meant to be handled (e.g., OutOfMemoryError).
● try-catch-finally: Catch and clean up after exceptions.
● throw: Used to throw an exception.
● throws: Declares exceptions a method might throw.
● Built-in Exceptions: ArithmeticException, NullPointerException, etc.
● Custom Exception: User-defined by extending Exception class.
● Throwable: Base class for exceptions and errors.
✅ UNIT-III: Networking, IO Streams, Collections
1. Networking (java.net)
● InetAddress: Represents IP addresses.
● Socket: For TCP communication (client-server).
● DatagramSocket / DatagramPacket: For UDP (connectionless) communication.
2. IO Streams
● Stream: Data flow.
○ Byte Streams: For binary data (InputStream, OutputStream)
○ Character Streams: For text data (Reader, Writer)
● File Class: Represents file or directory.
● Common Classes:
○ FileInputStream, FileOutputStream: Binary files.
○ FileReader, FileWriter: Text files.
○ BufferedReader: Efficient line-by-line reading.
3. Collection Classes
● List Interface: Ordered collection.
● ArrayList: Resizable array.
● LinkedList: Doubly-linked list.
● Enumeration: Legacy iterator.
● Vector: Thread-safe dynamic array.
● Properties: Key-value pairs, often used for config files.
● java.util Package: Contains the entire collection framework.
✅ UNIT-IV: Multithreading, Generics, Applets
1. Multithreaded Programming
● Thread: Smallest unit of CPU scheduling.
● Thread Class / Runnable Interface: Two ways to define a thread.
● Thread Priority: Influences thread scheduling (1 to 10).
● Synchronization: Prevents race conditions.
● Inter-thread Communication: wait(), notify(), notifyAll().
● Deadlock: Two or more threads wait indefinitely for each other.
2. Generics
● Generic Classes/Methods: Allow parameterized types (<T>)
● Bounded Types: T extends Number restricts T to subclasses of Number.
● Wildcards:
○ <?>: Unknown type.
○ <? extends T>: Subtypes of T.
○ <? super T>: Supertypes of T.
● Generic Constructors / Interfaces: Type-safe object creation.
3. Applets
● Applet Class: GUI-based small Java program embedded in a browser.
● Lifecycle Methods:
○ init(): Initialization
○ start(): After init or resume
○ stop(): Suspends
○ destroy(): Cleanup before termination
● Repainting: Update applet graphics.
● Status Window: Shows messages in browser.
● Passing Parameters: From HTML to applet using <param> tag.