Core Java: A Beginner to Intermediate Guide
1. Introduction to Java
Java is a high-level, object-oriented programming language developed by Sun Microsystems in 1995. It is
platform-independent due to the Java Virtual Machine (JVM), which allows compiled Java programs to run on
any device. Features include simplicity, portability, high performance, security, and multithreading.
Page 1
Core Java: A Beginner to Intermediate Guide
2. Java Installation and Environment Setup
To start with Java development, install the Java Development Kit (JDK). Set the JAVA_HOME environment
variable. Use IDEs like IntelliJ IDEA, Eclipse, or NetBeans for coding. Verify the setup using 'java -version'
and 'javac'.
Page 2
Core Java: A Beginner to Intermediate Guide
3. First Java Program
A Java program starts with a class and contains a main method:
public class HelloWorld {
public static void main(String[] args) {
[Link]("Hello, World!");
Page 3
Core Java: A Beginner to Intermediate Guide
4. Data Types and Variables
Java has primitive types (int, byte, char, float, double, long, short, boolean) and reference types. Variables
must be declared before use, e.g., int x = 10; String name = "Java";
Page 4
Core Java: A Beginner to Intermediate Guide
5. Operators
Operators perform operations on variables and values. Java has arithmetic (+, -, *, /), relational (==, !=, >, <),
logical (&&, ||, !), and assignment operators (=, +=, -=).
Page 5
Core Java: A Beginner to Intermediate Guide
6. Control Flow Statements
Use if, if-else, else-if, and switch statements to control program flow based on conditions.
Page 6
Core Java: A Beginner to Intermediate Guide
7. Loops
Java supports for, while, and do-while loops. Loops help in executing a set of statements repeatedly. Use
'break' to exit and 'continue' to skip iterations.
Page 7
Core Java: A Beginner to Intermediate Guide
8. Arrays
Arrays store multiple values in a single variable. Declare an array as: int[] arr = new int[5]; Access elements
using index (starting at 0).
Page 8
Core Java: A Beginner to Intermediate Guide
9. Object-Oriented Programming (OOP)
Java uses OOP principles: Encapsulation (data hiding), Inheritance (reuse), Polymorphism (many forms), and
Abstraction (hiding complexity).
Page 9
Core Java: A Beginner to Intermediate Guide
10. Classes and Objects
A class is a blueprint for creating objects. Objects have state (fields) and behavior (methods). Example:
class Car {
String model;
void drive() {}
Page 10
Core Java: A Beginner to Intermediate Guide
11. Constructors
Constructors initialize objects. If no constructor is defined, Java provides a default one. You can overload
constructors by using different parameter lists.
Page 11
Core Java: A Beginner to Intermediate Guide
12. Encapsulation and Access Modifiers
Encapsulation is achieved using private fields and public getters/setters. Access modifiers control visibility:
public, private, protected, and default.
Page 12
Core Java: A Beginner to Intermediate Guide
13. Inheritance
Inheritance allows one class to inherit fields and methods of another using 'extends'. Java supports single
inheritance and multiple inheritance via interfaces.
Page 13
Core Java: A Beginner to Intermediate Guide
14. Polymorphism
Polymorphism enables one interface to be used for a general class of actions. Method overloading and
method overriding are two types of polymorphism.
Page 14
Core Java: A Beginner to Intermediate Guide
15. Abstraction
Abstraction hides implementation details. Use abstract classes (with abstract methods) and interfaces to
define contracts for classes.
Page 15
Core Java: A Beginner to Intermediate Guide
16. Interfaces
Interfaces are used to achieve abstraction and multiple inheritance. They contain method declarations without
implementations. A class implements an interface using the 'implements' keyword.
Page 16
Core Java: A Beginner to Intermediate Guide
17. Exception Handling
Exceptions are runtime errors. Use try-catch blocks to handle exceptions. Use finally for cleanup and 'throws'
to declare exceptions.
Page 17
Core Java: A Beginner to Intermediate Guide
18. File Handling
Java provides FileReader, BufferedReader, FileWriter, and BufferedWriter for reading and writing files. Use
try-with-resources to automatically close resources.
Page 18
Core Java: A Beginner to Intermediate Guide
19. Collections Framework
Java Collections include List, Set, and Map. Classes like ArrayList, HashMap, and HashSet help manage
groups of objects efficiently.
Page 19
Core Java: A Beginner to Intermediate Guide
20. Final Project Overview
Build a console-based ToDo application using Java concepts. Implement classes, use collections to store
tasks, and provide options to add, update, delete, and list ToDo items.
Page 20