Free Exam: APCS Ch. 5
Number of Questions in Test: 10
Number of Questions in Preview: 5
Register to view all questions.
Note: Answers are not shown below but will be copied with this test.
Copy this test to my quiz maker account
Register with ClassMarker to copy free tests to give to your Test takers.
Register nowQuestion 1
For the Student class defined below, which of the following statements is true regarding constructors, accessor methods, and mutator methods?
public class Student
{ private String fname;
private String lName;
private Strind id;
private double gpa;
public Student()
{ fName =lName = id = "";
gpa = 0.0;
}
public Student (String first, String last, String idNumber, double gradePointAvg)
{ fName = first;
lName = last;
id = idNumber;
gpa = gradePointAvg;
}
public double getGPA()
{ return gpa;}
public voide setGPA (double newGPA)
{ gpa = newGPA;}
public class Student
{ private String fname;
private String lName;
private Strind id;
private double gpa;
public Student()
{ fName =lName = id = "";
gpa = 0.0;
}
public Student (String first, String last, String idNumber, double gradePointAvg)
{ fName = first;
lName = last;
id = idNumber;
gpa = gradePointAvg;
}
public double getGPA()
{ return gpa;}
public voide setGPA (double newGPA)
{ gpa = newGPA;}
Type: | Multiple choice |
Points: | 1 |
Randomize answers: | Yes |
Question 2
What is the purpose of a constructor method?
Type: | Multiple choice |
Points: | 1 |
Randomize answers: | Yes |
Question 3
Below is the BaseballPlayer class definition. How many methods are there?
BaseballPlayer()
BaseballPlayer(String aName, String aTeam)
setHomeRuns(int nHomeRuns)
setBattingAverage(double nBattingAverage)
getRating()
toString()
BaseballPlayer()
BaseballPlayer(String aName, String aTeam)
setHomeRuns(int nHomeRuns)
setBattingAverage(double nBattingAverage)
getRating()
toString()
Type: | Multiple choice |
Points: | 1 |
Randomize answers: | Yes |
Question 4
Given two initialized String variables, str1 and str2, which of the following expressions correctly tests whether the value of str1 is equivalent to str2?
Type: | Multiple choice |
Points: | 1 |
Randomize answers: | Yes |
Question 5
What is the mechanism whereby the data of an object is hidden from clients?
Type: | Multiple choice |
Points: | 1 |
Randomize answers: | Yes |