ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2025 ICSE Computer Science Paper



Share with a Friend

Solved 2025 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Menu Driven Program - Overload Method - ICSE 2025 Computer Science

Question 8
Define a class to overload the method display() as follows:


void display(): To print the following format using nested loop.

1 2 1 2 1
1 2 1 2 1
1 2 1 2 1

void display(int n, int m): To print the quotient of the division of m and n if m is greater than n otherwise print the sum of twice n and thrice m.

double display(double a, double b, double c): to print the value of z where z = p × q
p = (a + b) / c
q = a + b + c

 

class Overload{ public static void display(){ for(int i = 1; i <= 3; i++){ int value = 1; for(int j = 1; j <= 5; j++){ System.out.print(value + " "); if(value == 1) value = 2; else value = 1; } System.out.println(); } } public static void display(int n, int m){ if(m > n){ int q = m / n; System.out.println("Quotient = " + q); } else{ int sum = 2 * n + 3 * m; System.out.println("Sum = " + sum); } } public static double display(double a, double b, double c){ double p = (a + b) / c; double q = a + b + c; double z = p * q; System.out.println("z = " + z); return z; } }

Output