CBSE Class 12 Information Technology (802) Unit 3 Java Notes | Fundamentals of Java Programming

 

CBSE Class 12 Information Technology (802) Unit 3 – Fundamentals of Java Programming


Easy Java Notes | Introduction to Java | OOP | Arrays | Classes | Exception Handling | Threads | Strings | Important Questions

Java is one of the important programming languages included in CBSE Class 12 Information Technology (802). Students need to understand both the basic concepts of Java and how these concepts are used while writing simple programs.

According to the CBSE 2026–27 curriculum, Unit 3 – Fundamentals of Java Programming carries 20 marks in the theory syllabus. The unit covers Java introduction, Object-Oriented Programming, Java language elements, operators, control flow, arrays, class design, exception handling, assertions, threads, wrapper classes and string manipulation.

This article explains these topics in very easy and student-friendly language, with simple examples and important exam questions.


📌 Unit 3 – Fundamentals of Java Programming

Topics Covered

  1. Introduction to Java

  2. Object-Oriented Programming

  3. Java Language Elements

  4. Operators

  5. Control Flow

  6. Arrays

  7. Class Design

  8. Exception Handling

  9. Assertions

  10. Threads

  11. Wrapper Classes

  12. String Manipulation


1. Introduction to Java

What is Java?

Java is a high-level, object-oriented and platform-independent programming language.

Java is widely used for developing:

  • Desktop applications

  • Web applications

  • Mobile applications

  • Enterprise applications

  • Banking applications

  • Educational software

Simple Example

Suppose we want to calculate the total marks of a student.

int marks1 = 80;
int marks2 = 75;
int total = marks1 + marks2;

System.out.println(total);

Output:

155

Here Java performs the calculation and displays the result.


Important Features of Java

1. Simple

Java syntax is relatively easy to learn.

2. Object-Oriented

Java is based on objects and classes.

3. Platform Independent

Java follows the concept:

Write Once, Run Anywhere

A Java program can run on different operating systems if the required Java environment is available.

4. Secure

Java provides several features that help in developing secure applications.

5. Robust

Java provides features such as exception handling and automatic memory management.

6. Multithreaded

Java supports execution of multiple threads.


2. Object-Oriented Programming (OOP)

What is OOP?

Object-Oriented Programming is a programming approach in which programs are designed around objects and classes.

Real-Life Example

Think about a Student.

A student has:

Data:

  • Name

  • Roll Number

  • Marks

Behaviour:

  • Study

  • AttendClass

  • GiveExam

In Java, we can represent this student using a class and object.


Class

A class is a blueprint or design from which objects are created.

Example

class Student
{
    String name;
    int marks;
}

Here Student is a class.


Object

An object is an instance of a class.

Example:

Student s1 = new Student();

Here s1 is an object of the Student class.

Easy Example

Think of:

Class = Building Plan

Object = Actual Building

One building plan can be used to create multiple buildings.

Similarly, one class can be used to create multiple objects.


3. Main Concepts of OOP

1. Encapsulation

Encapsulation means wrapping data and methods together into a single unit, usually a class.

Example:

class Student
{
    String name;

    void display()
    {
        System.out.println(name);
    }
}

Here data and method are combined inside the class.


2. Inheritance

Inheritance allows one class to acquire properties and methods of another class.

Example:

class Animal
{
    void eat()
    {
        System.out.println("Eating");
    }
}

class Dog extends Animal
{
    void bark()
    {
        System.out.println("Barking");
    }
}

Here Dog inherits the eat() method from Animal.


3. Polymorphism

Polymorphism means one name having different forms.

For example, a method can behave differently depending on the parameters supplied.


4. Abstraction

Abstraction means showing important details and hiding unnecessary implementation details.

Real-Life Example

When we use an ATM, we know:

  • Insert card

  • Enter PIN

  • Select amount

  • Withdraw money

We do not need to know the internal programming of the ATM.

