Short Answer 3 points each ________27 pts

advertisement
Your Name___________________________________
GreenFoot Concepts~ Chapter 1-6
Matching: Match the correct data type with its definition (1 point each) _____4 pts
1. boolean
A. contains alphabetic letters or words enclosed in quotes
2. double
B. contains integers (whole numbers) only
3. int
C. contains only two possible values, true or false
4. String
D. contains double precision values with decimals
Matching: Match the following value operators with its definition. 1 pt each _____6 pts
1. <
A. equal to
2. <=
B. Greater than
3. >
C. Less than or equal to
4. >=
D. Not equal to
5. ==
E. Greater than or equal to
6. !=
F. Less than
1
Multiple Choice: Circle the correct response.( 2 points each) ______46 pts
1. Objects are created from:
a. methods
b. classes
c. parameters
d. commands
2. Objects have several [__] that are blocks of code that perform specific tasks or actions.
a. methods
b. classes
c. instances
d. parameters
3. This specifies what type of data a method call with return:
a. parameters
b. commands
c. class type
d. return type
4. The mechanism that is used to pass additional information to a method is called a:
a. command
b. parameter
c. return type
d. signature
5. The specification of a method, which shows its return type, name and parameters is
called its:
a. command
b. parameter
c. return type
d. signature
6. Another name for objects is:
a. classes
b. commands
c. methods
d. instances
2
7. An instruction that tells an object to perform a specific task it has programming code to
do is called a:
a. parameter
b. command
c. method call
d. instance
8. The command that allows you to make a decision based on true or false conditions is
a(n):
a. list command
b. do command
c. act statement
d. if statement
9. When you need to call a method from a different class you must specify the class name
before the method name using:
a. dot notation
b. parenthetical citation
c. curly braces
d. spaces
10. Methods that belong to the class itself are marked with the keyword:
a. void
b. public
c. static
d. general
11. By convention, class names in Java should always start with a:
a. capital letter
b. small letter but use capital letters for the beginning of words in the middle of it
12. This default Greenfoot method is automatically created in each new class and is what is
executed when you click on Act or Run in the window:
a. canSee()
b. move()
c. run()
d. act()
13. Comments are ignored by the computer but necessary for documentation for the user
and they are started with:
a. /**
b. (
c. {
d. <
3
14. By convention, method names in Java should always start with a:
a. capital letter
b. small letter but use capital letters for the beginning of words in the middle of it
because they cannot contain spaces
15. A bit of memory that belongs to an object to store information is called a:
a. method call
b. instance variable
c. return type
16. Good Java coding practice dictates that we should declare all of our variables:
a. at the top of the class
b. inside of the method that it is going to be used in
c. at the end of the class
17. An assignment statement enables us to store something into a variable. The symbol
that allows us to do that is:
a. !=
b. =
c. ==
d. /=
18. This statement can be added to the IF statement to specify what should happen if the
condition is false:
a. when
b. while
c. do
d. else
19. Putting this symbol in front of something means NOT:
a. . (dot
b. ! (exclamation mark)
c. ^(caret)
d. –(dash)
20. These symbols mean AND, which will join two conditions:
a. &&
b. !!
c. ||
d. <>
4
21. When we need to repeat code or do a similar task repeatedly, we need a:
a. constant
b. loop
c. modifier
d. instance
22. This type of data structure allows us to store many values of the same type and access
them using an index, like this whiteKeys[2], which would access the third element:
a. String
b. Array
c. Double
d. Constant
23. A special expression that means “nothing” or “no object” is:
a. null
b. private
c. static
d. Boolean
True and False- Circle T for True, circle F for False. 1 pt each ______7 pts
T F
1. A method with a void return type does not return a value.
T F
2. .Actors are classes that are placed into the world
T F
3. Computers do not understand source code that we type in so it needs to be translated
into machine code by a compiler before being executed.
T F
4. Java is very case dependent, so Body and body represent two different things.
T F
5. Objects will inherit methods from its superclasses.
T F
6. Anything stored in an instance variable will be remembered as long as the object exists
and can be accessed later.
T F
7. A constant is a named value that is used like a variable, but can only be changed by other
classes.
5
Short Answer 3 points each ________27 pts
1. Why do all loops need a loop counter?
2. What is overloading? (CH 6)
3. Explain what each of the first 4 words indicate in this statement:
private static final double GRAVITY=5.8;
4. If we want to use methods from other classes that are already written by other in the Java
documentation like setting colors from the Color class or using the List type from the Util
class, we must first _________________________ those packages.
6
5. Tell what the following code would do to the values of i and j:
private void example()
{
int j=10
for (int i=0; i<10; i++)
{
j=j – i;
}
}
6. Fill in the blanks of the following code so that it does exactly what the code above does.
private void exampleAgain()
{
int j=10, i=0;
while (i<_____________)
{
j = j - i;
i ________________
}
}
7. Explain what this method does:
private void anotherExample(int x, int y)
{
value=2*x+2*y;
}
7
To add a new actor, like a lobster, to this little-crab world, you would:
To place a crab into the world manually (not using the Act or Run buttons), you would:
8
Download