ICSE Class 10 Java – Full Notes (13
Topics)
This document covers all 13 ICSE Java topics in a detailed explanatory style. Each topic
includes theory, example programs, expected ICSE-style programs, and a checkpoint
summary.
1. OOP Concepts
Object Oriented Programming (OOP) organizes programs using classes and objects. It is
based on 4 pillars:
1. Encapsulation – data hiding and combining variables + methods.
2. Inheritance – child class inherits parent class.
3. Polymorphism – one name, many forms.
4. Abstraction – hide details, show essentials.
Example: Class and Object
class Student {
int roll;
String name;
void setData(int r, String n) {
roll = r;
name = n;
}
void showData() {
System.out.println("Roll: " + roll + ", Name: " + name);
}
}
class Test {
public static void main() {
Student s = new Student();
s.setData(1, "Arnav");
s.showData();
}
}
✅ Checkpoint 1: OOP = Class + Object + Encapsulation + Inheritance + Polymorphism +
Abstraction.
1
Made By Arnav K
2. Value and Datatypes
Java supports two categories:
- Primitive: int, double, char, boolean, byte, short, long, float.
- Non-primitive: String, Arrays, Classes.
class DataTypes {
public static void main() {
int age = 14;
double marks = 89.5;
char grade = 'A';
boolean pass = true;
System.out.println("Age: " + age);
System.out.println("Marks: " + marks);
System.out.println("Grade: " + grade);
System.out.println("Pass: " + pass);
}
}
✅ Checkpoint 2: Primitive types store simple values, non-primitives are objects.
3. Operators in Java
Operators are symbols that perform operations.
- Arithmetic: + - * / %
- Relational: < > <= >= == !=
- Logical: && || !
- Assignment: = += -=
- Increment/Decrement: ++ --
- Ternary: ? :
class Operators {
public static void main() {
int a = 10, b = 3;
System.out.println("a+b=" + (a+b));
System.out.println("a%b=" + (a%b));
System.out.println("a>b=" + (a>b));
boolean x=true, y=false;
System.out.println("x||y = " + (x||y)); // true
}
2
Made By Arnav K
}
✅ Checkpoint 3: Remember `||` means true if any condition is true.
4. Scanner Class
Scanner is used to take user input.
import java.util.Scanner;
class InputExample {
public static void main() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter name: ");
String name = sc.next();
System.out.print("Enter marks: ");
int marks = sc.nextInt();
System.out.println(name + " scored " + marks);
}
}
✅ Checkpoint 4: Use nextInt(), nextDouble(), next(), nextLine().
5. Math Library Methods
Math provides ready methods for calculations.
class MathDemo {
public static void main() {
System.out.println(Math.sqrt(25)); // 5.0
System.out.println(Math.pow(2,3)); // 8.0
System.out.println(Math.abs(-9)); // 9
System.out.println(Math.round(5.6)); // 6 (returns long)
System.out.println(Math.random()); // 0-1
}
}
✅ Checkpoint 5: Most return double, but round() can return long/int.
6. Condition in Java
Conditions let us branch logic: if, if-else, if-else-if, nested if, switch.
3
Made By Arnav K
class IfElseDemo {
public static void main() {
int n=5;
if(n%2==0) System.out.println("Even");
else System.out.println("Odd");
}
}
class SwitchDemo {
public static void main() {
int day=2;
switch(day) {
case 1: System.out.println("Sunday"); break;
case 2: System.out.println("Monday"); break;
default: System.out.println("Other");
}
}
}
✅ Checkpoint 6: `if` handles conditions, `switch` is better for fixed values.
7. Iterative Construct
Loops repeat code. Types: while, do-while, for. break exits, continue skips.
class LoopDemo {
public static void main() {
for(int i=1;i<=5;i++) {
if(i==3) continue;
System.out.println(i);
}
}
}
Expected Program: Reverse digits of a number.
class ReverseNumber {
public static void main() {
int num=1234, rev=0;
while(num>0) {
int d=num%10;
rev=rev*10+d;
4
Made By Arnav K
num/=10;
}
System.out.println("Reversed: "+rev);
}
}
✅ Checkpoint 7: while = 0 or more times, do-while = at least once, for = compact.
8. Nested Loops
Used for grids and patterns.
class Pattern {
public static void main() {
for(int i=1;i<=3;i++) {
for(int j=1;j<=i;j++) {
System.out.print("* ");
}
System.out.println();
}
}
}
✅ Checkpoint 8: Nested loops build tables/patterns.
9. Methods
Methods organize code. Types: args+return, args no return, no args return, no args no
return. Overloading = same name, diff. parameters.
class MethodTypes {
public static int add(int a,int b){ return a+b; }
public static void greet(){ System.out.println("Hello!"); }
public static void main() {
System.out.println("Sum="+add(4,5));
greet();
}
}
✅ Checkpoint 9: Methods = reusable code blocks. Overloading = polymorphism.
5
Made By Arnav K
10. Constructors
Constructors initialize objects. Types: Default, Parameterized, Overloaded.
class Car {
String brand; int price;
Car(){ brand="Unknown"; price=0; }
Car(String b,int p){ brand=b; price=p; }
public static void main() {
Car c1=new Car();
Car c2=new Car("BMW",5000000);
}
}
✅ Checkpoint 10: If only parameterized is written, default is not created.
11. Library Classes
Library classes are predefined: Math, Integer, Character, Double.
class LibraryDemo {
public static void main() {
double x=Math.sqrt(25);
int y=Integer.parseInt("123");
boolean b=Character.isUpperCase('A');
System.out.println(x+","+y+","+b);
}
}
✅ Checkpoint 11: Library classes come ready-made.
12. Strings
String is an object. Important methods: length(), charAt(), substring(), indexOf(), equals(),
compareTo().
class ReverseString {
public static void main() {
String s="BlueJ",rev="";
for(int i=s.length()-1;i>=0;i--)
rev+=s.charAt(i);
System.out.println("Reversed="+rev);
6
Made By Arnav K
}
}
class Palindrome {
public static void main() {
String s="level",rev="";
for(int i=s.length()-1;i>=0;i--)
rev+=s.charAt(i);
if(s.equals(rev)) System.out.println("Palindrome");
else System.out.println("Not palindrome");
}
}
✅ Checkpoint 12: Strings = objects. Last index = length-1. Use equals() not ==.
13. Arrays
Arrays store multiple values. 1D arrays store lists, 2D arrays store matrices.
class ArraySum {
public static void main() {
int[] arr={10,20,30};
int sum=0;
for(int x:arr) sum+=x;
System.out.println("Sum="+sum);
}
}
class MatrixAdd {
public static void main() {
int[][] a={{1,2},{3,4}}, b={{5,6},{7,8}}, c=new int[2][2];
for(int i=0;i<2;i++) {
for(int j=0;j<2;j++) {
c[i][j]=a[i][j]+b[i][j];
System.out.print(c[i][j]+" ");
}
System.out.println();
}
}
}
✅ Checkpoint 13: Arrays are fixed-size. Programs include sum, max, search, sort, matrix ops.
7
Made By Arnav K