Java Syllabus
Java Syllabus
PART -I
1. JAVA INTO
2. WHAT IS JAVA
3. FEATURES OF JAVA
4. C VS C++ VS JAVA
5. PROGRAM INTERNAL
6. WHAT IS JDK JRE JVM
7. JDK DOWNLOAD AND PATH SETTING
8. WHAT IS CLASS
9. WHAT IS OBJECT
10. HELLO JAVA PROGRAM
11. DATA TYPES
12. VARIABLES
13. MEMORY MANAGEMENT
14. KEYWORDS
15. SCANNER CLASS
16. JAVA CONTROL STATEMENTS
PART -II
1. PACKAGES
2. ACCESS MODIFIERS
3. METHODS
4. JAVA OPP’S CONCEPT
● CLASS
● OBJECT
● INHERITANCE
i. INHERITANCE(IS-A)
ii. INHERITANCE(HAS-A)
● POLYMORPHISM
i. COMPILE TIME POLYMORPHISM
ii. RUNTIME POLYMORPHISM
● ABSTRACTION
i. ABSTRACT CLASS
ii. INTERFACE
● ENCAPSULATION
5. this AND super ,final KEYWORDS
6. CONSTRUCTOR
7. this() AND super() KEYWORDS
1
PART -III
1. JAVA ARRAY
2. ARRAYS CLASS
3. STRING
4. STRING BUFFER AND STRING BUILDER
5. EXCEPTION HANDLING
6. FILE HANDLING
7. MULTITHREADING
a. SYNCHRONIZATION
b. INTER THREAD COMMUNICATION
c. DEADLOCK
d. DAEMON THREAD
8. INNER CLASS
9. OBJECT CLASS
PART -IV
1. WRAPPER CLASS
2. COLLECTION
● LIST
● QUEUE
● SET
3. COLLECTIONS
4. COMPARABLE INTERFACE
5. COMPARATOR INTERFACE
6. MAP INTERFACE
7. HASHTABLE
8. JAVA JDBC
2
PART - I
1. What is Java?
● Platform-independent: Java code is compiled into bytecode that can run on any platform
having a JVM.
● Object-Oriented: Java supports object-oriented programming concepts like classes, objects,
inheritance, polymorphism, encapsulation, and abstraction.
● Multithreading: Java supports concurrent execution of threads, making it suitable for
complex applications.
● Secure: Java uses the JVM to run code in a safe execution environment.
● Robust: Java’s strong exception handling and automatic memory management make it a
reliable language.
● Distributed: Java provides built-in networking capabilities and APIs.
2. C vs C++ vs Java
Feature C C++ Java
3. Program Internal
3
4. What is JDK, JRE, JVM?
● JDK (Java Development Kit): A software development kit that contains the necessary tools
for developing Java applications, including the compiler (javac), debugger, and JRE.
● JRE (Java Runtime Environment): A runtime environment that includes libraries and the
JVM to run Java applications.
● JVM (Java Virtual Machine): The engine that runs Java bytecode and provides platform
independence.
1. Download JDK: Visit Oracle’s official website to download the JDK.
2. Path Setting:
○ Windows:
■ Set JAVA_HOME environment variable to JDK's installation path.
■ Add JAVA_HOME/bin to the PATH system variable.
○ Linux/Mac:
■
○
6. What is a Class?
In Java, a class is a template or blueprint used to create objects. It defines the properties (fields) and
behaviors (methods) that the objects created from it will have.
Example:
java
Copy code
class Car {
String model;
int year;
void displayInfo() {
4
System.out.println("Model: " + model + ", Year: " + year);
}
}
7. What is an Object?
An object is an instance of a class. It holds the data (state) and methods (behavior) that are defined in
the class.
Example:
java
Copy code
class Dog {
String name;
void bark() {
System.out.println(name + " is barking!");
}
}
java
5
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!"); // Output: Hello,
World!
}
}
9. Data Types
Example:
java
Copy code
public class DataTypesExample {
public static void main(String[] args) {
int x = 10; // Integer
double pi = 3.14; // Double
char letter = 'A'; // Character
boolean isJavaFun = true; // Boolean
10. Variables
Variables in Java are used to store data. Java supports different types of variables:
6
● Class Variables: Declared with the static keyword.
Example:
java
Copy code
public class VariableExample {
int instanceVar = 5; // Instance variable
Java has automatic memory management, which is handled by the Garbage Collector (GC). The GC
automatically removes objects that are no longer in use to free up memory.
Example:
java
Copy code
public class GarbageCollectionExample {
public static void main(String[] args) {
String str = new String("Garbage Collection");
str = null; // Nullifying the reference to let GC clear the
object
System.gc(); // Request garbage collection (not guaranteed
to run immediately)
}
}
12. Keywords
Keywords are reserved words in Java that have a predefined meaning and cannot be used as
identifiers. Examples include class, public, private, static, final, etc.
7
Example:
java
Copy code
public class KeywordsExample {
public static void main(String[] args) {
final int MAX_VALUE = 100; // 'final' keyword
System.out.println(MAX_VALUE); // Output: 100
}
}
Example:
java
Copy code
import java.util.Scanner;
Example:
java
8
Copy code
public class ControlStatementsExample {
public static void main(String[] args) {
// if-else example
int age = 18;
if (age >= 18) {
System.out.println("You are eligible to vote.");
} else {
System.out.println("You are not eligible to vote.");
}
// switch-case example
int day = 3;
switch (day) {
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
default:
System.out.println("Invalid day");
}
}
}
9
PART - II
1. Packages
In Java, a package is a namespace that organizes classes and interfaces. Packages are used to avoid
name conflicts and to control access. They can be classified as built-in packages (like java.util
and java.io) or user-defined packages.
Example:
java
Copy code
// User-defined package example
package com.example;
java
Copy code
import com.example.MyClass;
2. Access Modifiers
Access modifiers are keywords used to define the accessibility of classes, methods, and variables.
Java has four types of access modifiers:
10
● public: Accessible from any class.
Example:
java
Copy code
public class AccessModifiersExample {
private int privateVar = 10; // Accessible only within this
class
int defaultVar = 20; // Accessible within the same
package
protected int protectedVar = 30; // Accessible within the same
package and subclasses
public int publicVar = 40; // Accessible from any class
}
3. Methods
Methods in Java are blocks of code that perform a specific task. Methods have a name, a return type,
and parameters.
Types of Methods:
Example:
java
Copy code
public class MethodExample {
// Instance Method
public void greet() {
System.out.println("Hello, World!");
}
// Static Method
public static void staticMethod() {
System.out.println("Static method called!");
}
11
MethodExample.staticMethod(); // Calling static method
}
}
5. Inheritance
Inheritance allows one class to inherit the properties and behaviors of another class.
IS-A Relationship
HAS-A Relationship
12
public class InheritanceExample {
public static void main(String[] args) {
Dog dog = new Dog();
dog.eat(); // Inherited method
dog.bark(); // Dog's own method
}
}
6. Polymorphism
Polymorphism is the ability of a single method to perform different tasks. It can be of two types:
void print(String s) {
System.out.println("Printing string: " + s);
}
}
13
System.out.println("Animal makes a sound");
}
}
7. Abstraction
Abstraction is the concept of hiding the implementation details and showing only the necessary
functionality. It can be achieved using:
● Abstract Class
● Interface
void eat() {
System.out.println("Eating...");
}
}
14
}
}
Interface Example:
java
Copy code
interface Animal {
void sound();
}
8. Encapsulation
Encapsulation is the process of wrapping data (variables) and code (methods) into a single unit. It is
achieved by providing access to the data using getter and setter methods.
Example:
java
Copy code
class Person {
15
private String name;
private int age;
// Getter method
public String getName() {
return name;
}
// Setter method
public void setName(String name) {
this.name = name;
}
this Keyword
super Keyword
16
Used to refer to the parent class constructor or methods.
final Keyword
Example:
java
Copy code
class Parent {
void display() {
System.out.println("Parent class display");
}
}
10. Constructor
A constructor is a special method used to initialize objects. It is called when an object of a class is
created.
Types of Constructors:
Example:
java
Copy code
17
class Car {
String model;
int year;
// Parameterized constructor
Car(String m, int y) {
model = m;
year = y;
}
void display() {
System.out.println("Model: " + model + ", Year: " + year);
}
}
Example:
java
Copy code
class Animal {
Animal() {
System.out.println("Animal constructor");
}
}
18
}
19
PART - III
1. Java Array
An array is a collection of elements of the same type, stored in contiguous memory locations. It can be
of any data type (primitive or object).
Types of Arrays:
Example:
java
Copy code
// Single-dimensional array
int[] numbers = {1, 2, 3, 4, 5};
// Accessing elements
System.out.println(numbers[0]); // Output: 1
2. Arrays Class
The Arrays class provides various utility methods for array manipulation like sorting, searching,
and filling.
Common Methods:
Example:
java
Copy code
import java.util.Arrays;
20
public class ArraysExample {
public static void main(String[] args) {
int[] numbers = {5, 1, 3, 2, 4};
3. String
A String in Java is an object that represents a sequence of characters. Strings are immutable,
meaning once created, their values cannot be changed.
Example:
java
Copy code
public class StringExample {
public static void main(String[] args) {
String str = "Hello, World!";
21
System.out.println("Length: " + str.length()); // Output:
13
System.out.println("Substring: " + str.substring(0, 5)); //
Output: Hello
System.out.println("To Upper Case: " + str.toUpperCase());
// Output: HELLO, WORLD!
}
}
● StringBuffer: Mutable string class designed for thread-safety (slower performance due to
synchronization).
● StringBuilder: Mutable string class designed for faster performance (not thread-safe).
Example:
java
Copy code
public class StringBufferBuilderExample {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer("Hello");
sb.append(", World!");
System.out.println(sb); // Output: Hello, World!
5. Exception Handling
Exception handling in Java is managed using try, catch, finally, throw, and throws
keywords.
Common Keywords:
22
● throws: Declares exceptions that a method might throw.
Example:
java
Copy code
public class ExceptionExample {
public static void main(String[] args) {
try {
int result = 10 / 0; // ArithmeticException
} catch (ArithmeticException e) {
System.out.println("Error: " + e.getMessage());
} finally {
System.out.println("This will always execute");
}
}
}
6. File Handling
File handling in Java is done using File, FileReader, FileWriter, BufferedReader, and
BufferedWriter.
Example:
java
Copy code
import java.io.*;
23
}
7. Multithreading
Multithreading is the concurrent execution of more than one part of a program to maximize CPU
utilization.
Common Concepts:
Example:
java
Copy code
class MyThread extends Thread {
public void run() {
System.out.println("Thread is running");
}
}
8. Inner Class
An inner class is a class defined within another class. It can be of several types: static inner class,
non-static inner class, local inner class, and anonymous inner class.
Example:
java
Copy code
class OuterClass {
int outerVar = 10;
class InnerClass {
void display() {
24
System.out.println("Outer Variable: " + outerVar);
}
}
}
9. Object Class
The Object class is the root of the Java class hierarchy. Every class in Java inherits from the
Object class.
Common Methods:
Example:
java
Copy code
class Person {
String name;
int age;
@Override
public String toString() {
return "Person[name=" + name + ", age=" + age + "]";
}
}
25
public class ObjectClassExample {
public static void main(String[] args) {
Person p = new Person("John", 25);
System.out.println(p.toString()); // Output:
Person[name=John, age=25]
}
}
26
PART - IV
1. Wrapper Class
Wrapper classes allow primitive types to be represented as objects. Java provides wrapper classes for
each primitive type.
Common Methods:
Example:
java
Copy code
public class WrapperClassExample {
public static void main(String[] args) {
Integer i = Integer.valueOf(100);
System.out.println(i.toString()); // Output: 100
}
}
2. Collection Framework
Java's Collection Framework is a set of classes and interfaces that implement commonly reusable
collection data structures. It includes:
27
list.add("Apple");
list.add("Banana");
System.out.println(list); // Output: [Apple, Banana]
}
}
3. Collections Class
The Collections class provides static methods for sorting, searching, and manipulating
collections.
Common Methods:
Example:
java
Copy code
import java.util.*;
Example (Comparable):
java
Copy code
class Student implements Comparable<Student> {
int age;
String name;
28
Student(int age, String name) {
this.age = age;
this.name = name;
}
@Override
public int compareTo(Student other) {
return this.age - other.age;
}
}
4o mini
You said:
continue Part IV
ChatGPT said:
ChatGPT
PART - IV (Continued)
5. Map Interface
The Map interface represents a collection of key-value pairs. Common implementations include
HashMap, TreeMap, and LinkedHashMap.
Methods in Map:
29
● containsKey(): Checks if the map contains a specified key.
● keySet(): Returns a set view of the keys.
● values(): Returns a collection view of the values.
Example (HashMap):
java
Copy code
import java.util.*;
6. Hashtable
Methods in Hashtable:
Example (Hashtable):
java
Copy code
import java.util.*;
30
table.remove("Mary");
System.out.println(table); // Output: {John=40}
}
}
JDBC is a Java API for connecting and executing queries with a database. It provides methods for
querying and updating data, and managing database connections.
Steps in JDBC:
// Establish connection
Connection connection = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/mydatabase", "root",
"password");
// Create statement
Statement statement = connection.createStatement();
// Execute query
ResultSet resultSet = statement.executeQuery("SELECT *
FROM users");
31
// Process results
while (resultSet.next()) {
System.out.println("ID: " + resultSet.getInt("id"));
System.out.println("Name: " +
resultSet.getString("name"));
}
// Close connection
connection.close();
The Collection Framework is a powerful set of interfaces and classes for handling groups of objects
in Java. It enables the storage, retrieval, and manipulation of collections of objects. Here's a summary
of key components:
● Interfaces:
○ Collection: The root interface in the collection hierarchy.
○ List: A sequence of elements (e.g., ArrayList, LinkedList).
○ Set: A collection of unique elements (e.g., HashSet).
○ Queue: A collection used to hold elements before processing (e.g.,
PriorityQueue).
○ Map: A collection of key-value pairs (e.g., HashMap).
● Classes:
○ ArrayList: A resizable array implementation of the List interface.
○ HashSet: A Set implementation backed by a hash table.
○ PriorityQueue: A queue where elements are ordered based on priority.
○ HashMap: A Map implementation based on a hash table.
● Utility Class:
○ Collections: Provides static methods to operate on collections (e.g., sort(),
reverse()).
32
9. Conclusion
Java provides a robust set of tools for managing data, handling exceptions, working with threads, and
interacting with databases. The Collection Framework and JDBC enable developers to efficiently
manage and query data, while Exception Handling ensures that Java programs are more robust and
easier to debug.
33