turn(); } When a client class constructs a why is it blue, facing north? ChameleonCritter It inherits the constructor from the class. Critter It inherits the constructor from the class. Actor It inherits the methods and from the class. getColor() getDirection() Actor The compiler adds the following code to the class: ChameleonCritter public ChameleonCritter() { super(); } which calls the default constructor from the class. Actor The compiler adds the following code to the class: ChameleonCritter public ChameleonCritter() { setColor(Color .BLUE); setDirection(Location.NORTH); } COMPUTER SCIENCE SECTION II Time—1 hour and 45 minutes Number of questions—4 Percent of total grade—50 Directions: SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN Java. Write your answers in pencil only in the booklet provided. Notes: Assume that the classes in the Quick Reference have been imported where needed. Unless otherwise stated, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied. In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods may not receive full credit. Pig Latin is a made-up language sometimes used by children. Here are the rules for converting an English word to Pig Latin. If the word begins with a consonant, move the consonant to the end of the word and add after it. If “ay” the word begins with a vowel, add to the end of the word. “yay” Examples: English Pig Latin dog ogday Apple Appleyay
turn(); } When a client class constructs a ChameleonCritter why is it blue, facing north? It inherits the constructor from the Critter class. It inherits the constructor from the Actor class. It inherits the methods getColor() and getDirection() from the Actor class. The compiler adds the following code to the ChameleonCritter class: public ChameleonCritter() { super(); } which calls the default constructor from the Actor class. The compiler adds the following code to the ChameleonCritter class: public ChameleonCritter() { setColor(Color .BLUE); setDirection(Location.NORTH); } COMPUTER SCIENCE SECTION II Time—1 hour and 45 minutes Number of questions—4 Percent of total grade—50 Directions: SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN Java. Write your answers in pencil only in the booklet provided. Notes: Assume that the classes in the Quick Reference have been imported where needed. Unless otherwise stated, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied. In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods may not receive full credit. Pig Latin is a made-up language sometimes used by children. Here are the rules for converting an English word to Pig Latin. If the word begins with a consonant, move the consonant to the end of the word and add “ay” after it. If the word begins with a vowel, add “yay” to the end of the word. Examples: English Pig Latin dog ogday Apple Appleyay
practice_exam_3.docx