Question: Question 8 Next three (3) questions are based on the following java code: import java.text.DecimalFormat; public class Student { private String name; private double GPA;

Question 8

Next three (3) questions are based on the following java code:

import java.text.DecimalFormat;

public class Student

{

private String name;

private double GPA;

public Student(String newName, double newGPA)

{

name = newName;

GPA = newGPA;

}

public double getGPA()

{

return GPA;

}

public String toString( )

{

DecimalFormat df = new DecimalFormat("0.00");

return (Name: + name.toUpperCase() + " | GPA: + df.format(GPA)) ;

}

}

Question: In a driver class, which of the following could be used to instantiate a new Student s1?

A.

Student s1 = new Student("Jane Doe", 3.3333);

B.

new Student(s1);

C.

new Student s1 = ("Jane Doe", 3.3333);

D.

Student s1 = new Student( );

10 points

Which of the following will be printed out using the statement System.out.println(s1) in the driver class? s1 is the Student object created in previous question.

A.

Name: JANE DOE | GPA: 3.33

B.

Jane Doe, 3.3333

C.

Name: Jane Doe | GPA: 3.33

D.

The address of s1.

10 points

Given that s1 is a student created in a driver class, which of the following would properly be used in the driver class to get s1's GPA?

A.

double s1_GPA=s1.getGPA( );

B.

double s1_GPA=getGPA();

C.

double s1_GPA=s1.GPA;

D.

double s1_GPA=getGPA(s1);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!