Use the following class for the next questions. Which of the following could be
ID: 3746163 • Letter: U
Question
Use the following class for the next questions.
Which of the following could be used to instantiate a new Person p? Select all that apply.
A) new Person p = ("Carla Doe", "789 Broad Street", 26);
c)new Person(p);
D) p = new Person();
E) Person p = new Person("John Smith", "123 Main Street", 42);
F) Person p = new Person();
Assume that another method has been defined that will return the a person's phone number. The method header is:
If p is an object of type Person, which of the following are correct statements to obtain p's phone number? Select all that apply.
p.getPhoneNumber();
Which of the following could be used to invoke the vote method on a Person object p? Select all that apply.
A) new Person p = ("Carla Doe", "789 Broad Street", 26);
Explanation / Answer
1.
Here we can pass the String String and int data.
Person p = new Person("Janet Jones", "456 Orange Avenue", 16.5);
Person p = new Person("John Smith", "123 Main Street", 42);
Option B and E correct choice.
2.
String s = p.getPhoneNumber(); // Here s stores the phone number
p.getPhoneNumber(); // this method receive the phone number
Option E and F correct choice.
3.
Person.vote();
Option B and E correct choice.
p.vote();Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.