Sunteți pe pagina 1din 9

MIDTERM

1. Examine the following code. What are the variables?





args

n (*)

i (*)

t


2. In Java, which symbol is used to assign one value to another?

<

>

= (*)

//


3. Alice uses built-in math operators; they are:

Add and subtract

Multiply and divide

All of the above (*)

None of the above



4. In Alice, functions are dragged into the control statement, not the procedure. True or false?
True False (*)


5. From your Alice lessons, where should comments be placed?

Above each set of programming statements. (*)

At the end of the program.

In the scene editor.

In their own procedure.



6. An Alice object can move in four directions. True or false?

True False (*)

7. From your Alice lessons, comments do not affect the functionality or behavior of objects. True or
false?
True (*) False

8. In Alice, inheritance means that the superclass inherits its traits from the subclass. True or false?
True False (*)

9. In Alice, declaring a new procedure to shorten code and make it easier to read is a procedural
abstraction technique. True or false

True (*) False


10. In Alice, a person object inherits its procedures, functions, and properties from which of the
following classes
Object subclass

Biped class (*)

Quadruped class

Person subclass (*)

11. A scenario gives the Alice animation a purpose. True or false
True (*) False

12. From your Alice lessons, random numbers are set in the distance and duration arguments in a
procedure. True or false
True (*) False


13. In Alice, which of the following instructions turn the Blue Tang fish right one half of a meter?

this.blueTang turn Right 5

this.blueTang turn Right 0.5 (*)

blueTang turn Right 5

blueTang turn Right 0.5

14. The move procedure moves an object in how many different possible directions

1

4

3

6 (*)

15. A loop can be infinite (continue forever) or conditional (stops upon a condition). True or false?
True (*) False

16. In Alice, we use the While control statement to implement the conditional loop. True or false?
True (*) False

17. A conditional loop is a loop that will continue forever. True or false?
True False (*)

18. The value that a variable holds must be a whole number, not a decimal. True or false?
True False (*)

19. From your Alice lessons, what can be used as a guideline to ensure your animation fulfills
animation principles
The Internet

Animation checklist (*)

A close friend

None of the above

20. An Alice event is considered what?

A party with at least 20 people

An object's orientation

Error handling

A keystroke or mouse click (*)
21. Besides invoking a procedure, another way to precisely position an Alice object is to enter
values in the x, y, and z coordinates in the Position property. True or false
True (*) False


22. From your Alice lessons, what is a one-shot procedural method?

A procedure that is invoked when the Run button is clicked.

A procedure that is used to make a scene adjustment. (*)

A procedure that is dragged into the code editor.

A procedure that is used to launch the program.

23. From your Alice lessons, how do you add an instance to a scene in Alice?
Select the instance from your computer's network.

Write code that places the instance in the scene.

Select the class, then drag the object into the scene. (*)

Call the addObject method.

24. When you want specific code to be executed only if certain conditions are met, what type of
Java construct would you use
while loop

if (*)

array

boolean


25. What do lines 7, 10 and 13 do in the following code?



Export files called A, B, and num3.

Create a single file containing A, B, and the value of num3.

Print "A", "B" and the value of num3 on the screen. (*)

None of the above.


26. From your Greenfoot lessons, abstraction techniques can only be used once in a class's source
code. True or false?
True False (*)

27. From your Greenfoot lessons, which of the following are examples of abstraction?

Playing a range of sounds when keyboard keys are pressed. (*)

A single instance displays a single image.

Assigning a different keyboard key to each instance. (*)

Programming a single movement for a single instance.

Assigning a different image file to each instance. (*)

28. In Greenfoot, a constructor has a void return type. True or false
True False (*)

29. From your Greenfoot lessons, what is the parameter of the following constructor that creates a
new image, and designates it to the Actor class?

setImage (new GreenfootImage("duke100.png

setImage

GreenfootImage

duke100.png (*)

new


30. Use your Greenfoot knowledge to answer the question: Where are defined variables typically
entered in a class's source code
In the defined method in the source code.

Between the constructors and methods in the source code.

After the constructors and methods in the source code.

At the top of the source code, before the constructors and methods. (*)
31. In Greenfoot, a variable can be saved and accessed later, even if the instance no longer exists.
True or false ?
True False (*)

32. From your Greenfoot lessons, when a method needs additional data to perform a task, this data
comes from parameters. True or false?
True (*) False

33. In the Greenfoot IDE, which type of variable allows instances to store information

Method variable

Instance variable (*)

Class variable

World variable

34. From your Greenfoot lessons, how do you call a defined method?
Call the method from the act method. (*)

Call the method from the defined method.

Write the method in the World superclass.

Write the method in the instance.

Write the method in the source code.

35. To execute a method in your Greenfoot game, where is it called from?
The world

The act method (*)

The actor class

The gallery

36. From your Greenfoot lessons, to save space in the act method, you can write an entirely new
method below it, called a _____________.
Class method

Instance method

Defined method (*)

World method

Code method


37. Which method is used to play sound in your Greenfoot game

getSound method

findSound method

playSound method (*)

importSound method

38. In Greenfoot, which method checks if a key on the keyboard has been pressed
keyPress method

keyUp method

keyDown method (*)

keyClick method

39. In the Greenfoot IDE, what symbols indicate that the variable is an array?
Square brackets [ ] (*)

Curly brackets { }

Semicolon ;

Colon :

40. In Greenfoot, which of the following statements could prevent an infinite loop from occurring?
I = 100 + i

i=1

i = i

i = i + 1 (*)

41. In Greenfoot, what happens if the end to a while loop isn't established?
The code will keep executing and will never stop. (*)

The code will execute once and then stop, due to controls in Greenfoot.

The code will prompt you to enter a loop counter.

The code will not execute.

42. In Greenfoot, in which programming task are the objects identified
Define the problem.

Design the solution.

Program the solution. (*)

Test the solution.


43. Use your Greenfoot skills to answer the question. What is incorrect in this code?


Spacing missing

Curly brace missing

Parenthesis missing (*)

Comma missing


44. From your Greenfoot lessons, a problem statement defines the purpose for your game. True or
false
True (*) False

45. From your Greenfoot lessons, where do you review a class's inherited methods

Act method

Documentation (*)

Inspector

If-statement

46. From your Greenfoot lessons, the reset button resets the scenario back to its initial position.
True or false?

True (*) False

47. Which of the following Java syntax is used to correctly create a Duke subclass

private Dog extends World

public class Dog extends World

public class Duke extends Animal (*)

private class extends Actor

private class extends Duke


48. When a Greenfoot code segment is executed in an if-statement, each line of code is executed in
sequential order. True or false? True (*) False

49. In a Greenfoot if-else statement, if the condition is true, the if-statement is executed, and then
the else-statement is executed. True or false
True False (*)


50. Read the following method signature. Using your Greenfoot experience, what does this method
do?

public static int getRandomNumber (int limit)
Returns a random number less than 10.

Returns a random coordinate position in the world.

Returns a random number between zero and parameter limit. (*)

Returns a random number for instances in the animal class only.

S-ar putea să vă placă și