Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

s1.toString();
s1 = getClassRank();
String s = s1.getClassRank();
getClassRank(s1);
s1.getHours();

s1.getClassRank();

3.

What type of variable is name?

formal parameter
actual parameter
instance data
none of the above

local variable

4.

What type of variable is newGPA?

formal parameter
none of the above
instance data
actual parameter

local variable

5.

What type of variable is s?

none of the above
actual parameter
formal parameter
instance data
local variable

6.

Which statements would print a text representation of s1 to the console? Select all that apply.

System.out.print(s1.toString);
System.out.print(s1);
s1.toString();

System.out.print(String.to(s1));

7.

Another method that might be added is one to modify a student's name. The next three questions ask about this method.

According to convention, what would be the best name for such a method?

updateName
changeName
setStudentName
setName
getName

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

More Books

Students also viewed these Databases questions

Question

3. Explain the forces that influence how people handle conflict

Answered: 1 week ago