Section 3 - Quiz 2 L6-L10 (Answer all questions in this section) 1.In Greenfoot a collision is when 2 actors touch?
Mark for Review (1) Points
True (*) False Correct 2.Which actor method is used to detect a simple collision?
Mark for Review (1) Points
hasCollided() hasTouched() isCollision() isInContactWith() isTouching() (*) Incorrect. Refer to Section 3 Lesson 6. 3.In Greenfoot, a way to have all subclasses of a superclass inherit a method is by adding the method to the superclass. True or false?
Mark for Review (1) Points
True (*) False Correct 4.In Greenfoot, the sound file must be saved in the scenario and written in the source code for it to play. True or false?
Mark for Review (1) Points
True (*) False Correct 5.In Greenfoot when you use the method to retrieve input from the user, the scenario will continue to run in the background?
Mark for Review (1) Points
True
False (*) Correct 6.In Greenfoot, you can only interact with the scenario using a keyboard.
Mark for Review (1) Points
True False (*) Incorrect. Refer to Section 3 Lesson 7. 7. In Greenfoot, the == operator is used to test if two values are equal. True or false?
Mark for Review (1) Points
True (*) False Correct 8. The GreenfootImage class enables Greenfoot actors to maintain their visible image by holding an object of type GreenfootImage. True or false?
Mark for Review (1) Points
True (*) False Correct 9. In Greenfoot, which method is used to end a game?
Mark for Review (1) Points
Duke.stop( ); Game.stop(1); Greenfoot.stop( ); (*) Class.stop( ); Correct
10. In Greenfoot, you can cast an Actor class to a World class?
Mark for Review (1) Points
True False (*) Incorrect. Refer to Section 3 Lesson 9. 11.From your Greenfoot lessons, which one of the following is an example of when an abstraction technique is used?
Mark for Review (1) Points
Adding a property to an instance Initialising a variable Passing a paramater in a constructor to set an initial speed. (*) Adding a property to a Class Incorrect. Refer to Section 3 Lesson 9. 12. In Greenfoot modifying an actors constructor to accept an initial speed is a form of abstraction?
Mark for Review (1) Points
True (*) False Correct 13. From your Greenfoot lessons, when do infinite loops occur?
Mark for Review (1) Points
When the end to the code isn't established. (*) Only in while loops. When the loop is executed.
When the end to the act method isn't established. Incorrect. Refer to Section 3 Lesson 10. 14. In Greenfoot, when is a local variable most often used?
Mark for Review (1) Points
Within the world constructor Within the act method Within the scenario Within loop constructs (*) Incorrect. Refer to Section 3 Lesson 10. 15. In Greenfoot, what type of symbol is used to connect boolean expressions?
Mark for Review (1) Points
Logic operators (*) Keyboard key names Integers String concatenation 1. Use your Greenfoo t knowledg e to answer the question. One reason to write a defined method in a class is to make it easier to read. True or false?
Mark for Review (1) Points
True (*) False Correct
2. Which one of the following can be used to detect when 2 actors collide?
Mark for Review (1) Points
isCollision() isTouching() (*) hasCollided() isContact() Incorrect. Refer to Section 3 Lesson 6. 3. From your Greenfoot lessons, to save space in the act method, you can write an entirely new method below it, called a _____________.
Mark for Review (1) Points
Instance method Defined method (*) Class method World method Code method Incorrect. Refer to Section 3 Lesson 6. 4. In Greenfoot you can interact with the scenario using a mouse.
Mark for Review (1) Points
True (*) False Correct 5. You cannot record unique sounds in Greenfoot. You can only use the sounds that are stored in the Greenfoot library. True or false?
Mark for Review (1) Points
True False (*) Correct 6. In Greenfoot , what type of paramete
Mark for Review (1) Points
r does the isKeyDow n method expect? String (*) Boolean Method Integer Correct 7. Which of the following answers have the correct syntax for declaring a class variable in Greenfoot?
Mark for Review (1) Points
(Choose all correct answers) public variable-name variable type; public variable-type variable-name; (*) private variable-type variable-name; (*) private variable-name, variable-type; Correct 8. In Greenfoot, which method body correctly adds an instance of the World to a scenario, with size x = 300 y = 300 and a resolution of 2 pixels per cell?
Mark for Review (1) Points
world(300, 300, 2); super(2,300,300); super(300,300,2); (*) Super(300,300,2); Incorrect. Refer to Section 3 Lesson 8. 9. In Greenfoot, a constructor has a void return type. True or false?
Mark for Review (1) Points
True False (*) Incorrect. Refer to Section 3 Lesson 8.
10. From your Greenfoot lessons, which one of the following is an example of when an abstraction technique is used?
Mark for Review (1) Points
Adding a property to an instance Initialising a variable Adding a property to a Class Passing a paramater in a constructor to set an initial speed. (*) Incorrect. Refer to Section 3 Lesson 9. 11. In Java what is casting ?
Mark for Review (1) Points Casting is when we remove an object from the world Casting is when we want to tell the java compiler that a class we are accessing is really another type of class (*) Casting is when we reset the state of an instance. Casting is when we change the coordinates of an actor Correct
12. From your Greenfoot lessons, abstraction techniques can only be used once in a class's source code. True or false?
Mark for Review (1) Points
True False (*) Correct 13. If an end to a while loop is not established, what happens?
Mark for Review (1) Points
The condition becomes false after one minute of executions. The code executes and does not stop. (*) The code stops after 10 executions. The code stops after 20 executions. Correct 14. In Greenfoot, what is a common letter used for the loop variable?
Mark for
Review (1) Points A X I (*) Y Incorrect. Refer to Section 3 Lesson 10. 15. Which of the following is an example of string concatenation?
Mark for Review (1) Points
Instead of entering ".png" after each image file name, add && ".png" after the imageName value in the programming statement. Instead of entering ".png" after each image file name, add ".png" after the imageName value in the programming statement. Instead of entering ".png" after each image file name, add + ".png" after the imageName value in the programming statement. (*) Instead of entering ".png" after each image file name, add = ".png" after the imageName value in the programming statement. Correct 1. In Greenfoo t, a way to have all subclasse s of a superclas s inherit a method is by adding the method to the superclas s. True or false?
Mark for Review (1) Points
True (*) False Correct 2. Which actor method is used to detect a simple collision?
Mark for Review (1) Points
hasTouched() isInContactWith() isTouching() (*) isCollision() hasCollided() Correct 3. To execute a method in your Greenfoot game, where is it called from?
Mark for Review (1) Points
The act method (*) The gallery The actor class The world Correct 4. In Greenfoot, what type of parameter does the isKeyDown method expect?
Mark for Review (1) Points
Boolean Integer Method String (*) Correct 5. Which method is used to play sound in your Greenfoot game?
Mark for Review (1) Points
importSound method playSound method (*) getSound method findSound method Correct
6. From your Greenfoo t lessons, the isKeyDow n method is located in which class?
Mark for Review (1) Points
World Actor Greenfoot (*) GreenfootImage Correct 7. Using the Greenfoot IDE, when is a constructor automatically executed?
Mark for Review (1) Points
When a new image is added to the class. When the act method is executed. When source code is written. When a new instance of the class is created. (*) Correct 8. In Greenfoot, actor constructors can be used to create images or values and assign them to the variables. True or false?
Mark for Review (1) Points
True (*) False Correct 9. In Greenfoot, constructors can be used to create new instances of objects. True or false?
Mark for Review (1) Points
True (*) False Correct
10. Abstraction occurs in many different ways in programming. True or false?
Mark for Review (1) Points
True (*) False Correct 11. In Greenfoo t, you will never have to cast as we only ever use 2 classes - World and Actor.
Mark for Review (1) Points
True False (*) Incorrect. Refer to Section 3 Lesson 9. 12. In Greenfoot, you can cast an Actor class to a World class?
Mark for Review (1) Points
True False (*) Correct 13. In Greenfoot, what happens if the end to a while loop isn't established?
Mark for Review (1) Points
The code will keep executing and will never stop. (*) The code will prompt you to enter a loop counter. The code will not execute. The code will execute once and then stop, due to controls in Greenfoot. Incorrect. Refer to Section 3 Lesson 10.
14. In Greenfoot, string concatenation reduces the number of redundant characters or phrases you need to type into each array. True or false?
Mark for Review (1) Points
True (*) False Incorrect. Refer to Section 3 Lesson 10. 15. In Greenfoot, arrays are a way to hold and access multiple variables, and assign different values to new instances each time the while loop executes and produces a new instance. True or false?
True (*) False Correct
Mark for Review (1) Points