That is an example of abstraction.


4. Java Language Elements

Java programs contain different language elements.

Important elements include:

  • Keywords

  • Identifiers

  • Literals

  • Variables

  • Data types

  • Operators

  • Separators


Keywords

Keywords are reserved words having special meaning in Java.

Examples:

class
int
if
else
while
for
public
static
void
new

We cannot normally use Java keywords as variable names.


Identifier

An identifier is the name given to:

  • Variable

  • Method

  • Class

  • Object

Example:

int marks;

Here marks is an identifier.

Rules for Identifiers

  • It can contain letters, digits, _ and $.

  • It cannot start with a digit.

  • It cannot contain spaces.

  • Java is case-sensitive.

  • Keywords cannot be used as identifiers.

Valid

student
studentName
marks1
_total

Invalid

1student
student name
class

5. Variables

A variable is a named memory location used to store data.

Example:

int age = 18;

Here:

  • int = data type

  • age = variable

  • 18 = value


6. Data Types in Java

Java data types are broadly divided into:

Primitive Data Types

Common primitive data types include:

Data TypeExample
bytebyte x = 10;
shortshort x = 100;
intint x = 500;
longlong x = 5000L;
floatfloat x = 10.5f;
doubledouble x = 10.55;
charchar grade = 'A';
booleanboolean pass = true;

7. Operators in Java

Operators are symbols used to perform operations on values.

1. Arithmetic Operators

+   Addition
-   Subtraction
*   Multiplication
/   Division
%   Modulus

Example:

int a = 10;
int b = 3;

System.out.println(a + b);
System.out.println(a % b);

Output:

13
1

2. Relational Operators

Relational operators compare two values.

> 
<
>=
<=
==
!=

Example:

int a = 10;
int b = 20;

System.out.println(a < b);

Output:

true

3. Logical Operators

Common logical operators:

&&   AND
||   OR
!    NOT

Example:

int age = 20;

if(age >= 18 && age <= 60)
{
    System.out.println("Eligible");
}

4. Assignment Operators

Examples:

=
+=
-=
*=
/=
%=

Example:

int x = 10;
x += 5;

Now x becomes:

15

5. Increment and Decrement Operators

++   Increment
--   Decrement

Example:

int x = 5;
x++;

Now:

x = 6

8. Control Flow

Control flow determines the order in which statements are executed.

Important control statements include:

  • if

  • if-else

  • else-if

  • switch

  • for

  • while

  • do-while


if Statement

The if statement executes a block when a condition is true.

Example:

int marks = 75;

if(marks >= 33)
{
    System.out.println("Pass");
}

Output:

Pass

if-else Statement

Example:

int marks = 25;

if(marks >= 33)
{
    System.out.println("Pass");
}
else
{
    System.out.println("Fail");
}

Output:

Fail

else-if

Used when there are multiple conditions.

Example:

int marks = 85;

if(marks >= 90)
{
    System.out.println("A+");
}
else if(marks >= 75)
{
    System.out.println("A");
}
else if(marks >= 60)
{
    System.out.println("B");
}
else
{
    System.out.println("C");
}

9. switch Statement

The switch statement is useful when we have multiple fixed choices.

Example:

int day = 2;

switch(day)
{
    case 1:
        System.out.println("Monday");
        break;

    case 2:
        System.out.println("Tuesday");
        break;

    default:
        System.out.println("Invalid Day");
}

Output:

Tuesday

10. Loops

Loops are used to repeat statements.

for Loop

Example:

for(int i = 1; i <= 5; i++)
{
    System.out.println(i);
}

Output:

1
2
3
4
5

while Loop

Example:

int i = 1;

while(i <= 5)
{
    System.out.println(i);
    i++;
}

do-while Loop

A do-while loop executes its body at least once.

Example:

int i = 1;

do
{
    System.out.println(i);
    i++;
}
while(i <= 5);

11. Array

What is an Array?

