0% found this document useful (0 votes)
35 views7 pages

ICSE Class10 Java Notes Detailed

This document provides detailed notes on 13 essential Java topics for ICSE Class 10, including OOP concepts, data types, operators, and more. Each topic features explanations, example programs, and highlights of weak points for better understanding. The document serves as a comprehensive guide for students to grasp key Java programming concepts and practices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views7 pages

ICSE Class10 Java Notes Detailed

This document provides detailed notes on 13 essential Java topics for ICSE Class 10, including OOP concepts, data types, operators, and more. Each topic features explanations, example programs, and highlights of weak points for better understanding. The document serves as a comprehensive guide for students to grasp key Java programming concepts and practices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

ICSE Class 10 Java – Detailed Notes (13

Topics)
This document contains a detailed mix of theory and programs, written in the same style as
our chat. Each topic includes explanations, key points, example programs, and where
relevant, weak points are highlighted for extra attention.

1. OOP Concepts
Object Oriented Programming is built on 4 main pillars:
1. Encapsulation – wrapping data and methods together, data hiding.
2. Inheritance – child class acquires features of parent.
3. Polymorphism – same name, different forms (overloading/overriding).
4. Abstraction – hiding unnecessary details.

In Java, everything revolves around classes and objects. A class is like a blueprint and an
object is an instance created from that class.

class Student {
int roll;
String name;

void setData(int r, String n) {


roll = r;
name = n;
}

void showData() {
System.out.println("Roll: " + roll);
System.out.println("Name: " + name);
}
}

class Test {
public static void main() {
Student s = new Student(); // object creation
s.setData(10, "Arnav");
s.showData();
}
}
Expected Program: Define a class with instance variables and methods, then create an
object in main to call those methods.

2. Value and Datatypes


Java has two categories of data types:
- Primitive: int, double, char, boolean, byte, short, long, float.
- Non-primitive: String, Arrays, Objects.

Primitives store simple values. Non-primitives are objects and have methods.

class DataTypes {
public static void main() {
int age = 15;
double marks = 92.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);
}
}

3. Operators in Java
Operators are special symbols used to 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));

boolean x = true, y = false;


System.out.println("x || y : " + (x || y)); // Weak Point
explained
}
}

4. Scanner Class
Scanner is used for user input. Methods include nextInt(), nextDouble(), next(), nextLine().

import java.util.Scanner;

class InputExample {
public static void main() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter your name: ");
String name = sc.next();
System.out.print("Enter age: ");
int age = sc.nextInt();
System.out.println("Hello " + name + ", age " + age);
}
}

5. Math Library Methods


Math is a built-in class for mathematical functions.
Important methods: sqrt(x), pow(a,b), abs(x), max(a,b), min(a,b), ceil(x), floor(x), round(x),
random().

class MathDemo {
public static void main() {
System.out.println("Sqrt 25 = " + Math.sqrt(25)); // double
System.out.println("Pow 2^3 = " + Math.pow(2,3));
System.out.println("Round 5.6 = " + Math.round(5.6)); // Weak
Point: returns long
System.out.println("Random = " + Math.random());
}
}

6. Conditions in Java
Conditions let us make decisions in code. Options: if, if-else, if-else-if ladder, nested if,
switch-case, ternary.
class ConditionDemo {
public static void main() {
int n = 7;
if (n % 2 == 0)
System.out.println("Even");
else
System.out.println("Odd");
}
}

7. Iterative Construct
Loops repeat code. Types: while, do-while, for.
- while: checks before running.
- do-while: runs at least once.
- for: compact.
break exits, continue skips current iteration.

class LoopDemo {
public static void main() {
for (int i = 1; i <= 5; i++) {
if (i == 3) continue;
System.out.println(i);
}
}
}

8. Nested Loops
Nested loops are loops inside loops, useful for patterns and matrices.

class NestedLoop {
public static void main() {
for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= 3; j++) {
System.out.print(i + "," + j + " ");
}
System.out.println();
}
}
}
9. Methods
Methods group code into reusable blocks.
Types: no args no return, args no return, no args with return, args with return.
Static methods can be called without objects. Overloading = same name with different
parameters.

class MethodTypes {
int add(int a, int b) { return a + b; }
void greet() { System.out.println("Hello!"); }

public static void main() {


MethodTypes obj = new MethodTypes();
System.out.println("Sum = " + obj.add(3,4));
obj.greet();
}
}

10. Constructors
Constructors initialize objects. They share the class name, have no return type.
Types: Default, Parameterized, Overloaded.
⚠ Weak Point: If only parameterized constructor exists, Java will NOT provide a default one.

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(); // default
Car c2 = new Car("BMW", 5000000); // parameterized
}
}

11. Library Classes


Java provides predefined classes with methods. Examples:
- Math.sqrt(), Math.pow()
- Integer.parseInt()
- Character.isDigit(), Character.isLetter()
- Double.parseDouble()
12. Strings
Strings are objects. Important methods: length(), charAt(), substring(), indexOf(), equals(),
compareTo().
⚠ Weak Point: last index = length-1. ⚠ Weak Point: Count vowels using "aeiou".indexOf(ch)
!= -1.

class ReverseString {
public static void main() {
String s = "BlueJ";
String rev = "";
for (int i = s.length()-1; i >= 0; i--) {
rev += s.charAt(i);
}
System.out.println("Reversed: " + rev);
}
}

class CountVowels {
public static void main() {
String s = "Education";
s = s.toLowerCase();
int count = 0;
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if ("aeiou".indexOf(ch) != -1)
count++;
}
System.out.println("Vowels: " + count);
}
}

13. Arrays
Arrays hold multiple values. 1D arrays store a list, 2D arrays store tables.
Common programs: sum, max, search, sort, transpose.

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);
}
}

Expected programs:
- Reverse digits using while loop
- Find max/min in an array
- Matrix addition and transpose
- String palindrome check
- Switch-case menu program

You might also like