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

1,In class Student, method equals() (Ch 8->Student.java), why a reference to Obj

ID: 3919462 • Letter: 1

Question

1,In class Student, method equals() (Ch 8->Student.java), why a reference to Object is passed as a parameter instead of a reference to Student? Note that class Object also has a method equals() that has as a parameter a reference to Object.

To allow the method to be overridden in derived classes for polymorphic purposes

To allow the method to be overloaded in derived classes for polymorphic purposes

Both a and b

None listed

2,In class Student, (Ch8->Student.java) what statement indicates that the class may be a derived class?

public Student (String initialName, int initialStudentNumber)

public class Student extends Person

private int studentNumber;

public Student()

3,In class Student, method equals() (Ch 8->Student.java), why a reference to Object is passed as a parameter instead of a reference to Student? Note that class Object also has a method equals() that has as a parameter a reference to Object.

To allow the method to be overridden in derived classes for polymorphic purposes

To allow the method to be overloaded in derived classes for polymorphic purposes

Both a and b

4,In class Student, (Student.java) how many statements invoke the base constructor(s)?

None listed

=======================================

To allow the method to be overridden in derived classes for polymorphic purposes

To allow the method to be overloaded in derived classes for polymorphic purposes

Both a and b

None listed

2,In class Student, (Ch8->Student.java) what statement indicates that the class may be a derived class?

public Student (String initialName, int initialStudentNumber)

public class Student extends Person

private int studentNumber;

public Student()

3,In class Student, method equals() (Ch 8->Student.java), why a reference to Object is passed as a parameter instead of a reference to Student? Note that class Object also has a method equals() that has as a parameter a reference to Object.

To allow the method to be overridden in derived classes for polymorphic purposes

To allow the method to be overloaded in derived classes for polymorphic purposes

Both a and b

4,In class Student, (Student.java) how many statements invoke the base constructor(s)?

None listed

  public class Student extends Person  {      private int studentNumber;        public Student( )      {          super( );          studentNumber = 0;//Indicating no number yet      }        public Student(String initialName, int initialStudentNumber)      {          super(initialName);          studentNumber = initialStudentNumber;      }        public void reset(String newName, int newStudentNumber)      {          setName(newName);          studentNumber = newStudentNumber;      }        public int getStudentNumber( )      {          return studentNumber;      }        public void setStudentNumber(int newStudentNumber)      {          studentNumber = newStudentNumber;      }        public void writeOutput( )      {          System.out.println("Name: " + getName( ));          System.out.println("Student Number: " + studentNumber);      }        public boolean equals(Student otherStudent)      {          return this.hasSameName(otherStudent) &&                (this.studentNumber == otherStudent.studentNumber);      }          public String toString( )      {          return "Name: " + getName( ) +                             " Student number: "  + studentNumber;      }     /* //For Optional Section      public boolean equals(Object otherObject)      {          if (otherObject == null)              return false;          else if (!(otherObject instanceof Student))              return false;          else          {              Student otherStudent = (Student)otherObject;              return (this.sameName(otherStudent)                  && (this.studentNumber ==                                  otherStudent.studentNumber));          }      }  */    }

=======================================

Explanation / Answer

Ans:1

To allow the method to be overloaded in derived classes for polymorphic purposes

Ans:2

public class Student extends Person

Ans:3

To allow the method to be overloaded in derived classes for polymorphic purposes.

Ans:4

There are 2 statement which are invoking base constructor.

========================================================

Kindly Check and Verify Thanks..!!!