An array is a collection of elements of the same data type stored under one variable name.

Without Array

int m1 = 80;
int m2 = 75;
int m3 = 90;
int m4 = 65;

This becomes difficult when there are many marks.

With Array

int marks[] = {80, 75, 90, 65};

Now all marks are stored in one array.


Array Index

Java array indexing starts from 0.

For:

int marks[] = {80, 75, 90, 65};
IndexValue
080
175
290
365

Example:

System.out.println(marks[0]);

Output:

80

Traversing an Array

int marks[] = {80, 75, 90, 65};

for(int i = 0; i < marks.length; i++)
{
    System.out.println(marks[i]);
}

12. Class Design

A class is a blueprint that contains data and methods.

Example:

class Student
{
    String name;
    int marks;

    void display()
    {
        System.out.println(name);
        System.out.println(marks);
    }
}

Creating an object:

Student s = new Student();

s.name = "Rahul";
s.marks = 85;

s.display();

Output:

Rahul
85

Constructor

A constructor is a special method used to initialize an object.

Example:

class Student
{
    String name;

    Student()
    {
        name = "Rahul";
    }
}

Important point:

Constructor name is the same as the class name.


13. Exception Handling

What is an Exception?

An exception is an unwanted event that occurs during program execution and may disturb the normal flow of the program.

Example

int a = 10;
int b = 0;

System.out.println(a / b);

Division by zero can cause an exception.


Why Exception Handling?

Exception handling helps us handle runtime problems without allowing the program to terminate unexpectedly.

Important keywords include:

try
catch
finally
throw
throws

try-catch Example

try
{
    int a = 10;
    int b = 0;

    System.out.println(a / b);
}
catch(ArithmeticException e)
{
    System.out.println("Cannot divide by zero");
}

Output:

Cannot divide by zero

Easy Understanding

try → Put risky code here.

catch → Handle the exception here.


finally

The finally block is generally used for code that should execute after the try/catch processing.

Example:

try
{
    System.out.println("Try block");
}
catch(Exception e)
{
    System.out.println("Exception");
}
finally
{
    System.out.println("Finally block");
}

14. Assertions

An assertion is a statement used to check whether a particular condition is true during program execution.

Syntax:

assert condition;

Example:

int marks = 80;

assert marks >= 0;

Here the program checks whether marks >= 0 is true.

Easy Example

Suppose marks can only be between 0 and 100.

assert marks >= 0 && marks <= 100;

Assertions are mainly useful for detecting programming errors during development and testing.


15. Threads

What is a Thread?

A thread is a smallest unit of execution within a program.

Java supports multithreading, which means a program can perform multiple tasks concurrently.

Real-Life Example

Think about using a smartphone:

At the same time:

  • Music is playing.

  • A file is downloading.

  • Notifications are being received.

Different tasks can be handled concurrently.


Why Use Threads?

Threads can be useful when a program needs to perform multiple activities.

Examples:

  • Downloading a file

  • Playing music

  • Processing data

  • Handling user requests


16. Wrapper Classes

Java provides wrapper classes to represent primitive data types as objects.

Examples:

PrimitiveWrapper Class
intInteger
floatFloat
doubleDouble
charCharacter
booleanBoolean
byteByte
shortShort
longLong

Example

int x = 10;

Integer obj = x;

Here an int value is represented using the Integer wrapper class.


Why Wrapper Classes?

Wrapper classes are useful when an object is required instead of a primitive value.

They are also useful with Java collections and various utility methods.


17. String Manipulation

What is a String?

A String is a sequence of characters.

Example:

String name = "Rahul";

Here "Rahul" is a String.


Common String Methods

length()

Returns the number of characters.

String name = "Rahul";

System.out.println(name.length());

Output:

5

toUpperCase()

String name = "rahul";

System.out.println(name.toUpperCase());

Output:

RAHUL

toLowerCase()

String name = "RAHUL";

