ITEC 2610 Lecture Notes - Lecture 9: James Gosling, Instance Variable
Document Summary
4 this program shows a simple quiz with two choice questions. 29 presents a question to the user and checks the response. Answer: the method is not allowed to access the instance variable text from the superclass. public class choicequestion public void display() System. out. println(text); for (int i = 0; i < choices. size(); i++) int choicenumber = i + 1; Answer: the type of the this reference is choicequestion. Choicequestion is selected, and the method calls itself. public class choicequestion public void display() this. display(); for (int i = 0; i < choices. size(); i++) int choicenumber = i + 1; Look again at the implementation of the addchoice method that calls the setanswer method of the superclass. In the manager class of self check 7, override the getname method so that managers have a * before their name (such as *lin, sally). Answer: public string getname() return * + super. getname();