Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

Test: Java Fundamentals Midterm Exam

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct
answer.

Section 2
(Answer all questions in this section)

1In Alice, procedural abstraction is the concept of making code easier to


Mark for
. understand and reuse. True or false?
Review 
(1) Points

True (*)
False

Correct

2In Alice, if a procedure is declared for a clownFish class, which classes


Mark for
. can use the procedure?
Review 
(1) Points

The clownFish class and Swimmer class


ClownFish class (*)
The pajamaFish class, clownFish class, and Swimmer class
Any class with "Fish" in the class name

Correct

3From your Alice lessons, which of the following is a tool to show the
Mark for
. logic of an animation?
Review 
(1) Points

Visual storyboard
Flowchart (*)
Pie chart
Scene editor
Class chart

Incorrect. Refer to Section 2 Lesson 5.

4In Alice, which function is used to move an object directly to the center
Mark for
. point of another object?
Review 
(1) Points

getObject
getDuration
getDepth
getDistance (*)

Incorrect. Refer to Section 2 Lesson 7.

5Which of the following statements about what happens when the


Mark for
. following code is executed is false?
Review 
(1) Points

The message "Printing Some Text" will be printed until loopVal is


no longer less than 5.
The variable loopVal is initialized to 0.
The condition loopVal < 5 is tested after the block is executed. (*)
The condition loopVal < 5 returns a boolean value.
None of the above.

Correct

6.If you
Mark for Review 
want one
(1) Points
message
to display
if a user
is below
the age of
18 and a
different
message
to display
if the
user is 18
or older,
what type
of
construct
would
you use?

for all loop


do loop
while loop
if (*)

Incorrect. Refer to Section 2 Lesson


14.

7. The Alice IF control structure requires the false statement to


Mark for Review 
be populated. True or false?
(1) Points

True
False (*)

Correct

8. In Alice, Do In Order and Do Together:


Mark for Review 
(1) Points

Are move statements


Are control statements (*)
Are complex statements
None of the above

Correct

9. In Alice, the setVehicle procedure will associate one object to


Mark for Review 
another. True or false?
(1) Points

True (*)
False

Incorrect. Refer to Section 2 Lesson


6.
10. Which of the following actions would require a control
Mark for Review 
statement to control animation timing?
(1) Points

(Choose all correct answers)

A biped object walking. (*)


A rock object turning.
A fish swimming. (*)
A bird flying. (*)

Incorrect. Refer to Section 2 Lesson


6
1In
Mark for
1.Alice,
Review 
how is
(1) Points
a one-
shot
procedu
re
differen
t from
procedu
res in
the
Code
editor?

One-shot procedures are only available for acting objects, while


procedures are available for all objects.
One-shot procedures are available in the Code editor, while
procedures are available in the Scene editor.
A one-shot procedure executes only one time to re-position the
object, while procedures in the Code editor execute every time
the Run button is clicked. (*)
All of the above

Incorrect. Refer to Section 2 Lesson 2.

12. From your Alice lessons, variables are fixed and cannot be changed.
Mark for
True or false?
Review 
(1) Points

True
False (*)
Correct

13. Which of the following programming instructions commands the fish


Mark for
to continuously move forward a random speed between 0.5 and 1.0
Review 
meters, minus 0.25 meters, until it collides with the shark?
(1) Points

(*)

Correct
14. From your Alice lessons, what does the Count control statement do?
Mark for
Review 
(1) Points

Executes statements a random number of times.


Executes statements simultaneously.
Executes statements a specific number of times. (*)
Executes statements while a condition is true.

Correct

15. From your Alice lessons, when testing your animation, you should
Mark for
test that comments were added below each sequence of instructions in
Review 
the code. True or false?
(1) Points

True
False (*)

Correct
Section 2
(Answer all questions in this section)

16.From your Alice lessons, at what point in the animation process do


Mark for Review 
you confirm the items on the "Checklist for Animation Completion"?
(1) Points

Before designing the animation.


During and after the animation process. (*)
At the beginning of the animation process.
After adding each procedure to the Code editor.

