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

Would this be considered constructor overloading for the Student class? public c

ID: 3597037 • Letter: W

Question

Would this be considered constructor overloading for the Student class?

public class Student {

private String firstName, lastName;

private Address home, school;

private int test1, test2, test3;

public Student() {

test1 = 0;

test2 = 0;

test3 = 0;

}

// constructor overloading the instances of the class

public Student(String first, String last, Address home, Address school, int test1,

int test2, int test3) {

this.firstName = first;

this.lastName = last;

this.home = home;

this.school = school;

this.test1 = test1;

this.test2 = test2;

this.test3 = test3;

}

public void setTestScore(int test, int score) {

if (test == 1) {

test1 = score;

} else if (test == 2) {

test2 = score;

} else if (test ==3) {

test3 = score;

} else {

System.out.println("You entered an invalid character. Your only options for test "

+ "scores are 1, 2, or 3.");

}

}

Explanation / Answer

Yes this can be considered as constructor overloading because there are two constructors with different parameters which is the concept of overloading

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote