Question: For the next three problems, consider the following class: Also consider the following partial implementation of a subclass of Student to represent undergraduate students at

For the next three problems, consider the following class:

1 // Represents a university student. 2 public class Student { 3. private String name; private int age; 9. public Student (String name, int age) { 7 this.name name; 8. this.age = age; } 10 11 public void setAge (int age) { 12 this.age = age; 13 14

Also consider the following partial implementation of a subclass of Student to represent undergraduate students at a university:

1 // Represents a university student. 2 public class Student { 3.

Can the code in the UndergraduateStudent class access the name and age fields it inherits from Student ? Can it call the setAge method?

1 // Represents a university student. 2 public class Student { 3. private String name; private int age; 9. public Student (String name, int age) { 7 this.name name; 8. this.age = age; } 10 11 public void setAge (int age) { 12 this.age = age; 13 14

Step by Step Solution

3.45 Rating (174 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The class Student has instance variables name and age ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!