package DoctorWho; class TimeTraveller { static int age; public String name; pro
ID: 3725317 • Letter: P
Question
package DoctorWho;
class TimeTraveller
{
static int age;
public String name;
protected char gender;
}
package DoctorWho;
public class Doctor extends TimeTraveller
{
private int number;
protected String companion;
String uniqueItem;
}
package DoctorWho;
public class TVShow
{
Doctor Who = new Doctor();
}
Given the code above, what variables in the instantiated Doctor object can be accessed without mutators or accessors? and why?
age
name
gender
number
companion
uniqueItem
package DoctorWho;
class TimeTraveller
{
static int age;
public String name;
protected char gender;
}
package DoctorWho;
public class Doctor extends TimeTraveller
{
private int number;
protected String companion;
String uniqueItem;
}
package DoctorWho;
public class TVShow
{
Doctor Who = new Doctor();
}
Given the code above, what variables in the instantiated Doctor object can be accessed without mutators or accessors? and why?
Answers:age
name
gender
number
companion
uniqueItem
Explanation / Answer
ANswer:
age,name,gender,companion,uniqueitem all of these variable can be instantiated using the Doctor object Who and number cannot be instantiated because number is declared as private and it cannot be instantiated outside of the class.age,name,gender can be instantiated because the Timetraveller class is extended by the Doctor class.
age,name,gender,companion,uniqueitem all of these variable can be instantiated using the Doctor object Who and number cannot be instantiated because number is declared as private and it cannot be instantiated outside of the class.age,name,gender can be instantiated because the Timetraveller class is extended by the Doctor class.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.