System.out.println(name.toLowerCase());

Output:

rahul

charAt()

Returns the character at a particular index.

String name = "Rahul";

System.out.println(name.charAt(0));

Output:

R

Remember: String indexing starts from 0.


equals()

Used to compare two Strings.

String a = "Java";
String b = "Java";

System.out.println(a.equals(b));

Output:

true

substring()

Used to obtain part of a String.

Example:

String name = "Computer";

System.out.println(name.substring(0, 4));

Output:

Comp

concat()

Used to join Strings.

String first = "Hello ";
String second = "Student";

System.out.println(first.concat(second));

Output:

Hello Student

18. Easy Java Program – Calculate Total and Average

class Student
{
    public static void main(String args[])
    {
        int m1 = 80;
        int m2 = 70;
        int m3 = 90;

        int total = m1 + m2 + m3;
        double average = total / 3.0;

        System.out.println("Total = " + total);
        System.out.println("Average = " + average);
    }
}

Output:

Total = 240
Average = 80.0

How the Program Works

  1. Three marks are stored.

  2. Marks are added.

  3. Total is calculated.

  4. Total is divided by 3.

  5. Result is displayed.


19. Easy Java Program – Check Even or Odd

class EvenOdd
{
    public static void main(String args[])
    {
        int n = 10;

        if(n % 2 == 0)
        {
            System.out.println("Even Number");
        }
        else
        {
            System.out.println("Odd Number");
        }
    }
}

Output:

Even Number

Logic

If the remainder after division by 2 is 0, the number is even.


20. Easy Java Program – Find Largest Number

class Largest
{
    public static void main(String args[])
    {
        int a = 20;
        int b = 35;
        int c = 15;

        if(a > b && a > c)
        {
            System.out.println("A is largest");
        }
        else if(b > a && b > c)
        {
            System.out.println("B is largest");
        }
        else
        {
            System.out.println("C is largest");
        }
    }
}

Output:

B is largest

21. Easy Java Program – Sum of Array Elements

class ArraySum
{
    public static void main(String args[])
    {
        int numbers[] = {10, 20, 30, 40, 50};
        int sum = 0;

        for(int i = 0; i < numbers.length; i++)
        {
            sum = sum + numbers[i];
        }

        System.out.println("Sum = " + sum);
    }
}

Output:

Sum = 150

22. Important Differences for Exam

Class vs Object

ClassObject
Blueprint/designInstance of class
Logical conceptReal entity
Used to create objectsCreated from a class
Example: StudentExample: s1

Primitive Data Type vs Wrapper Class

PrimitiveWrapper
Stores simple valueRepresents value as an object
Example: intExample: Integer
Generally more basicProvides object-oriented functionality

while vs do-while

whiledo-while
Condition checked firstBody executes first
May execute zero timesExecutes at least once
Syntax ends with conditionEnds with semicolon

try vs catch

trycatch
Contains code that may cause exceptionHandles the exception
Used for risky codeUsed for error handling

23. Important One-Mark Questions

Q1. What is Java?

Answer: Java is a high-level, object-oriented and platform-independent programming language.

Q2. What is a class?

Answer: A class is a blueprint or design from which objects are created.

Q3. What is an object?

Answer: An object is an instance of a class.

Q4. What is an array?

Answer: An array is a collection of elements of the same data type stored under one variable name.

Q5. From which index does a Java array start?

Answer: Java arrays start from index 0.

Q6. What is an exception?

Answer: An exception is an unwanted event that occurs during program execution and can disturb the normal flow of a program.

Q7. Name two keywords used in exception handling.

Answer: try and catch.

Q8. What is a thread?

Answer: A thread is a small unit of execution within a program.

Q9. What is a wrapper class?

Answer: A wrapper class represents a primitive data type as an object.

Q10. Give two examples of wrapper classes.

Answer: Integer and Double.


24. Important Short Answer Questions

Q1. Explain Object-Oriented Programming.

