ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2024 ICSE Computer Science Paper



Share with a Friend

Solved 2024 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Method Overloading Program - ICSE 2024 Computer Science

Question 4
Define a class to overload the method perform() as follows:
double perform(double r, double h) – to calculate and return the value of curved surface area of cone.

void perform(int r, int c) – use nested for loop to generate the following format:


r = 4, c = 5

Output:


1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

void perform(int m, int n, char ch) – to print the quotient of the division of m and n if ch is Q else print the remainder of the division of m and n if ch is R.

class Overload{ public double perform(double r, double h){ double l = Math.sqrt(r * r + h * h); double csa = Math.PI * r * l; return csa; } public void perform(int r, int c){ for(int i = 1; i <= r; i++){ for(int j = 1; j <= 5; j++){ System.out.print(j + " "); } System.out.println(); } } public void perform(int m, int n, char ch){ if(ch == 'Q') System.out.println("Quotient: " + (m / n)); else if(ch == 'R') System.out.println("Remainder: " + (m % n)); } }

Output

 
 OUTPUT 1: 
 

 OUTPUT 2: