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: 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) getClassRank(sq) ;public int updateHours(int moreHours)
{ return hours + moreHours; }
Correct Answer:

Verified
Correct Answer:
Verified
Q31: Class Definition Ch 04-1<br>import java.text.DecimalFormat;<br>public class Student<br>{<br> private
Q32: Because an Image cannot directly be added
Q33: Class Definition Ch 04-4<br>public class Box<br>{<br>double length;<br>double
Q34: If a method does not have a
Q35: While multiple objects of the same class
Q37: Class Definition Ch 04-4<br>public class Box<br>{<br>double length;<br>double
Q38: Instance data for a Java class<br>A) are
Q39: Class Definition Ch 04-3<br>Consider a class called
Q40: Regarding the software failure described at the
Q41: Class Definition Ch 04-3<br>Consider a class called