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
Q18: Java methods can only return primitive types.
Q19: A method defined in a class can
Q20: The following method header definition will result
Q21: A variable whose scope is restricted to
Q22: The software failure at the Denver International
Q24: In a UML diagram for a class
A)
Q25: Consider a Rational class designed to represent
Q26: Class Definition Ch 04-1
import java.text.DecimalFormat;
public class Student
{
private
Q27: Instance data for a Java class
A) are
Q28: If a method does not have a
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