Tips Midterm Java
Tips Midterm Java
double
Incorrect. Refer to Section 2 Lesson 9.
5. The list below displays valid arithmetic operators in J
ava, except which one? Mark for Review
(1) Points
+
/
*
%
$ (*)
Correct
6. Results of arithmetic operations cannot be stored in a
variable. True or false? Mark for Review
(1) Points
True
False (*)
Correct
7. Expressions with relational operators produce true and
false values. True or false? Mark for Review
(1) Points
True (*)
False
Correct
8. What is the result of the following code?
Mark for Review
(1) Points
x > y : x > y
x < y : x < y
x > y : 1
x < y : 0
x > y : 0
x < y : 1
x > y : true
x < y : false (*)
x > y : false
x < y : true
Correct
9. If a value has been assigned to (is stored in) a variab
le, that value will be overwritten when another value is assigned to the variabl
e using the assignment "=" operator. True or false? Mark for Review
(1) Points
True (*)
False
Correct
10. What is the output produced by the following code?
Mark for Review
(1) Points
j is 5
k is 5 (*)
j is 10
j is 5
k is 5
j is 10
k is 10
j is 15
k is 15
Correct
Test: Correlating Java Methods, Classes, and Other Structures with Alice 3 Tools
: Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Section 1
(Answer all questions in this section)
1. The list below contains method descriptions. All are cor
rect except which one? Mark for Review
(1) Points
(Choose all correct answers)
A subprogram that acts on data and often returns a value. (*)
A set of code that is referred to by name. (*)
Can be called at any point in a program simply by utilizing its name.
Is associated with an instance variable.
Correct
2. Main is an example of what in the following code?
public static void main (String[] args) {
System.out.println{"Hello World!");
} Mark for Review
(1) Points
An instance
A method (*)
A class
A variable
Incorrect. Refer to Section 2 Lesson 10.
3. You have a Class representing Cat. A cat can meow, purr
, catch mice, and so on. When you create a new cat, what is it called? Mark fo
r Review
(1) Points
A submethod
A subprogram
An instance (*)
A subclass
A variable class
Correct
4. You want a block of code to be executed only once if ce
rtain conditions are met. What type of Java construct would you use? Mark fo
r Review
(1) Points
while loop
if (*)
array
boolean
Correct
5. If you want one message to display if a user is below t
he age of 18 and a different message to display if the user is 18 or older, what
type of construct would you use? Mark for Review
(1) Points
for all loop
do loop
while loop
if (*)
Correct
6. If you need to repeat a group of Java statements many t
imes, which Java construct should you use? Mark for Review
(1) Points
(Choose all correct answers)
repeat...until
do while loop (*)
while loop (*)
if
Correct
Asterisks **
Correct
10. In Greenfoot, methods can be called in the act method.
When the Act button is clicked in the environment, the methods in the method bod
y of the act method are executed. True or false? Mark for Review
(1) Points
True (*)
False
Correct
Page 1 of 1 Summary
False (*)
Correct
Page 1 of 1 Summary
Test: Working with Source Code and Documentation: Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Section 1
(Answer all questions in this section)
1. The list below provides actions you can perform in the
Greenfoot code editor except one. Which one should be removed? Mark for Review
(1) Points
Write source code to tell the class how to act in the scenario.
Review the class's inherited methods and properties. (*)
Write and edit source code.
Write and edit comments.
Correct
2. The list below displays components of the Greenfoot sou
rce code editor except one. Which one should be removed? Mark for Review
(1) Points
Documentation
Comments
Method body
Instance creator (*)
Class description
Correct
3. In a Greenfoot if-statement, the programming statements
that the if-statement executes are written in curly brackets. True or false?
Mark for Review
(1) Points
True (*)
False
Correct
4. An if-statement requires which type of information retu
rned from the condition? Mark for Review
(1) Points
Integer
Action
True or false (*)
Method
Correct
5. In Greenfoot, which of the following methods display an
object's orientation? Mark for Review
(1) Points
(Choose all correct answers)
void move()
int getRotation() (*)
int getX() (*)
void turn()
Correct
6. In Greenfoot, which of the following methods return the
world that the instance lives in? Mark for Review
(1) Points
World getClass()
World getWorld() (*)
getRotation()
getXY()
Correct
Page 1 of 1 Summary
Test: Developing and Testing an Application: Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Section 1
(Answer all questions in this section)
1. Which of the following is an incorrectly written progra
mming statement? Mark for Review
(1) Points
move(): (*)
move(2);
turn(25);
turn(2);
Correct
2. Which of the following features of Greenfoot will teach
you how to identify bugs in your program? Mark for Review
(1) Points
Code editor
Compilation (*)
Instance creation
Documentation
Correct
3. In object oriented programming, programmers analyze a p
roblem and create objects to solve the problem. True or false? Mark for Review
(1) Points
True (*)
False
Correct
4. Which of the following statements is most correct?
Mark for Review
(1) Points
My program is complete when it compiles.
My program is complete when I add music to it.
My program is complete when it runs and I've tested the code. (*)
My program is complete when I add images to it.
Correct
Page 1 of 1 Summary
Section 1
(Answer all questions in this section)
1. Which of the following Greenfoot methods returns a rand
om number between 0, up to and including 10,000? Mark for Review
(1) Points
Greenfoot.getRandomNumber(10,000)
Greenfoot.getRandomNumber(10,001) (*)
Greenfoot.getRandomNumber(9,999)
Greenfoot.getRandomNumber(0-10,000)
Correct
2. What does the following Greenfoot programming statement
tell the class to do?
class-name.method-name(parameters);
Method-name.object-name(parameters);
Method-name.object-name;
Correct
10. In Greenfoot, a semicolon is not necessary at the end o
f a method that uses dot notation. True or false? Mark for Review
(1) Points
True
False (*)
Correct
11. In Greenfoot, the origin of the world coordinate system
(0,0) starts in the center of the world. True or false? Mark for Review
(1) Points
True
False (*)
Correct
12. Which keyword indicates that Greenfoot needs to create
a new object? Mark for Review
(1) Points
new (*)
addObject
newObject
newClass
Correct
Test: Defining Methods: Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Section 1
(Answer all questions in this section)
1. In the Greenfoot IDE, any new methods you create are wr
itten in the class's source code, below the act method. True or false? Mark fo
r Review
True (*)
False
Correct
2. In reference to Greenfoot, if t
he following method was defined in a superclass,
public void lookForEdge(){
...
}
all subclasses of the superclass will inherit the method.
True or false? Mark for Review
True (*)
False
Correct
Test: Using Sound and Keyboard Control: Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Section 1
(Answer all questions in this section)
1. In Greenfoot, the sound file must be saved in the scena
rio and written in the source code for it to play. True or false? Mark fo
r Review
(1) Points
True (*)
False
Correct
2. You cannot record unique sounds in Greenfoot. You can o
nly use the sounds that are stored in the Greenfoot library. True or false?
Correct
6. In Greenfoot, what is the purpose of the variable type?
Mark for Review
(1) Points
Defines the access specifier used with the variable.
Defines what kind of data to store in the variable. (*)
Defines which class the variable is associated with.
Defines the instance that the variable is associated with.
Correct
7. Which operator is used to test if values are equal?
Mark for Review
(1) Points
<
== (*)
>
!>
Correct
8. In Greenfoot, the == operator is used to test if two va
lues are equal. True or false? Mark for Review
(1) Points
True (*)
False
Correct
9. The GreenfootImage class enables Greenfoot actors to ma
intain their visible image by holding an object of type GreenfootImage. True or
false? Mark for Review
(1) Points
True (*)
False
Correct
10. What does the following programming statement mean?
image1 = new GreenfootImage("duke12.png?); Mark for Review
(1) Points
The variable, image1, cannot use the image file, duke12.png.
The image file, duke12.png, has just been drawn and imported into the sc
enario.
The image file, duke12.png, is assigned to the variable image1. (*)
Image files from 1-119 are associated with image1.
Correct
11. In Greenfoot, which method is used to end a game?
Mark for Review
(1) Points
Class.stop( );
Greenfoot.stop( ); (*)
Duke.stop( );
Game.stop(1);
Correct
12. Where can we review the available classes and methods i
n Greenfoot, including the stop method? Mark for Review
(1) Points
Class menu
Object menu
Class Application Programmers' Interface (API)
Greenfoot Application Programmers' Interface (API) (*)
Correct
Page 1 of 1 Summary
Test: Understanding Abstraction: Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Section 1
(Answer all questions in this section)
1. From your Greenfoot lessons, which of the following are
examples of when abstraction techniques are used? Mark for Review
(1) Points
Assigning a sound file to an instance.
Assigning a keyboard key to an instance.
Assigning an image file to an instance.
All of the above. (*)
Correct
2. Abstraction occurs in many different ways in programmin
g. True or false? Mark for Review
(1) Points
True (*)
False
Correct
Page 1 of 1 Summary
Test: Using Loops, Variables, and Strings: Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Section 1
(Answer all questions in this section)
1. From your Greenfoot lessons, which of the following are
examples of actions that can be achieved using the while loop? Mark for Review
(1) Points
Create 50 instances of the Duke class.
Call the move method 1 million times.
Call the move and turn methods 10 times.
Create 100 instances of an Actor subclass.
All of the above. (*)
Correct
2. Which of the following is not a component of a while lo
op? Mark for Review
(1) Points
Local variable
Control operator
Loop variable
if statement (*)
while keyword
Correct
3. If an end to a while loop is not established, what happ
ens? Mark for Review
(1) Points
The code stops after 10 executions.
The code stops after 20 executions.
The condition becomes false after one minute of executions.
The code executes and does not stop. (*)
Incorrect. Refer to Section 3 Lesson 10.
4. Infinite loops are a common cause of errors in programm
ing. True or false? Mark for Review
(1) Points
True (*)
False
Correct
5. An array is an object that holds multiple methods. True
or false? Mark for Review
(1) Points
True
False (*)
Correct
6. In Greenfoot, arrays are a way to hold and access multi
ple variables, and assign different values to new instances each time the while
loop executes and produces a new instance. True or false? Mark for Review
(1) Points
True (*)
False
Correct
7. Which of the following Greenfoot logic operators repres
ents "not"? Mark for Review
(1) Points
&
&&
=
! (*)
Correct
8. In the Greenfoot IDE, what does the AND operator (&&) d
o? Mark for Review
(1) Points
Compares two boolean values, and returns a boolean value which is true i
f and only if both of its operands are true. (*)
Compares two boolean values, and returns a boolean value which is true i
f and only if one of its operands are true.
Compares two boolean values and returns a boolean value which is true if
either one of the operands is true.
Compares two boolean variables or expressions and returns a result that
is true if either of its operands are true.
Correct
9. In Greenfoot, a local variable is declared at the begin
ning of a class. True or false? Mark for Review
(1) Points
True
False (*)
Correct
10. In Greenfoot, what types of values cannot be stored in
a local variable? Mark for Review
(1) Points
Class name
Objects
Integers
World name
Method (*)
Correct
11. In Greenfoot, string concatenation reduces the number o
f redundant characters or phrases you need to type into each array. True or fals
e? Mark for Review
(1) Points
True (*)
False
Correct
12. Which of the following is an example of string concaten
ation? Mark for Review
(1) Points
Instead of entering ".png" after each image file name, add && ".png" aft
er the imageName value in the programming statement.
Instead of entering ".png" after each image file name, add = ".png" afte
r the imageName value in the programming statement.
Instead of entering ".png" after each image file name, add + ".png" afte
r 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
Page 1 of 1 Summary
Test: Creating an Inventory of Java Fundamentals: Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Section 1
(Answer all questions in this section)
1. From your Greenfoot lessons, the __________ control str
ucture is used to compare and make a decision. Mark for Review
(1) Points
Conditional (*)
Repetition
Obsolete
Rewind
Correct
2. From your Greenfoot lessons, the __________ control str
ucture is often referred to as loops. Mark for Review
(1) Points
Conditional
Repetition (*)
Obsolete
Rewind
Correct
3. The construct listed below is described as a __________
________.
/**
* Get value and store in variable
*/
Mark for Review
(1) Points
Method
Comment (*)
Variable Assignment
Instruction
Correct
4. The construct listed below is described as a __________
________.
termvar = scanterm.nextLine();
Mark for Review
(1) Points
Method
Comment
Variable Assignment (*)
Instruction
Correct
5. What is wrong with the following line of code?
System.out.println(termvar+'; '+termdef);
Mark for Review
(1) Points
There are parenthesis instead of brackets.
There are parenthesis instead of curly braces.
There are single quotes instead of double quotes. (*)
The command is incorrectly capitalized.
Nothing is wrong with the code.
Incorrect. Refer to Section 3 Lesson 12.
6. Which line of code contains a syntax error?
Mark for Review
(1) Points
2
3 (*)
4
5
6
Correct
7. In which step to create a Greenfoot game do you find an
d resolve errors in the game? Mark for Review
(1) Points
Define the problem
Design the solution
Program the solution
Test the solution (*)
Correct
8. In which step to create a Greenfoot game is the solutio
n implemented? Mark for Review
(1) Points
Define the problem
Design the solution
Program the solution (*)
Test the solution
Correct
9. From your Greenfoot lessons, which of the following are
examples of Q/A test variations? Mark for Review
(1) Points
Change the environment, change the programmer, change the execution
Change the execution, change the data, change the environment (*)
Change the environment, change the execution, change the language
All of the above.
Correct
10. The variations listed below are examples of changing wh
at part of Q/A testing?
Input numbers when characters are expected
Input characters when numbers are expected
Input symbols
Mark for Review
(1) Points
Change the environment
Change the execution
Change the data (*)
None of the above
Correct
Page 1 of 1 Summary
\
Test: Compiling with Eclipse: Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Section 1
(Answer all questions in this section)
1. When Eclipse launches, the Welcome page displays. Once
this page is closed you cannot return to the resources available on this page. T
rue or False? Mark for Review
(1) Points
True
False (*)
Incorrect. Refer to Section 4 Lesson 1.
2. Eclipse provides an edit area to help you navigate a hi
erarchy of information. True or False? Mark for Review
(1) Points
True
False (*)
Incorrect. Refer to Section 4 Lesson 1.
3. Eclipse provides views to help you navigate a hierarchy
of information. True or False? Mark for Review
(1) Points
True (*)
False
Correct
4. Tabs are used when more than one file is open in the ed
it area. True or False? Mark for Review
(1) Points
True (*)
False
Correct
5. A perspective is described as: Mark for Review
(1) Points
A combination of views and editors (*)
A combination of views and windows
A combination of editor tabs
None of the above
Correct
6. The ______________ is the location onto which you will
store and save your files. Mark for Review
(1) Points
Perspective
Workspace (*)
Editor
None of the above
Correct
7. A workspace can have one or more stored projects. True
or false? Mark for Review
(1) Points
True (*)
False
Correct
8. Identify the components in the image below.
Mark for Review
(1) Points
A-Main Method, B-Class, C-Package
A-Class, B-MainMethod, C-Package
A-Package, B-Main Method, C-Class (*)
None of the above
Correct
9. In Eclipse, when you run a Java Application, the result
s may be displayed in the Console View. True or False? Mark for Review
(1) Points
True (*)
False
Correct
Test: Using Program Control Statements: Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Section 1
(Answer all questions in this section)
1. What is a loop? Mark for Review
(1) Points
A keyword used to skip over the remaining code.
A set of logic that is repeatedly executed until a certain condition is
met. (*)
A segment of code that may only ever be executed once per call of the pr
ogram.
None of the above.
Correct
2. It is necessary to end all loops at some point in your
Java program. True or false? Mark for Review
(1) Points
True (*)
False
Incorrect. Refer to Section 5 Lesson 1.
3. Which of the following are types of loops in Java?
Mark for Review
(1) Points
(Choose all correct answers)
While (*)
If/Else
Do-While (*)
For (*)
Correct
4. Identify which situation could be an example of a WHILE
loop. Mark for Review
(1) Points
Taking coins out of a pile one at a time and adding their value to the t
otal until there are no more coins in the pile to add.
Attending class while school is not over for the day.
Petting each animal at the pet store one at a time until all the animals
have been petted.
All of the above. (*)
Correct
5. Which of the following correctly initializes a For loop
that runs through 5 times? Mark for Review
(1) Points
for(int i = 0; i == 6; i++)
for(int i = 1; i < 6; i++) (*)
for(int i = 0; i < 5; I++)
for(int i = 1; i < 5; I++)
Correct
6. What is the function of the word "break" in Java?
Mark for Review
(1) Points
It exits the current loop or case statement. (*)
It continues onto the next line of code.
It stops the program from running.
It does not exist in Java.
Incorrect. Refer to Section 5 Lesson 1.
7. The following code fragment properly implements the swit
ch statement. True or false?
default(input)
switch '+':
answer+=num;
break;
case '-':
answer-=num;
break;
!default
System.out.println("Invalid input"); Mark for Review
(1) Points
True
False (*)
Correct
8. What is one significant difference between a WHILE loop
True (*)
False
Correct
13. The following creates a reference in memory named z that
can refer to seven different doubles via an index. True or false?
double z[] = new double[7]; Mark for Review
(1) Points
True (*)
False
Correct
14. What is the output of the following segment of code if t
he command line arguments are "apples oranges pears"?
Mark for Review
(1) Points
apples
pears (*)
oranges
args
This code doesn't compile.
Correct
15. What is the output of the following segment of code if t
he command line arguments are "apples oranges pears"?
Mark for Review
(1) Points
0
1
2
3 (*)
This code does not compile.
Correct
16. What will be the content of array variable table after e
xecuting the following code?
Mark for Review
(1) Points
0 0 0
0 0 0
0 0 0
1 0 0
0 1 0
0 0 1 (*)
1 0 0
1 1 0
1 1 1
0 0 1
0 1 0
1 0 0
Correct
17. What is the output of the following segment of code?
Mark for Review
(1) Points
1286864 (*)
643432
262423242322
666666
This code does not compile.
Correct
18. After execution of the following statement, which of th
e following are true?
int number[] = new int[5]; Mark for Review
(1) Points
number[0] is undefined
number[4] is null
number[2] is 0 (*)
number.length() is 6
Incorrect. Refer to Section 6 Lesson 1.
19. The following array declaration is valid. True or false
?
int x[] = int[10]; Mark for Review
(1) Points
True
False (*)
Correct
Page 1 of 1 Summary