What is the result?

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?

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.



Leave a Reply 1

Your email address will not be published. Required fields are marked *


Fredy Jimenez Rendon

Fredy Jimenez Rendon

D) a Student don’t have a “year” field