Quiz
Final Exam Computer Science Module 6
Fragen in diesem Quiz (3)
1Take a look at the below class specification and details of the student class. Which of the below methods represents a mutator method.
Fields:
* double GPA
* String name
Contructor:
*Student ()
Methods:
* int getName()
* void setName( String newName )
* void resetGPA(): // sets GPA to 0.0- AresetGPA
- BThere are no mutator methods
- CsetName
- DBoth resetGPA and setName are mutator methods
- EgetName
2What do accessor methods do?
- AAllow client code to add new class fields
- BAllow client code to access the values of class fields only
- CAllow the client to convert the class fields from public to private
- DAllow client code to modify the current values of the class fields
3Take a look at the below implementation of the Student class. Let's say you would like to a getter method. Which of the below choices would be considered a valid "getter" method?
punlic class Student {
private double GPA;
private String name;
public Student() {}
public String getName() {
return name;
}
public void setName(String newName) {
name = newName;
}
public void resetGPA() {
GPA= 0;
}
}- Apublic double getGPA() {
return this.GPA; - Bpublic void getGPA() {
System.out.printIn(this.GPA);
} - Cpublic void getGPA() {
return this.GPA; - Dpublic double getGPA() {
this.GPA = GPA;
}
- Apublic double getGPA() {
Informationen
- Beschreibung
- Quiz am Final Exam Computer Science Module 6, erstellt von Christopher Castillo am 20/08/2024.
- Autor
- Christopher Castillo
- Sprache
- English
- Aufrufe
- 0
- Schlagwörter
- Bewertung
- Noch keine Bewertungen Bewerte dieses Quiz