Multiple Choice
Class Definition Ch 04-1
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()
{
// xxxx needs to be replaced
DecimalFormat df = new DecimalFormat("xxxx") ; return name + "\n" + major + "\n" + df.format(gpa)
+ "\n" + hours
}
}
-Refer to Class Definition Ch 04-1: 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(sq) ;
Correct Answer:

Verified
Correct Answer:
Verified
Q43: Class Definition Ch04-2<br>The following is from a
Q44: Visibility modifiers include<br>A) public, private<br>B) public, private,
Q45: The expressions that are passed to a
Q46: An example of passing a message to
Q47: Defining formal parameters requires including each parameter's
Q48: Which of the following is not a
Q50: Java methods can return more than one
Q51: The relationship between a class and an
Q52: Write a portion of a class named
Q53: All Java classes must contain a main