Answer: Object-Oriented Programming is a programming approach based on classes and objects. It helps organise programs into reusable and manageable units. Important OOP concepts include encapsulation, inheritance, polymorphism and abstraction.


Q2. What is encapsulation?

Answer: Encapsulation means combining data and methods into a single unit such as a class. It also helps control access to data.


Q3. What is inheritance?

Answer: Inheritance is the process by which one class acquires properties and methods of another class.


Q4. What is polymorphism?

Answer: Polymorphism means one name can have different forms or behaviours depending on the situation.


Q5. What is exception handling?

Answer: Exception handling is a mechanism used to handle runtime errors so that the normal flow of a program can be managed properly.


Q6. Explain the purpose of try and catch.

Answer: The try block contains code that may generate an exception, while the catch block contains code to handle that exception.


Q7. What is the purpose of an array?

Answer: An array stores multiple values of the same data type using a single variable name.


Q8. What is String manipulation?

Answer: String manipulation means performing operations on strings, such as finding length, changing case, comparing strings, extracting a substring and joining strings.


25. Important Long Answer Questions

Q1. Explain the main features of Java.

Answer:

The important features of Java are:

  1. Simple – Java is relatively easy to learn.

  2. Object-Oriented – Java programs are based on classes and objects.

  3. Platform Independent – Java programs can run on different platforms with the required Java environment.

  4. Secure – Java provides features that support secure application development.

  5. Robust – Java provides features such as exception handling and automatic memory management.

  6. Multithreaded – Java supports execution of multiple threads.


Q2. Explain the four important principles of OOP.

Answer:

1. Encapsulation

Combining data and methods into one unit.

2. Inheritance

Acquiring properties and methods from another class.

3. Polymorphism

One name can have different forms or behaviours.

4. Abstraction

Showing important information and hiding unnecessary implementation details.


Q3. Explain different types of control flow statements in Java.

Answer:

Control flow statements control the execution of a program.

Decision Statements

  • if

  • if-else

  • else-if

  • switch

Looping Statements

  • for

  • while

  • do-while

These statements allow a program to make decisions and repeat instructions.


Q4. Explain exception handling in Java with an example.

Answer:

Exception handling is used to handle runtime problems in a program.

Example:

try
{
    int a = 10;
    int b = 0;
    System.out.println(a / b);
}
catch(ArithmeticException e)
{
    System.out.println("Cannot divide by zero");
}

Here the risky statement is placed inside the try block and the exception is handled by the catch block.


26. Important Case-Based Questions

Case Study 1 – Student Marks

A school wants to store the marks of 5 students and calculate their total.

Questions

1. Which Java data structure can be used to store multiple marks of the same type?

Answer: Array

2. From which index does the array start?

Answer: 0

3. Which property can be used to find the number of elements in an array?

Answer: length


Case Study 2 – ATM Program

An ATM program performs division while calculating certain values. Sometimes the denominator may become zero.

Questions

1. What problem can occur?

Answer: ArithmeticException

2. Which block should contain the risky code?

Answer: try block

3. Which block handles the exception?

Answer: catch block


Case Study 3 – Student Class

A school software system needs to store student name and marks and display them.

Questions

1. What should be created to represent a student?

Answer: Class

2. What is an actual student object called in Java?

Answer: Object

3. Which keyword is commonly used to create an object?

Answer: new


27. Quick Revision Chart

TopicRemember
Java        High-level, object-oriented language
OOP        Programming using classes and objects
Class        Blueprint
Object        Instance of class
Encapsulation        Data + methods together
Inheritance        Acquiring properties from another class
Polymorphism        One name, different forms
Abstraction        Hide unnecessary details
Array        Collection of same type
Array Index        Starts from 0
Exception        Runtime problem/event
try        Risky code
catch        Handles exception
Thread        Unit of execution
Wrapper Class        Primitive represented as object
String        Sequence of characters
Assertion        Checks a condition during execution

