Ask Question
10 April, 07:41

Consider the following class definition.

public class Person {

private String name; / * missing constructor * /

}

The statement below, which is located in a method in a different class, creates a new Person object with its attribute name initialized to "Washington". Person p = new Person ("Washington");

Which of the following can be used to replace / * missing constructor * / so that the object p is correctly created?

A)

private Person ()

{

name = n;

}

B)

private Person (String n)

{

name = n;

}

C)

public Person ()

{

name = n;

}

D)

public Person (String n)

{

name = n;

}

E)

public Person (String name)

{

String n = name;

}

+1
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Consider the following class definition. public class Person { private String name; / * missing constructor * / } The statement below, ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers