You are on page 1of 3

Q1

A class 'Box' which contains method and other details(width, height, depth) to calculate
volume.

Another class ‘Boxweight’ contains method for finding cost for shipping the box using
weight of the box (formula to find cost of shipping= distance in km * volume * cost per
km)

Take cost per KM by the user.

WAP to find the volume of box and cost to ship using a single object

Q2

WAP to create a method to create a method named 'multiply' and overload it such that-

For 2 inputs, multiply of 2 numbers are done

For 3 inputs, multiply of 3 numbers are done

For other numbers, multiply them all

For multiple parameters (more than 3, pass array to the method)

Use cases-

(1)

(For more than 3 parameters)

Enter the number (Press * to stop): 5

Enter the number (Press * to stop): 10

Enter the number (Press * to stop): 3

Enter the number (Press * to stop): 4


Enter the number (Press * to stop): *

Method for multiple numbers called- (Result)- 600

(2)

(For 2 parameters)

Enter the number (Press * to stop): 5

Enter the number (Press * to stop): 10

Enter the number (Press * to stop): *

Method for Two numbers called- (Result)- 50

(3)

(For 3 parameters)

Enter the number (Press * to stop): 5

Enter the number (Press * to stop): 10

Enter the number (Press * to stop): 50

Enter the number (Press * to stop): *

Method for Two numbers called- (Result)- 2500


Q3

Shape is the super class for square and rectangle. Write a program to find areas of
square and rectangle by inheriting shape.

Method-find_Area() should be declared in shape. Parameters could be changed as per


needed.

Q4

Design a interface "Car" containing abstract methods- start(), stop() and running() along
with few member variables. Define another class "Toyota" which implements the
interface and use those methods as its own.

Q5

A class 'shape' contains a method 'about'.

Its subclass 'circle' also has method 'about' but different body.

Is it possible to create a object of circle but give its reference as shape? Demonstrate via
example and provide suitable output.

You might also like