Correct

17.Debugging and testing is the process of running the animation one


Mark for Review 
time, and adjusting the control statements, procedures, and
(1) Points
arguments.

True
False (*)

Incorrect. Refer to Section 2 Lesson 3.


18.From your Alice lessons, complete the following sentence: When
Mark for Review 
coded, an event triggers a ___________.
(1) Points

Infinite loop
Gallery
Procedure (*)
Scene

Correct

19.In Alice, which of the following programming statements moves the


Mark for Review 
butterfly forward, double the distance to the tree?
(1) Points

this.Butterfly move forward {this.Butterfly getDistanceTo


this.Tree * 2} (*)
this.Butterfly move backward {this.Butterfly getDistanceTo
this.Tree * 2}
this.Butterfly move backward {this.Butterfly getDistanceTo
this.Tree / 2}
this.Butterfly move forward {this.Butterfly getDistanceTo
this.Tree / 2}

Correct

20.In Alice, which of the following programming statements moves the


Mark for Review 
fish forward, the distance to the rock, minus the depth of the rock?
(1) Points

this.Fish move forward {this.Rock getDistanceTo this.Fish -


this.Fish getDepth}
this.Fish move forward {this.Fish getDistanceTo this.Rock -
this.Rock getDepth} (*)
this.Fish move forward {this.Rock getDistanceTo this.Fish -
this.Fish - 2}
this.Rock move forward {this.Rock getDistanceTo this.Fish -
this.Fish - 2}

Correct
2Examine the following code. What are the variables?
Mark for
1.
Review 
(1) Points
(Choose all correct
answers)

args
n (*)
i (*)
t

Incorr
ect.
Refer
to
Sectio
n2
Lesso
n 13.

22. Which of the following


Mark for
is not a valid arithmetic
Review 
operator in Java?
(1) Points

+
/
-
*
%
None of the above
(*)
Corre
ct

Section 3
(Answer all questions in this section)

23. From your Greenfoot


Mark for
lessons, source code is
Review 
written in the Code
(1) Points
editor. True or false?

True (*)
False

Corre
ct

24. In Greenfoot, what


Mark for
happens if the
Review 
condition is false in an
(1) Points
if-statement?

The programming
statements are
executed.
The if-statement is
executed.
The act method is
deleted.
The programming
statements are not
executed. (*)

Corre
ct

25. Use your Greenfoot


Mark for
knowledge to answer
Review 
the question. One
(1) Points
reason to write a
defined method in a
class is to change the
behavior of the class.
True or false?

True
False (*)

Incorr
ect.
Refer
to
Sectio
n3
Lesso
n6
26.From
Mark for
your
Review 
Greenfoot
(1) Points
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.

Correct

27. Which of the following type of audience should you ask to


Mark for
play your Greenfoot game during the testing phase?
Review 
(1) Points

Testing
Target (*)
Primary
Programmer

Incorrect. Refer to Section 3 Lesson


4.
28. From your Greenfoot lessons, a problem statement defines
Mark for
the purpose for your game. True or false?
Review 
(1) Points

True (*)
False

Correct

29. Using Greenfoot, how do we change the size and resolution


Mark for
of the World instance?
Review 
(1) Points

Edit the methods in the class.


Edit the values in the constructor. (*)
Delete the instance.
Edit the values in the class's act method.

Correct

30. In Greenfoot, an if-statement is used to alternate between


Mark for
displaying two images in an instance. True or false?
Review 
(1) Points

True
False (*)

Correct
31.Using the
Mark for
Greenfoot
Review 
IDE, when is
(1) Points
a constructor
automatically
executed?

When source code is written.


When a new image is added to the class.
When a new instance of the class is created. (*)
When the act method is executed.

Correct
32. From your Greenfoot lessons, which of the following is an
Mark for
example of a type of data passed through a parameter?
Review 
(1) Points

Methods
Classes
Integers (*)
Scenarios

Incorrect. Refer to Section 3


Lesson 2.

33. In Greenfoot, the properties of an instance can be


Mark for
modified in the documentation. True or false?
Review 
(1) Points

