Question
For the next seven questions, use the following class: public class Student { private String name; private String major; private double gpa; private int hours;
For the next seven questions, use the following class:
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() {
String s = name + "\t" + major + "\t" + gpa + "\t" + hours;
return s;
}}
1.
Which of the following could be used to instantiate a new Student s1? Select all that apply.
s1 = new Student(); |
new Student s1 = ("Jane Doe", "Computer Science", 3.333, 33); |
Student s1 = new Student(); |
new Student(s1); |
Student s1 = new Student("Jane Doe", "Computer Science", 3.333, 33);
2. Assume that another method has been defined that will compute and return the students class rank (Freshman, Sophomore, etc). It is defined as public String getClassRank() Given that s1 is a Student, which of the following would properly be used to get s1s class rank? Select all that apply.
|
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started