Java Notes – ICSE Class 10 (Full Marks Ready)
Object Oriented Programming (OOP) Concepts
Data Abstraction:
Showing only essential details to the user and hiding the internal implementation. Achieved
using abstract classes and interfaces.
Encapsulation:
Wrapping data and methods into a single unit (class). Data is protected using access
specifiers.
Inheritance:
Process by which one class acquires the properties of another class using the 'extends'
keyword.
Polymorphism:
Ability of a method to take many forms. Achieved using method overloading and method
overriding.
Access Specifiers
Specifier Same Class Same Package Subclass Outside
Package
private Yes No No No
default Yes Yes No No
protected Yes Yes Yes No
public Yes Yes Yes Yes
Primitive Data Types and Storage
byte – 1 byte
short – 2 bytes
int – 4 bytes
long – 8 bytes
float – 4 bytes
double – 8 bytes
char – 2 bytes
boolean – 1 bit
Loops in Java
for loop syntax:
for(initialization; condition; update)
while loop syntax:
while(condition)
do-while loop syntax:
do { } while(condition);
Sorting and Searching Algorithms
Bubble Sort:
for(int i=0;i<n-1;i++){
for(int j=0;j<n-1-i;j++){
if(a[j]>a[j+1]){
int t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}}}
Selection Sort:
for(int i=0;i<n-1;i++){
int min=i;
for(int j=i+1;j<n;j++){
if(a[j]<a[min])
min=j;
}
int t=a[i];
a[i]=a[min];
a[min]=t;
}
Linear Search:
for(int i=0;i<n;i++){
if(a[i]==key){
pos=i;
break;
}
}
Binary Search:
int l=0, u=n-1;
while(l<=u){
int m=(l+u)/2;
if(a[m]==key) break;
else if(key>a[m]) l=m+1;
else u=m-1;
}
Functions / Methods
Syntax:
returnType functionName(parameters){
statements;
return value;
}
Call by Value and Call by Reference
Call by Value:
Copy of variable is passed.
Example:
void change(int x){ x=10; }
Call by Reference:
Reference of object is passed.
Example:
void change(int a[]){ a[0]=10; }
Math Class Functions
[Link](x)
[Link](x)
[Link](x)
[Link](a,b)
[Link](a,b)
[Link](a,b)
[Link]()
[Link](x)
[Link](x)
[Link](x)
Return type: double (except round → long/int)
String Class Methods
length()
charAt(i)
substring(a,b)
equals(str)
equalsIgnoreCase(str)
compareTo(str)
indexOf(ch)
lastIndexOf(ch)
toUpperCase()
toLowerCase()
trim()
replace(a,b)
Character Class Methods
[Link](ch)
[Link](ch)
[Link](ch)
[Link](ch)
[Link](ch)
[Link](ch)
Exam Tip
Memorize definitions, method syntax, and practice writing programs by hand. ICSE checks
accuracy, not creativity.