Question: Question 1 a) You will write two classes in this question. The first class is the athlete class. An athlete has three attributes: first name,
Question 1
a) You will write two classes in this question. The first class is the athlete class. An athlete has three attributes: first name, last name, and sport. The athlete class will have a toString method that prints out the three items with labels on three separate lines. You will also write the Olympian class. You will need to determine the correct relationship between the two classes. An Olympian also has a: country, year (the year they participated in the Olympics), and city (location of that years Olympics). The toString of the Olympian will use the parents version and add their additional attributes with appropriate labels on separate lines. Please write the two classes.
b) What does the code below print out and why?
public void whoHoo(int a, String b, Object c)
{
a = 15;
b += just in case
c.set(123);
}
public static void main(String) args)
{
int sum = 12;
String name = Yes, ;
Object obj = new Object(111);
whoHoo(sum, name, obj);
System.out.print(sum + + name + + obj);
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
