19 questions
Why do we use if statements in Java?
To break out of some block of code
To do something only if a condition is true
To do something while a condition is true
To repeat something for a fixed number of times
Which general if statement definition is written correctly?
for(condition)
{
//code
}
if(condition)
{
//code
}
if(int i = 0; i < count; i++
{
//code
}
if(false)
{
//code
}
Why do we use if/else statements in Java?
To repeat something for a fixed number of times
To either do something if a condition is true or do something else
To break out of some block of code
To repeat something while a condition is true
What does an if/else statement look like in Java?
if(condition)
{
//code
}
for(int i=0; i<count; i++)
{
//code
}
if(condition)
{
//code
}
if(condition)
{
//code
}
if(condition)
{
//code
}
else
{
//code
}
Why do we use while loops in Java?
To break out of some block of code
To do something if a condition is true
To repeat some code while a condition is true
To repeat something for a fixed number of times
Which general while loop definition is written correctly?
while(x is true)
{
//code
}
if(i<5)
{
//code
}
while(int i=0; i<count; i++)
{
//code
}
while(condition)
{
//code
}
Why do we use for loops in Java?
To repeat something for a fixed number of times
To do something while a condition is true
To do something if a condition is true
To break out of some block of code
Which general for loop definition is written correctly?
for(true)
{
//code
}
if(i<5)
{
//code
}
for(int i=0; i<count; i++)
{
//code
}
while(condition)
{
//code
}
What commands does SuperKarel know that regular Karel does not?
turnLeft() and jump()
turnRight() and move()
turnLeft() and move()
turnAround() and turnRight()
How do you write a SuperKarel class?
public class FunProgram extends Karel
private class FunProgram extends Karel
class FunProgram extends SuperKarel
public class FunProgram extends SuperKarel
What is a code comment?
A way to teach Karel a new word
A way to give notes to the reader to explain what your code is doing
A message to your teacher in code
A place to write whatever you want in your code
Why do we use methods in Java programming?
Make our program more readable
Avoid repeating code
Break down our program into smaller parts
All of the Above
What is top down design?
A way of designing your program by starting with the biggest problem and breaking it down into smaller and smaller pieces that are easier to solve.
A way that you can create designs on a computer to put on a web page
A way of designing your programs starting with the individual commands first
A way to use loops and classes to decompose the problem
Top Down Design starts with many small problems and leads to the big problem.
True
False
Making a movie is an example of Top Down Design.
True
False
If you need to write a program to have Karel move 6 times and put a ball, you should use a While Loop.
True
False
If you need to write a program that has Karel take all of the tennis balls where Karel is standing if there are any there, you should use a For Loop.
True
False
If you need to write a program that has Karel move if the front is clear but if it isn't clear, Karel will do nothing, you should use an If Statement.
True
False
How many times will Karel move in the following program?
public void run()
{
move();
for(int i=0; i<5;i++)
{
move();
putBall();
}
}
6
5
1
0