0% found this document useful (0 votes)
0 views5 pages

ICSE Class9 Java Practice Updated

The document provides an overview of Java programming concepts for ICSE Class 9, including basic syntax and sample programs. It covers topics such as input/output, conditional statements, loops, and includes practice programs like adding numbers, checking even/odd, and calculating factorials. Additionally, it lists extra practice questions for further learning.

Uploaded by

Call Back
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views5 pages

ICSE Class9 Java Practice Updated

The document provides an overview of Java programming concepts for ICSE Class 9, including basic syntax and sample programs. It covers topics such as input/output, conditional statements, loops, and includes practice programs like adding numbers, checking even/odd, and calculating factorials. Additionally, it lists extra practice questions for further learning.

Uploaded by

Call Back
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

ICSE Class 9 Java Practice Programs

1. Java Programming - Introduction

Java is a high-level, object-oriented programming language used in ICSE for creating


structured and modular programs.
In Class 9, you will learn the basics like variables, input/output, conditional
statements, loops, and simple programs.
All codes are based on BlueJ IDE which supports Java.

2. Hello World Program

public class HelloWorld {


public static void main(String[] args) {
System.out.println("Hello, ICSE Class 9!");
}
}

3. Add Two Numbers

import java.util.Scanner;
public class AddNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter first number: ");
int a = sc.nextInt();
System.out.print("Enter second number: ");
int b = sc.nextInt();
int sum = a + b;
System.out.println("Sum = " + sum);
}
}

4. Check Even or Odd

import java.util.Scanner;
public class EvenOdd {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
int n = sc.nextInt();
if (n % 2 == 0)
System.out.println(n + " is Even");
else
System.out.println(n + " is Odd");
}
}

5. Multiplication Table
ICSE Class 9 Java Practice Programs

import java.util.Scanner;
public class MultiplicationTable {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
int num = sc.nextInt();
for (int i = 1; i <= 10; i++) {
System.out.println(num + " x " + i + " = " + (num * i));
}
}
}

6. Factorial of a Number

import java.util.Scanner;
public class Factorial {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
int n = sc.nextInt();
int fact = 1;
for (int i = 1; i <= n; i++) {
fact = fact * i;
}
System.out.println("Factorial of " + n + " is " + fact);
}
}

7. Check Leap Year

import java.util.Scanner;
public class LeapYear {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a year: ");
int year = sc.nextInt();
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
System.out.println("Leap Year");
else
System.out.println("Not a Leap Year");
}
}

8. ICSE Style Sample Question

Q. Write a program to input a number and check whether it is a prime number.

Sample Input: 7
Sample Output: Prime number
ICSE Class 9 Java Practice Programs

9. Extra Practice Questions (Without Solution)

1. Write a program to find the largest of three numbers.


2. Write a program to input marks and print grade.
3. Write a program to print all even numbers between 1 to 50.
4. Write a program to check if a number is a palindrome.
5. Write a program to calculate the sum of digits of a number.

You might also like