True
False (*)

Incorrect. Refer to Section 3


Lesson 2.

34. From your Greenfoot lessons, which of the following are


Mark for
properties of an instance?
Review 
(1) Points

Size
Color
Image file
Methods
All of the above (*)

Incorrect. Refer to Section 3


Lesson 2.

35. In the following Greenfoot method signature, which is the


Mark for
method name?
Review 
(1) Points
void turnLeft()

()
void
turnLeft (*)
Left

Correct
36.From your
Mark for
Greenfoot
Review 
lessons,
(1) Points
which of the
following is
not a
characteristic
of a static
method?

Belongs to a class itself


Belongs to an instance itself (*)
Available for other classes to use with dot notation
Signature contains the word static
Is a method

Incorrect. Refer to Section 3


Lesson 5.

37. From your Greenfoot lessons, dot notation allows you to


Mark for
use a method from a different class, if the class you are
Review 
programming does not possess the method. True or false?
(1) Points

True (*)
False

Correct

38. When a Greenfoot code segment is executed in an if-


Mark for
statement, each line of code is executed in sequential
Review 
order. True or false?
(1) Points

True (*)
False

Correct
39. In Greenfoot, you can use comparison operators to
Mark for
compare a variable to a random number. True or false?
Review 
(1) Points

True (*)
False

Correct

40. From your Greenfoot lessons, the keyDown method is


Mark for
located in which class?
Review 
(1) Points

Actor
Greenfoot (*)
GreenfootImage
World

Correct
41.From
Mark for
your
Review 
Greenfoot
(1) Points
lessons,
which of
the
following
is not a
step to
creating a
new
subclass?

Right-click on a superclass.
Click New subclass...
Name the class.
Select an image for the class.
Program the class to move forward. (*)

Incorrect. Refer to Section 3 Lesson


1.

42. From your Greenfoot lessons, a scenario is a game or


Mark for
simulation implemented in Greenfoot. True or false? Review 
(1) Points

True (*)
False

Correct

43. How would the following sentence be written in Greenfoot


Mark for
source code? If Duke's leg is down, and the keyboard key "d"
Review 
is down...
(1) Points

if (&&isDown ! Greenfoot.isKeyDown("d") )
if (!isDown && Greenfoot.isKeyDown("d") )
if (isDown && Greenfoot.isKeyDown("d") ) (*)
if (!Greenfoot.isKeyDown && isDown("d") )

Correct

44. From your Greenfoot lessons, what is a loop?


Mark for
Review 
(1) Points

A statement that executes one segment of code.


A statement that can execute a section of code multiple
times. (*)
A statement that can execute a section of code one time.
A statement that can execute a method multiple times.

Incorrect. Refer to Section 3 Lesson


10.

45. From your Greenfoot lessons, when do infinite loops occur?


Mark for
Review 
(1) Points

When the loop is executed.


Only in while loops.
When the end to the code isn't established. (*)
When the end to the act method isn't established.
Incorrect. Refer to Section 3 Lesson
10.
Section 3
(Answer all questions in this section)

4In the following Greenfoot array, what statement would you write to access
Mark for
6.the "a" key?
Review 
(1) Points
Keynames = {"a", "b", "c", "d"};

keynames[2]
keynames["a"]
keynames[0] (*)
keynames["a" key]

Correct

4From your Greenfoot lessons, which line of code is missing something?


Mark for
7.
Review 
(1) Points

1
3 (*)
4
5
6

Correct

4In Greenfoot, the image below is an example of what construct?


Mark for
8.
Review 
(1) Points
Method
Comment
Constructor (*)
Class

Incorrect. Refer to Section 3 Lesson 12.

4Use your Greenfoot skills to answer the question. What is incorrect in this
Mark for
9.code?
Review 
(1) Points

Spacing missing
Curly brace missing
Parenthesis missing (*)
Comma missing

Correct

5From your Greenfoot lessons, which of the following are examples of


Mark for
0.abstraction?
Review 
(1) Points

(Choose all correct answers)

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. (*)

Correct

You might also like