Presentation is loading. Please wait.

Presentation is loading. Please wait.

Clicker quiz 10/1/13 CSE 1102 Fall 2013. 1. public class Sun extends Ellipse { 2. public Sun(Color c) { 3. super(c); 4. … 5. } 6. public Sun() { 7. this(Color.yellow);

Similar presentations


Presentation on theme: "Clicker quiz 10/1/13 CSE 1102 Fall 2013. 1. public class Sun extends Ellipse { 2. public Sun(Color c) { 3. super(c); 4. … 5. } 6. public Sun() { 7. this(Color.yellow);"— Presentation transcript:

1 Clicker quiz 10/1/13 CSE 1102 Fall 2013

2 1. public class Sun extends Ellipse { 2. public Sun(Color c) { 3. super(c); 4. … 5. } 6. public Sun() { 7. this(Color.yellow); 8. } 9.… 10. } The above code illustrates what recipe? A.Default value B.Accessors and mutators C.Parts that know about their containers D.Sharing the interface E.Invisible sun

3 1.public class Sun extends Ellipse { 2. private Color _myColor; 3. public Sun(Color c) { 4. super(c); 5. _myColor = c;; 6. } 7. public Color getColor(){ 8. return _myColor; 9. } 10. public void setColor(Color col){ 11. _myColor = col; 12. } 13. } The above code illustrates what recipe? A.Default value B.Accessors and mutators C.Parts that know about their containers D.Sharing the interface E.Here comes the sun

4 Suppose _tweety is declared to be a Bird (as above). Given this diagram the actual type of _tweety can be A.Bird B.Bird, Crow, or Duck C.Bird or Animal D.Bird, Crow, Duck, or Animal public class Forest { Bird _tweety; … }

5 Using only the information in this diagram, if we want to be able to make the assignment sporty = new Car(3); sporty would have been declared a A.Car B.Car or Vehicle C.Car or PeopleMover D.Car, Vehicle, or PeopleMover

6 Clicker questions 10/1/13 CSE 1102 Fall 2013

7 1.public class { 2. … 3. private _ ; 4. 5. public (…) { 6. … 7. _part = new (this); 8. … 9. } 10.… 11. } In the above code, to what does this in line 7 refer? A.A constructor for B.A constructor for C._part D.An instance of E.An instance of 1.public class Hat { 2. … 3. private HatPart _myHatPart; 4. 5. public Hat() { 6. … 7. _myHatPart = new HatPart(this); 8. … 9. } 10.… 11. } A. A constructor for Hat B. A constructor for HatPart C. _myHatPart D. An instance of Hat E. An instance of HatPart

8 Given the above diagram, which line of code is not legal? A.Vehicle oily = new OilTanker(200); B.Car frank = new Car(); C.PeopleMover pm = new Car(3); D.OilTanker oily = new Truck(42); E.More than two of these are not legal

9 In the code above, after robyn gets instantiated, which methods can be invoked on robyn? (i.e. robyn.???) A.holdPeople, tootHorn, carryCargo, and move B.holdPeople, tootHorn, and move C.holdPeople and move D.carryCargo and move E.carryCargo only … Vehicle robyn; robyn = new Car(200); …

10 In the code above, which move method gets executed? A.The move method defined in OilTanker B.The move method defined in Truck C.The move method defined in Vehicle D.All of the above E.The code does not work … Truck oily = new OilTanker(200); … oily.move();


Download ppt "Clicker quiz 10/1/13 CSE 1102 Fall 2013. 1. public class Sun extends Ellipse { 2. public Sun(Color c) { 3. super(c); 4. … 5. } 6. public Sun() { 7. this(Color.yellow);"

Similar presentations


Ads by Google