Workbook 7.7
From the Java Bootcamp Resources
, launch Workbook 7.7
.
Task 1
Add a toString
method to the Person
class. Return a String
that follows this template:
"Name: " + <name field> + "\n" + "Nationality: " + <nationality field> + "\n" + "Date of Birth: " + <date of birth field> + "\n" + "Seat Number: " + <seat number field> + "\n" + "Passport: " + <toString of passport field> + "\n";
Task 2
Print your object. Java should internally call toString
and print its return value.
>>: Name: Rayan Slim >>: Nationality: Canadian >>: Date of Birth: 01/01/1111 >>: Seat Number: 5 >>: Passport: [Rayan Slim, Canadian, 01/01/1111]
Visualizing the Runtime
After you solve this workbook, I still recommend watching the video solution on Udemy.
It will show you how to visualize the runtime using Visual Studio Code.
Associated Course: The Complete Java Development Bootcamp
Related Course: The Complete Spring Boot Development Bootcamp – Become a Java Web Developer
Feedback Summary
4.7
43 students
5
91%
4
2%
3
0%
2
0%
1
7%
Written Reviews
There are no written reviews yet.