28. Exam-Oriented Important Topics

For CBSE Class 12 IT (802), students should revise these areas carefully:

⭐ Java Basics

  • Features of Java

  • Variables

  • Data types

  • Keywords

  • Identifiers

⭐ OOP

  • Class

  • Object

  • Encapsulation

  • Inheritance

  • Polymorphism

  • Abstraction

⭐ Operators

  • Arithmetic

  • Relational

  • Logical

  • Assignment

  • Increment/Decrement

⭐ Control Flow

  • if

  • if-else

  • switch

  • for

  • while

  • do-while

⭐ Arrays

  • Declaration

  • Initialization

  • Indexing

  • Traversing

  • length

⭐ Exception Handling

  • Exception

  • try

  • catch

  • finally

  • throw

  • throws

⭐ Other Important Topics

  • Assertions

  • Threads

  • Wrapper Classes

  • String methods

  • Class and Object concepts


29. Easy Tips to Learn Java

Tip 1 – Understand the Logic First

Do not try to memorise every program. First understand:

Input → Processing → Output

Tip 2 – Practise Small Programs

Start with:

  • Even/Odd

  • Largest number

  • Sum

  • Average

  • Factorial

  • Array sum

  • String operations

Tip 3 – Remember Array Indexing

Always remember:

First element = index 0

Tip 4 – Practise Output Questions

CBSE-style questions may ask students to understand the output of a Java code segment.

Read the code line by line before selecting the answer.

Tip 5 – Learn Differences

Prepare differences such as:

  • Class vs Object

  • while vs do-while

  • Primitive vs Wrapper

  • try vs catch


30. CBSE Class 12 IT (802) – Unit 3 Final Revision

Before the examination, make sure you can answer:

✔ What is Java?
✔ What are the features of Java?
✔ What is OOP?
✔ Explain class and object.
✔ Explain encapsulation, inheritance, polymorphism and abstraction.
✔ What are Java language elements?
✔ Explain different operators.
✔ Explain control flow statements.
✔ What is an array?
✔ Explain class design.
✔ What is exception handling?
✔ Explain try, catch and finally.
✔ What are assertions?
✔ What is a thread?
✔ What are wrapper classes?
✔ What is String manipulation?
✔ Write simple Java programs using conditions, loops and arrays.


Conclusion

Java becomes much easier when students understand the logic behind the program instead of simply memorising code.

Start with basic Java elements, then learn operators and control flow. After that, practise arrays, classes and objects. Finally, revise exception handling, assertions, threads, wrapper classes and String manipulation.

For CBSE Class 12 Information Technology (802), regular practice of short Java programs, output-based questions, definitions, differences and case-based questions can help students build confidence in Unit 3.

Keep practising small programs — one program at a time!

Official CBSE Reference

The official CBSE 2026–27 curriculum lists Unit 3 – Fundamentals of Java Programming as a 20-mark unit and includes all the topics covered in these notes.

CBSE Class 12 IT (802) – Official 2026–27 Curriculum

CBSE Skill Education – Official Study Material

📚 Also Read - Important for 2026:
👉 Class 12 All Chapters Notes
👉 Class 11 Commerce Notes
🚀 Join CommerceWallah12 Family - Free Notes Daily!

▶️ YouTube: Subscribe Now - CommerceWallah12
📸 Instagram: Follow on Instagram
💬 WhatsApp Channel: Join WhatsApp Channel for MCQs
📱 Direct Help: 9664795023

Disclaimer: Ye notes NCERT & CBSE pattern par banaye gaye hai. Koi doubt ho to Contact Us par message karein.

Comments

Popular posts from this blog

CBSE Class 12 Business Studies: 50 MCQs with Answers | Chapters 1–4

CBSE Class 12 Accountancy Unit 1 Notes | Accounting for Partnership Firms

CBSE Class 12 Business Studies Chapter 2 Notes – Principles of Management