View the exhibit:
public class Student {
public String name = "";
public int age = 0;
public String major = "Undeclared";
public boolean fulltime = true;
public void display() {
System.out.println("Name: " + name + " Major: " + major); }
public boolean isFullTime() {
return fulltime;
}
Given:
Public class TestStudent {
public static void main(String[] args) {
Student bob = new Student ();
bob.name = "Bob";
bob.age = 18;
bob.year = 1982;
}
What is the result?
A.
year is set to 1982.
B.
bob.year is set to 1982
C.
A runtime error is generated.
D.
A compile time error is generated.
how comes it doesn’t compile is it because when name is initialized doesn’t have
default value or is it something else
E correct. Class Student does not has member year 🙂