Given the following code, the correct code to replace the \"missing code\" comme
ID: 3859790 • Letter: G
Question
Given the following code, the correct code to replace the "missing code" comment is: public class Address{ private String street: private String city: private String state: private String zip: public Address(String road, String town, String st, String zipCode) { street - road: city = town: state = st: zip = zipCode: } public String tostring() { return (street + ", " + city + ", " + state + " " +zip): } public class Person { private String lastName: private String firstName: private Address home: public Person(String last, String first, Address residence) { lastName = last: firstName = first: home = residence: } public String toString() { //Chose the missing code } } return(firstName + "" + lastName + ", " +home) retum(firstName + + lastName + ", " +home.toString()): firstName + " " + lastName + ", " +home.toString(): return firstName.printString() + lastName.printString() + home.printString();Explanation / Answer
Missing Code:return(firstName+" "+lastName+","+home.toString());
Explanation: The method should return the string represention of the person. So we call toString method on the Address object to concatenate with the firstName and lastName of person
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.