ITEC 2610 Lecture Notes - Lecture 9: James Gosling, Instance Variable

124 views13 pages

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();

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents