0% found this document useful (0 votes)
10 views3 pages

203 - Part - 3

Uploaded by

ahmedrssayeed821
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

203 - Part - 3

Uploaded by

ahmedrssayeed821
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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.

b. public int getTeamCount)


- the method should return the team Count attribute.

c. public void displayO


- inside the method, print the values of all three 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.a. Write short notes on the following.


i. Inheritance
ii. Encapsulation

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

Copy hoy na word catch hoy na tai pic add dilam -


b. Identify the errors in the code below and fix the errors. You are not allowed to delete any line
of code. You can only add new line or edit existing line.

You might also like