WITH OUTLINED ANSWERS
A Jeroo method that requires you to specify a direction when you call it is:
1) hop()
2) plant()
3) turn()
4) pick()
turn()
A Jeroo can carry these:
1) Flowers
2) water
3) other jeroos
4) nets
flowers()
True or False - A subclass can represent a less specialized concept than its superclass
False - a subclass can represent a more specialized concept than its superclass
Which of the following is NOT a step to consider when design an algorithm?
1) consider the problem and ask additional questions
2) get a problem description
3) all of these are steps
4) create a high-level algorithm
all of these are steps
In what step of algorithm development do we ask what rules exist for working with the data?
1) when we review the algorithm we've created
2) when we get a problem description
3) when we refine out high-level algorithm
4) when we analyze the problem
when we analyze the problem
,Where should pre and postconditions be stated?
1) at the top of a java file before a class is declared
2) in a comment block below the method
3) in a comment block just under the method definition
4) in a comment block above the method
in a comment block above the method
What is the method identifier in the following method definition
public int add3Ints(int a, int b, int c)
{
return a + b + c;
}
1) add3Ints
2) public
3) int
4) return
5) a + b + c
add3Ints
In an if-then-else structure, if the condition in the if statement is false, which of the following
will happen
1) nothing
2) the code will proceed to the next line after the if-then-else structure
3) the code inside of the {} of the if statement will run
4) the code inside of the brackets in the else branch will run
the code inside of the bracket in the else branch will run
Assume we see an if statement that reads if (! true). What would you know about this code
1) the code inside this conditional would always run
2) this code would compile, but would fail if you tried to run it
3) if (!true) would produce a syntax error
4) the code inside this conditional would never run
the code inside this conditional would never run
Assume boolean variable a is true and boolean variable b is false. Would if (a && b) run the
code in the if statement?
1) no - both variables need to be true for the if statement to run
2) yes - at least one boolean is true so the whole statement is true
, 3) yes - at least one boolean is false so the whole statement is true
4) no - this code would produce an error
no - both variables need to be true for the if statement to run
Assume boolean variable a is true and boolean variable b is false. Would if (a || b) run the
code in the if statement?
1) no - both variables need to be true for the if statement to run
2) yes - at least one boolean is true so the whole statement is true
3) yes - at least one boolean is false so the whole statement is true
4) no - this code would produce an error
yes - at least one boolean is true so the whole statement is true
What is the difference between an if-then structure and a while loop
a) an if-then structure can contain multiple conditionals
b) a while loop does not need a conditional
c) a while loop can repeatedly execute a block of code many times
d) an if-then structure is more efficient but more complicated
a while loop can repeatedly execute a block of code many times
how many times will conor hop
while (true)
{
conor.hop();
}
a) this loop will never run
b) this loop will produce a syntax error
c) this loop will run 17 times and then produce a syntax error
d) this loop will never stop
this loop will never stop
Which of the following statements are NOT true about objects?
a) creating a new object is called instantiation
b) renaming an object is called reconstruction
c) object-orientated programming uses objects to model parts of a program (like LightBots or
a world)
d) each object provides a set of behaviors that it understands. these are called methods
renaming an object is called reconstruction