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: Which of the following patterns should be used in place of "xxxx" when instantiating df so that the gpa to be output is in typical form (like 3.810) ?
A) "#.###"
B) "#.0"
C) "0.#"
D) "0.000"
E) "0.0##"
Correct Answer:

Verified
Correct Answer:
Verified
Q8: The behavior of an object is defined
Q9: Given the method defined here, which of
Q10: Class Definition Ch 04-4<br>public class Box<br>{<br>double length;<br>double
Q12: A constructor may contain a return statement
Q14: When reasoning about a car, we use
Q15: A GUI control sets up an event
Q16: Consider a sequence of method invocations as
Q17: To define a class that will represent
Q18: An object should be encapsulated in order
Q19: Formal parameters are those that appear in