You are on page 1of 1

1.

Apply the concept of class, object and method overloading to write a class to
overload a method num_calc() as follows:

a. void num_calc(int num, char ch) with one integer and one character argument. It
computes the square of an integer if choice is ‘s’ otherwise its cube.
b. void num_calc(int a, int b, char ch) with two integer and one character arguments.
It computes the product of integer arguments if ch is ‘p’ else adds the integers.
void num_calc(String str1, String str2) with two string arguments and prints if the two strings
are equal or not.

2. Apply the concept of class, object and method overloading to write a class to
overload a method generate() as follows:

a. void generate(int num, char ch) with one integer and one character argument. It
computes the cube of an integer if choice is ‘t’ otherwise its square
b. void generate(int x, int y, char ch) with two integer and one character arguments.
It computes the sum of integer arguments if ch is ‘s’ else product the integers.
void generate(String str1, String str2) with two string arguments and prints if the two strings
are equal or not.

3. Write a program to calculate bike rent of parking based on the following information:

No. of hours Parking Charges

First 4 hours Rs. 10 for four hours

Next 5-7 hours Rs. 5 per hour

Next 8-10 hours Rs. 4 per hour

Above 10 hours Rs. 3 per hour

You might also like