Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Pick the best possible choice. Which of the following constructors specified for

ID: 3726131 • Letter: P

Question

Pick the best possible choice. Which of the following constructors specified for the Person class may be correctly used to create an object as follows:

Person person1 = new Person( x, y);

where x is a string variable and y is an int variable.

public Person(int age, String name )

{

this.age = age;

this.name =name;

}

public Person(){

this.age = x;

this.name = y;

}

public Person(x, y){

this.age = x;

this.name = y;

}

public Person(String name, int age){

this.x = name;

this.y = age;

}

A)

public Person(int age, String name )

{

this.age = age;

this.name =name;

}

B)

public Person(){

this.age = x;

this.name = y;

}

C)

public Person(x, y){

this.age = x;

this.name = y;

}

D)

public Person(String name, int age){

this.x = name;

this.y = age;

}

Explanation / Answer

D)

public Person(String name, int age){

this.x = name;

this.y = age;

}

_______________

As the first parameter is String and the Second parameter is int this constructor perfectly matches.

______________Thank you