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
}
}
-Which of the following could be used to instantiate a new Student s1?
A) Student s1 = new Student( ) ;
B) s1 = new Student( ) ;
C) Student s1 = new Student("Jane Doe", "Computer Science", 3.333, 33) ;
D) new Student s1 = ("Jane Doe", "Computer Science", 3.333, 33) ;
E) new Student(s1) ;
Correct Answer:

Verified
Correct Answer:
Verified
Q7: The following method header definition will result
Q43: Write the constructor for this class.
Q44: For the questions below, use the following
Q45: Consider a method defined with the header:
Q46: Write a statement to instantiate a cube
Q49: The expressions that are passed to a
Q50: Listener objects "wait" for an event to
Q51: Java methods can return only primitive types
Q52: Which of the following Applet methods is
Q53: Consider the "Push Me!" program described in