Java Exam-Oriented Notes
Unit 1 – Introduction to Java
Java is a high-level, object-oriented programming language developed by Sun Microsystems.
Features: Platform Independent, Simple, Secure, Robust, Multithreaded, Portable.
JVM (Java Virtual Machine) executes bytecode, JDK (Java Development Kit) is used to develop
Java applications, JRE (Java Runtime Environment) provides libraries to run them.
Sample Program:
class Main {
public static void main(String args[]) {
System.out.println("Hello Java");
}
}
Unit 2 – Basics of Java
Variables: Containers for storing data. Example: int num = 10;
Data Types: Primitive (int, char, float, boolean) & Non-Primitive (String, Arrays).
Operators: Arithmetic (+, -), Relational (>, <), Logical (&&, ||), Assignment (=, +=).
Input: Use Scanner class → Scanner sc = new Scanner(System.in);
Unit 3 – Control Statements
Decision Making: if, if-else, nested if, switch-case.
Loops: for, while, do-while.
Jump Statements: break, continue, return.
Unit 4 – Object-Oriented Programming
Class: A blueprint for objects.
Example: class Student { int id; String name; }
Object: An instance of a class.
Constructor: Used to initialize objects.
Inheritance: Acquiring properties of parent class. Example: class B extends A.
Polymorphism: Method Overloading & Method Overriding.
Abstraction: Hiding implementation using abstract classes & interfaces.
Encapsulation: Wrapping data & methods together inside a class.
Unit 5 – Arrays & Strings
Array: Collection of elements of the same type. Example: int arr[] = {1,2,3};
String: Immutable sequence of characters. Example: String s = "Java";
StringBuffer & StringBuilder: Used for mutable strings.
Unit 6 – Exception Handling
Exception: An event that disrupts program flow.
try-catch-finally: Handles exceptions.
throw & throws: Used to explicitly throw exceptions.
Custom Exception: Creating user-defined exceptions.
Unit 7 – Multithreading
Multithreading allows concurrent execution of tasks.
Creating Threads: Extending Thread class or implementing Runnable interface.
Thread Methods: start(), sleep(), join(), yield().
Synchronization ensures thread safety.
Unit 8 – Collections Framework
Collections: Framework for storing & manipulating groups of objects.
List: ArrayList, LinkedList; Set: HashSet; Map: HashMap.
Iterators: Used to traverse collections.
Unit 9 – Java I/O
File Handling using FileReader, FileWriter, BufferedReader, BufferedWriter.
Serialization: Converting object into byte stream.
Deserialization: Reconstructing object from byte stream.
Unit 10 – Important Programs
Factorial:
int fact=1; for(int i=1;i<=n;i++){fact*=i;}
Fibonacci:
int a=0,b=1; while(n-->0){System.out.print(a); int sum=a+b; a=b; b=sum;}
Palindrome, Prime Numbers, Sorting & Searching.
Unit 11 – Quick Revision Questions
Q1. Difference between JDK, JRE, JVM?
Q2. What is method overloading & overriding?
Q3. What is the difference between ArrayList & LinkedList?
Q4. What is finally block in exception handling?