<h2>
Question:</h2>
<em>Which XXX declares a student's name. </em>
public class Student {
XXX
private double myGPA;
private int myID;
public int getID() {
return myID;
}
}
<em>Group of answer choices </em>
a. String myName;
b. public String myName;
c. private myName;
d. private String myName;
<h2>
Answer:</h2>
private String myName;
<h2>
Explanation:</h2>
To declare a student's name, the following should be noted.
i. The name of the student is of type <em>String</em>
ii. Since all of the instance variables (myGPA and myID) have a <em>private</em> access modifier, then myName (which is the variable name used to declare the student's name) should be no exception. In other words, the student's name should also have a <em>private</em> access.
Therefore, XXX which declares a student's name should be written as
<em>private String myName;</em>
<em></em>
Option (a) would have been a correct option if it had the <em>private</em> keyword
Option (b) is not the correct option because it has a <em>public</em> access rather than a <em>private</em> access.
Option (c) is not a valid syntax since, although it has a <em>private</em> access, the data type of the variable <em>myName</em> is not specified.
Option (d) is the correct option.