Core Java PDF 1: Introduction to Core Java
Introduction to Core Java
Java is a high-level, class-based, object-oriented programming language designed to have as
few implementation dependencies as possible. It is widely used for building robust and
secure applications.
Features of Java:
• Platform Independent: Java code runs on multiple platforms without modification
due to the Java Virtual Machine (JVM).
• Object-Oriented: Java follows OOP principles like Encapsulation, Inheritance,
Polymorphism, and Abstraction.
• Secure: Provides built-in security features like bytecode verification, automatic
memory management, and exception handling.
• Multithreading: Java supports concurrent execution of two or more parts of a
program for maximum utilization of CPU.
Java Development Kit (JDK), Java Virtual Machine (JVM), and Java Runtime Environment
(JRE):
• JDK: Includes the compiler, libraries, and tools necessary for Java development.
• JVM: Converts Java bytecode into machine code for execution.
• JRE: Contains the libraries and JVM required to run Java applications.
Core Java PDF 2: OOPs Concepts in Java
Object-Oriented Programming Concepts in Java
Java is based on Object-Oriented Programming (OOP) concepts, which provide modularity,
reusability, and scalability to applications.
Key OOP Concepts:
1. Encapsulation: Wrapping data and code into a single unit (class) to restrict direct
access to variables.
2. Inheritance: Allowing one class to inherit properties and methods of another class.
3. Polymorphism: The ability to perform a single action in different ways (Method
Overloading and Method Overriding).
4. Abstraction: Hiding implementation details from the user while only exposing
necessary functionalities.
Example:
class Animal {
void makeSound() {
System.out.println("Animal makes a sound");
class Dog extends Animal {
void makeSound() {
System.out.println("Dog barks");
public class Test {
public static void main(String[] args) {
Animal myDog = new Dog();
myDog.makeSound();
Core Java PDF 3: Exception Handling in Java
Exception Handling in Java
Exception handling is a mechanism to handle runtime errors and maintain normal program
flow.
Types of Exceptions:
1. Checked Exceptions: Handled at compile-time (e.g., IOException, SQLException).
2. Unchecked Exceptions: Occur at runtime (e.g., NullPointerException,
ArithmeticException).
Exception Handling Keywords:
• try: Defines the block of code that may throw an exception.
• catch: Handles exceptions.
• finally: Executes code after try-catch, whether an exception occurs or not.
• throw: Manually throw an exception.
• throws: Declares an exception that might be thrown.
Example:
try {
int result = 10 / 0;
} catch (ArithmeticException e) {
System.out.println("Cannot divide by zero");
} finally {
System.out.println("Execution completed");
Core Java PDF 4: Multithreading in Java
Multithreading in Java
Multithreading allows concurrent execution of multiple parts of a program to maximize CPU
utilization.
Thread Lifecycle:
1. New: Thread object created but not started.
2. Runnable: Thread ready to run.
3. Blocked/Waiting: Thread waiting for resources.
4. Running: Thread executing.
5. Terminated: Thread execution complete.
Implementing Threads:
• Extending Thread Class
• Implementing Runnable Interface
Example:
class MyThread extends Thread {
public void run() {
System.out.println("Thread is running");
public class TestThread {
public static void main(String[] args) {
MyThread t1 = new MyThread();
t1.start();
Core Java PDF 5: Collections Framework in Java
Collections Framework in Java
The Collections Framework provides a set of interfaces and classes to store and manipulate
groups of objects.
Key Interfaces:
1. List (ArrayList, LinkedList, Vector)
2. Set (HashSet, TreeSet, LinkedHashSet)
3. Map (HashMap, TreeMap, LinkedHashMap)
4. Queue (PriorityQueue, Deque)
Example:
import java.util.*;
public class TestCollection {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
list.add("Java");
list.add("Python");
list.add("C++");
for (String lang : list) {
System.out.println(lang);
These PDFs cover essential Core Java topics, making it easier for beginners to learn
fundamental concepts.