For the questions below, use the following class definition.
import java.text.DecimalFormat;
public class Student
{
private String name;
private String major;
private double gpa;
private int hours;
public Student(String newName, String newMajor, double newGPA, int newHours)
{
name = newName;
major = newMajor;
gpa = newGPA;
hours = newHours;
}
public String toString( )
{
DecimalFormat df = new DecimalFormat("xxxx") ; // xxxx needs to be replaced
return name + "\n" + major + "\n" + df.format(gpa) + "\n" + hours
}
}
-Assume that another method has been defined that will compute and return the student's class rank (Freshman, Sophomore, etc) . It is defined as: public String getClassRank( )
Given that s1 is a student, which of the following would properly be used to get s1's class rank?
A) s1 = getClassRank( ) ;
B) s1.toString( ) ;
C) s1.getHours( ) ;
D) s1.getClassRank( ) ;
E) getClassRank(s1) ;
Correct Answer:
Verified
Q12: For the questions below, use the following
Q13: To define a class that will represent
Q14: Consider a method defined with the header:
Q16: Instance data for a Java class
A) are
Q16: The relationship between a class and an
Q17: For the questions below, use the following
Q19: Which of the following Applet methods is
Q21: A variable whose scope is restricted to
Q28: If a method does not have a
Q37: Consider a sequence of method invocations as
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents