203 - Part - 3
203 - Part - 3
1. a. Define a class and name it as "ICPCCoach". Add the following inside the class.
i. Declare 3 instance variables name, country, team Count
ii. Add a parameterized constructor which will take 3 parameters. Inside the constructor
initializes the attributes with the parameters passed to the constructor.
iii. Add the following methods.
2
1
a. public void promoteTeam(String teamName)
- Inside the method, increase the team Count by I and print "team Name under name has been
promoted for Final contest." Here team Name is the value of the parameter passed to the method
whereas team Count and name are the values of respective attributes.
1.b. Define a class and name it as "ICPCContest". Declare the main method inside the class.
Inside the main, do the following.
i. Create an object of ICPCCoach class with name=your name, country = "Bangladesh",
and team Count =2. Store the reference of the object to coach variable. ii. Call the
promoteTcam(...) method using the coach variable and pass "UAP Fighter"
as the parameter of the method.
ii. Call the display method using the coach variable.
What is the output of this method?
OR
2.a. Define a class named Rectangle" Add the following inside the class.
. Declare 2 private instance variables length and width.
. Add a parameterized constructor which will take 2 parameters. Inside the constructor
initialises the attributes with the parameters passed to the constructor.
3. Add the following methods.
a. public double get/ren()
- Inside the method, calculate the area of the rectangle and return the area.
b. public void display)
- inside the method, print the value of all three attributes.
c. Add getter/setter method for the 2 attributes.
2.b. Define a class named Box and make it the subclass of Rectangle (Q#2.a.) class. Add
an additional attribute height to this subclass. Add a parameterized constructor which will take 3
parameters for length, width and height. Inside the constructor, initialize the attributes in proper
way. Add a method "public double getVolumeO" and return the volume of the box from the
method.
3.b. Write a java program that will take 3 integers as input and print the square of the
highest number among these 3 numbers.
4.a. What will be output of the code below? Explain the steps for output calculation in details