Solved

For the Questions Below, Use the Following Class Definition

Question 44

Multiple Choice

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
}
}
-Another method that might be desired is one that updates the Student's number of credit hours. This method will receive a number of credit hours and add these to the Student's current hours. Which of the following methods would accomplish this?


A) public int updateHours( ) { return hours; }
B) public void updateHours( ) { hours++; }
C) public updateHours(int moreHours) { hours += moreHours; }
D) public void updateHours(int moreHours) { hours += moreHours; }
E) public int updateHours(int moreHours) { return hours + moreHours; }

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions