Question1: Where are instance data variables declared? c.outside of the class d.
ID: 3881701 • Letter: Q
Question
Question1:
Where are instance data variables declared?
c.outside of the class
d.it depends on the problem you are solving
Question 2:
Consider the code fragments below:
Student s = new Student(...);
int n = 4;
What is stored in memory at the location of the variable s?
b. none of the above
c. the information that describes a student
question 3:
Question 191 pts
Consider the code fragments below:
Student s = new Student(...);
int n = 4;
What is stored in memory at the location of the variable n?
c. the value 4
Question 4:
Write a class header for a class that would represent a car.
---------------------------------------------------------------------------------
For the next 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 + " " + major + " " + gpa + " " + hours;
return s;
}}
Quesiont 5:
Another method that might be added is one to access a student's major. It is defined as:
public String getMajor()
What statement should be placed inside this method?
Question 6:
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?
e. changeName
Question 7:
By convention, what would be the return type of the method?
d. Student
Question 8:
What would be the parameter(s) for the method?
Explanation / Answer
Question1:
Answer:
b.inside the class but outside of all methods
Question2
Answer:
a. a memory location to somewhere else in memory
Question3
Answer:
c. the value 4
Question4
Answer:
public class Car {
}
Questio5
Answer:
public String getMajor() {
return major;
}
Question6
Answer:
c. setName
Question7
Answer:
c.void
Question8
Answer:
d. String name
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.