{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Unit 2 Quiz

# Unit 2 Quiz - Unit 2 Quiz 1 Consider the following...

This preview shows pages 1–3. Sign up to view the full content.

Unit 2 Quiz 1 Consider the following circumstances for a bug. I. The bug has a flower immediately in front of it. II. The bug has a rock immediately in front of it. III. The bug has a wall (grid boundary) immediately in front of it. In which of these situations will the bug's canMove() method return false? Choose one answer. a. I only b. II only c. III only d. I and II only e. II and III only 2 Which of the following best describes how a bug turns when its turn() method is called? Choose one answer. a. 45 degrees to the left b. 45 degrees to the right c. 90 degrees to the left d. 90 degrees to the right e. 45 degrees randomly to the left or right 3 The reason there is no move method in BoxBug is... Choose one answer. a. A BoxBug never moves b. The move method is inherited from Actor c. The move method is inherited from BoxBug d. The move method is inherited from Bug e. The move method is hard-coded 4 Consider replacing the following code from BoxBug: if (steps < sideLength && canMove()) with this code: if (steps%sideLength != 0 && canMove()) How would this affect the boxbug's behavior? Choose one answer . a. The boxbug never turns, it continues in a straight line

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
b. The boxbug turns once after drawing one side, then continues in a straight line c. There is no change in the boxbug pattern d. The boxbug never moves, it only turns e. The boxbug now makes a pattern like a Z 5 Consider the following MysteryBug that extends Bug. The code for MysteryBug is exactly
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern