1. What is the difference between the symbols = and == ? Mark for Review
(1) Points
The symbol = is used in if statements and == is used in loops.
The symbol == is used to assign values to variables and the = is used in declarations.
The = is use to assign values to variables and the == compares values. (*)
There is no difference.
[Incorrect] Incorrect. Refer to Section 5 Lesson 1.
2. Which of the following correctly initializes an instance of Scanner, called "in", that reads input from the console screen? Mark for Review
(1) Points
Scanner in = new Scanner("System.in");
Scanner in = Scanner(System.in);
Scanner in = new Scanner(System.in); (*)
System.in in = new Scanner();
[Incorrect] Incorrect. Refer to Section 5 Lesson 1.
3. Determine whether this boolean expression evaluates to true or false:
!(3 < 4 && 6 > 6 || 6 <= 6 && 7 - 2 == 6) Mark for Review
(1) Points
True (*)
False
[Correct] Correct
4. What will print if the following Java code is executed?
if ((5.1 > 4.3 && 6.2 < 8.4) && !(7.2 < 3.5 || 1.2 == 2.1 || 2.2 != 2.25))
System.out.print("TRUE");
else
System.out.print("FALSE"); Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 5 Lesson 1.
5. Determine whether this boolean expression evaluates to true or false:
!(3 < 4 && 5 > 6 || 6 <= 6 && 7 - 1 == 6) Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 5 Lesson 1.
6. The three logic operators in Java are: Mark for Review
(1) Points
&, |, =
&&, ||, ! (*)
&&, !=, =
!=, =, ==
[Incorrect] Incorrect. Refer to Section 5 Lesson 1.
7. How would you use the ternary operator to rewrite this if statement?
if (gender == "male")
System.out.print("Mr.");
else
System.out.print("Ms."); Mark for Review
(1) Points
(gender == "male") ? "Ms." : "Mr." ;
System.out.print( (gender == "male") ? "Mr." : "Ms." ); (*)
(gender == "male") ? "Mr." : "Ms." ;
System.out.print( (gender == "male") ? "Ms." : "Mr." );
[Incorrect] Incorrect. Refer to Section 5 Lesson 1.
8. This keyword is used to instruct specific code when the input for a switch statement that does not match any of the cases. Mark for Review
(1) Points
switch
case
break
default (*)
None of the above
[Incorrect] Incorrect. Refer to Section 5 Lesson 1.
9. When the for loop condition statement is met the construct is exited. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 5 Lesson 2.
10. All of the following are essential to initializing a for loop, except which one? Mark for Review
(1) Points
Having an if statement. (*)
Initializing the iterator(i).
Having a conditional statement.
Updating the counter.
[Correct] Correct
11. The syntax below represents a valid initialization of a for loop counter. True or False?
public class ForLoop {
public static void main (String args[])
{
for (int i=10; i <20; i++)
{System.out.println("i: "+i); }
}
}
Mark for Review
(1) Points
True (*)
False
[Correct] Correct
12. What is the function of the word "break" in Java? Mark for Review
(1) Points
It continues onto the next line of code.
It does not exist in Java.
It stops the program from running.
It exits the current loop or case statement. (*)
[Incorrect] Incorrect. Refer to Section 5 Lesson 2.
13. A counter used in a for loop cannot be initialized within the For loop statement. True or False? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 5 Lesson 2.
14. In a for loop the counter is not automatically incremented after each loop iteration. Code must be written to increment the counter. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
15. 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 total 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. (*)
[Incorrect] Incorrect. Refer to Section 5 Lesson 2.
1. Suppose you misspell a method name when you call it in your program. Which of the following explains why this gives you an exception? Mark for Review
(1) Points
Because the interpreter does not recognize this method since it was never initialized, the correct spelling of the method was initialized.
This will not give you an exception, it will give you an error when the program is compiled. (*)
Because the interpreter tries to read the method but when it finds the method you intended to use it crashes.
Because the parameters of the method were not met.
[Incorrect] Incorrect. Refer to Section 6 Lesson 2.
2. Which of the following could be a reason to throw an exception? Mark for Review
(1) Points
You have a fatal error in your program.
To make the user interface harder to navigate.
To eliminate exceptions from disrupting your program. (*)
You have encountered a Stack Overflow Error.
[Incorrect] Incorrect. Refer to Section 6 Lesson 2.
3. Which of the following correctly matches the symbol with its function? Mark for Review
(1) Points
(Choose all correct answers)
== (two equal signs) compares values of primitive types such as int or char. (*)
.equals() compares the value of non-primitive objects. (*)
== (two equal signs) compares the memory location of non-primitive objects. (*)
= (single equals sign) compares the value of primitive types such as int or char.
== (two equal signs) compares the values of non-primitive objects.
[Incorrect] Incorrect. Refer to Section 6 Lesson 2.
4. If an exception has already been thrown, what will the interpreter read next in the program? Mark for Review
(1) Points
The user input.
The next line of the program even if it is not the catch block of code.
Where the program catches the exception. (*)
The end of the program.
[Incorrect] Incorrect. Refer to Section 6 Lesson 2.
5. Which of the following would be a correct way to handle an index out of bounds exception? Mark for Review
(1) Points
(Choose all correct answers)
Throw the exception that prints out an error message. There is no need to have the catch handle the exception if it has already been thrown.
Do nothing, it will fix itself.
Throw the exception and catch it. In the catch, set the index to the index of the array closest to the one that was out of bounds. (*)
Rewrite your code to avoid the exception by not permititng the use of an index that is not inside the array. (*)
[Incorrect] Incorrect. Refer to Section 6 Lesson 2.
6. Which of the following statements print every element of the one dimensional array prices to the screen? Mark for Review
(1) Points
for(int i=1; i <= prices.length; i++){System.out.println(prices[i]);}
for(int i=0; i <= prices.length; i++){System.out.println(prices[i]);}
for(int i=0; i < prices.length; i++){System.out.println(prices[i]);} (*)
System.out.println(prices.length);
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
7. What is the output of the following segment of code?
Mark for Review
(1) Points
1111
This code doesn't compile.
11 (*)
111
321111
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
8. What is the output of the following segment of code if the command line arguments are "apples oranges pears"?
Mark for Review
(1) Points
oranges
pears (*)
This code does not compile.
args
apples
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
9. Which of the following declares a one dimensional array name scores of type int that can hold 14 values? Mark for Review
(1) Points
int[] scores=new scores int[14];
int score= new int[14];
int scores;
int[] scores=new int[14]; (*)
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
10. What is the output of the following segment of code?
Mark for Review
(1) Points
643432
1286864
This code does not compile.
666666 (*)
262423242322
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
11. Which of the following declares and initializes a one dimensional array named values of size 5 so that all entries contain 1? Mark for Review
(1) Points
int[] values={1};
int[] values={1,1,1,1,1}; (*)
int values[]={1,1,1,1,1,1};
int values={1,1,1,1,1};
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
12. What is the output of the following segment of code?
int array[][] = {{1,2,3},{3,2,1}};
for(int i=0;i<2;i++)
for(int j=0;j<3;j++)
System.out.print(2*array[1][1]); Mark for Review
(1) Points
444444 (*)
222222
246642
This code doesn't compile.
123321
[Correct] Correct
13. Which of the following declares a one dimensional array named "score" of type int that can hold 9 values? Mark for Review
(1) Points
int[] score=new int[9]; (*)
int score;
int score=new int[9];
int[] score;
[Correct] Correct
14. The following creates a reference in memory named k that can refer to six different integers via an index. True or false?
int k[]= int[6]; Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
15. What is the output of the following segment of code if the command line arguments are "apples oranges pears"?
Mark for Review
(1) Points
1
This code does not compile.
0
3 (*)
2
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
1. Which of the following is a goal of the object model? Mark for Review
(1) Points
(Choose all correct answers)
Concealing implementation. (*)
Protecting information and limiting other classes' ability to change or corrupt data. (*)
Data abstraction. (*)
Providing modular code that can be reused by other programs or classes. (*)
[Incorrect] Incorrect. Refer to Section 7 Lesson 5.
2. It is possible to inherit from an abstract class. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
3. Which of the following are true about abstract methods? Mark for Review
(1) Points
(Choose all correct answers)
They must be declared in an abstract class. (*)
They must be overloaded.
They must be overridden in a non-abstract subclass. (*)
They cannot have a method body. (*)
They may contain implementation.
[Incorrect] Incorrect. Refer to Section 7 Lesson 5.
4. Which of the following may be part of a class definition? Mark for Review
(1) Points
instance variables
instance methods
constructors
comments
all of the above (*)
[Incorrect] Incorrect. Refer to Section 7 Lesson 1.
5. Which of the following creates a Object from the Animal class listed below?
Mark for Review
(1) Points
Animal dog=new Animal();
Animal dog=new Animal(50,30); (*)
Animal dog=Animal(50,30);
Animal dog=new Animal(50);
[Incorrect] Incorrect. Refer to Section 7 Lesson 1.
Which of the following adds a constructor to the class below?
Mark for Review
(1) Points
(*)
[Correct] Correct
7. How is it possible for overloading to work? Mark for Review
(1) Points
There is no such thing as overloading.
Java Virtual Machine searches until it finds a constructor name and argument type match. (*)
The interpreter doesn't care what you name your constructors.
The code has to be declared as private.
[Incorrect] Incorrect. Refer to Section 7 Lesson 2.
8. A team is working on a coding project. They desire that all portions of their code should have access to the classes that they write. What access modifier should be used for each class? Mark for Review
(1) Points
public (*)
protected
private
default
All of the above
[Correct] Correct
9. Which of the following can be used as a parameter? Mark for Review
(1) Points
(Choose all correct answers)
Integers (*)
Objects (*)
Constructors
Strings (*)
Arrays (*)
[Incorrect] Incorrect. Refer to Section 7 Lesson 2.
10. You can create static class methods inside any Java class. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
11. Static classes can return instances of their parent class. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
12. Static classes can't return instances of the parent class when the parent class uses a private constructor. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 7 Lesson 3.
13. What is a hierarchy? Mark for Review
(1) Points
A structure that categorizes and organizes relationships among ideas and concepts of things with the most general at the top and the most specific at the bottom. (*)
A keyword that allows subclasses to access methods, data, and constructors from their parent class.
A programming philosophy that promotes simpler, more efficient coding by using existing code for new applications.
A programming philosophy that promotes protecting data and hiding implementation in order to preserve the integrity of data and methods.
[Correct] Correct
14. Where should the constructor for a superclass be called? Mark for Review
(1) Points
Anywhere inside the subclass.
The super constructor does not need to be called inside the subclass.
The last line in the constructor of the subclass.
Inside the main method of the subclass.
The first line of the constructor in the subclass. (*)
[Incorrect] Incorrect. Refer to Section 7 Lesson 4.
15. Which of the following correctly describes the use of the keyword super? Mark for Review
(1) Points
A keyword that allows subclasses to access methods, data, and constructors from their parent class. (*)
A keyword that restricts access to only inside the same class.
A keyword that allows access from anywhere.
A keyword that signals the end of a program.
[Correct] Correct
What will the following code segment output?
Mark for Review
(1) Points
"\\" (*)
"\\\"
\"\\\\\"
"\\\\\"
2. The String methods equals and compareTo perform similar functions and differ in their return type. True or false? Mark for Review
(1) Points
True (*)
False
3. Consider the following code snippet. What is printed?
String river = new String("Hudson"); System.out.println(river.length()); Mark for Review
(1) Points
8
7
Hudson
river
6 (*)
4. Which of the following defines a driver class? Mark for Review
(1) Points
Contains a main method and other static methods. (*)
Contains classes that define objects.
Contains a main method, a package, static methods, and classes that define objects.
None of the above.
5. The following defines a class keyword: Mark for Review
(1) Points
Provides the compiler information that identifies outside classes used within the current class.
Precedes the name of the class. (*)
Defines where this class lives relative to other classes, and provides a level of access control.
6. Which of the two diagrams below illustrate the general form of a Java program?
Mark for Review
(1) Points
Example A
Example B (*)
7. When importing another package into a class you must import only the package classes that will be called and not the entire package. True or false? Mark for Review
(1) Points
True
False (*)
8. What two values can a boolean variable have? Mark for Review
(1) Points
Relational and logic operators
Arithmetic and logic operators
True and false (*)
Numbers and characters
Integers and floating point types
9. Which line of Java code assigns the value of 5 raised to the power of 8 to a? Mark for Review
(1) Points
int a=Math.pow(5,8);
double a=Math.pow(5,8); (*)
double a=15^8;
int a=Math.pow(8,5);
double a=pow(8,5);
10. What is the output of the following lines of code?
int j=6,k=8,m=2,result;
result=j-k%3*m;
System.out.println(result); Mark for Review
(1) Points
-42
2 (*)
6
0
11. What will the method methodA print to the screen?
Mark for Review
(1) Points
15
6
3
18 (*)
12. Write a declaration statement that will hold a number like 2.541. Mark for Review
(1) Points
float number; (*)
boolean number;
char number;
int number;
13. For every opening curly brace { there must be a closing curly brace} or the program will not compile without error. True or False? Mark for Review
(1) Points
True (*)
False
14. You can return to the Eclipse Welcome Page by choosing Welcome from what menu? Mark for Review
(1) Points
Close
Edit
File
Help (*)
15. Tabs are used when more than one file is open in the edit area. True or False? Mark for Review
(1) Points
True (*)
False
1. Consider the following:
You are writing a class and are using a global variable. Inside a method you declare a local variable with the same name as the global variable.
This programming style is poor because inside the method the global variable will have precedence over the local variable with the same name.
True or false? Mark for Review
(1) Points
True
False (*)
2. Which of the following statements correctly assigns "3 times 10 to the 4th power" to the variable number? Mark for Review
(1) Points
double number=3(e4);
double number=3*10e4;
double number=3*10^4;
double number=3e4; (*)
3. Which line of code does not assign 3.5 to the variable x? Mark for Review
(1) Points
3.5=x; (*)
x=7.0/2.0;
double x=3.5
x=3.5;
4. A local variable has precedence over a global variable in a Java method. True or false? Mark for Review
(1) Points
True (*)
False
5. What does the following program output?
Mark for Review
(1) Points
"total cost: " 48
total cost: 48
"total cost: " 40
total cost: + 40
total cost: 40 (*)
6. For every opening curly brace { there must be a closing curly brace} or the program will not compile without error. True or False? Mark for Review
(1) Points
True (*)
False
7. The ______________ is the location into which you will store and save your files. Mark for Review
(1) Points
Perspective
Workspace (*)
Editor
None of the above
8. What symbols are required for a compiler to ignore a comment? Mark for Review
(1) Points
/*/
/*
*/
// (*)
9. The following program prints "Equal". True or false?
Mark for Review
(1) Points
True
False (*)
10. Suppose that s1 and s2 are two strings. Which of the statements or expressions are valid? Mark for Review
(1) Points
(Choose all correct answers)
String s3 = s1 + s2; (*)
String s3 = s1 - s2;
s1.compareTo(s2); (*)
int m = s1.length(); (*)
s1 <= s2
11. Declaring and instantiating a String is much like any other type of variable. However, once instantiated, they are final and cannot be changed. True or false? Mark for Review
(1) Points
True (*)
False
12. The following defines a package keyword: Mark for Review
(1) Points
Defines where this class lives relative to other classes, and provides a level of access control. (*)
Provides the compiler information that identifies outside classes used within the current class.
Precedes the name of the class.
13. The following defines a class keyword: Mark for Review
(1) Points
Provides the compiler information that identifies outside classes used within the current class.
Precedes the name of the class. (*)
Defines where this class lives relative to other classes, and provides a level of access control.
14. The following defines a class keyword: Mark for Review
(1) Points
Precedes the name of the class. (*)
Defines where this class lives relative to other classes, and provides a level of access control.
Provides the compiler information that identifies outside classes used within the current class.
15. When importing another package into a class you must import the entire package as well as the package classes that will be called. True or False? Mark for Review
(1) Points
True
False (*)
1. Match each of the following literals ('x', 10, 10.2, 100L, "hello") with its respective data type. Mark for Review
(1) Points
char, boolean, float, long, String
char, double, int, long, String
char, int, long, float, String
boolean, byte, int, long, Short
char, int, double, long, String (*)
2. Which line of Java code will assign the value of the square root of 11 to a variable named a? Mark for Review
(1) Points
int a=Math.sqrt(11);
double a=11^(1/2);
double a=Math.sqrt*11;
double a=Math.sqrt(11); (*)
double a=sqrt(11);
3. Which of the following statements displays 12345?
I. System.out.println( 123 * 100 + 45);
II. System.out.println("123" + 45);
III. System.out.println( 12 + "345"); Mark for Review
(1) Points
All of the above. (*)
I only.
I and II only.
II and III only.
None of the above.
4. Consider the following:
You are writing a class and are using a global variable. Inside a method you declare a local variable with the same name as the global variable.
This programming style is poor because inside the method the global variable will have precedence over the local variable with the same name.
True or false? Mark for Review
(1) Points
True
False (*)
5. Select the declaration and initialization statement that will hold the letter J. Mark for Review
(1) Points
String letter='J';
char letter='J'; (*)
int letter='J';
float letter='J';
6. For every opening curly brace { there does not need to be a closing curly brace} for the program to compile without error. True or False? Mark for Review
(1) Points
True
False (*)
7. Two variables are required to support a conversion of one unit of measure to another unit of measure. True or False? Mark for Review
(1) Points
True (*)
False
8. Eclipse provides views to help you navigate a hierarchy of information. True or False? Mark for Review
(1) Points
True (*)
False
9. The == operator can be used to compare two String objects. The result is always true if the two strings are identical. True or false? Mark for Review
(1) Points
True
False (*)
10. Consider the following code snippet
String forest = new String("Black");
System.out.println(forest.length());
What is printed? Mark for Review
(1) Points
Forest
7
6
Black
5 (*)
11. The following program prints "Equal". True or false?
Mark for Review
(1) Points
True (*)
False
12. The following defines a package keyword: Mark for Review
(1) Points
Provides the compiler information that identifies outside classes used within the current class.
Defines where this class lives relative to other classes, and provides a level of access control. (*)
Precedes the name of the class.
13. Which of the two diagrams below illustrate the general form of a Java program?
Mark for Review
(1) Points
Example A
Example B (*)
14. Which of the two diagrams below illustrate the general form of a Java program?
Mark for Review
(1) Points
Example A
Example B (*)
15. Which of the following defines a driver class? Mark for Review
(1) Points
Contains a main method and other static methods. (*)
Contains classes that define objects.
Contains a main method, a package, static methods, and classes that define objects.
None of the above.
1. In Eclipse, when you run a Java Application, the results are displayed in a new window. True or False? Mark for Review
(1) Points
True
False (*)
2. Multiple windows are used when more than one file is open in the edit area. True or False? Mark for Review
(1) Points
True
False (*)
3. What is the purpose of the Eclipse Editor Area and Views? Mark for Review
(1) Points
(Choose all correct answers)
To choose the file system location to delete a file.
To modify elements. (*)
To navigate a hierarchy of information. (*)
4. The following defines an import keyword: Mark for Review
(1) Points
Precedes the name of the class.
Defines where this class lives relative to other classes, and provides a level of access control.
Provides the compiler information that identifies outside classes used within the current class. (*)
5. The following defines a package keyword: Mark for Review
(1) Points
Precedes the name of the class.
Provides the compiler information that identifies outside classes used within the current class.
Defines where this class lives relative to other classes, and provides a level of access control. (*)
6. The following defines a class keyword: Mark for Review
(1) Points
Defines where this class lives relative to other classes, and provides a level of access control.
Precedes the name of the class. (*)
Provides the compiler information that identifies outside classes used within the current class.
7. The following defines a class keyword: Mark for Review
(1) Points
Provides the compiler information that identifies outside classes used within the current class.
Defines where this class lives relative to other classes, and provides a level of access control.
Precedes the name of the class. (*)
8. The following code is an example of creating a String reference:
String s;
True or false? Mark for Review
(1) Points
True (*)
False
9. Which of the following statements declares a String object called name? Mark for Review
(1) Points
String name; (*)
String name
double name;
int name;
10. Given the code below, which of the following would equate to true?
String s1 = "yes";
String s2 = "yes";
String s3 = new String(s1);
Mark for Review
(1) Points
(Choose all correct answers)
s1 == s2 (*)
s3.equals(s1) (*)
s1.equals(s2) (*)
s1 = s2
s3 == s1
11. Which line of Java code will assign the value of the square root of 11 to a variable named a? Mark for Review
(1) Points
double a=11^(1/2);
double a=sqrt(11);
double a=Math.sqrt(11); (*)
double a=Math.sqrt*11;
int a=Math.sqrt(11);
12. Which line of Java code assigns the value of 5 raised to the power of 8 to a? Mark for Review
(1) Points
int a=Math.pow(5,8);
int a=Math.pow(8,5);
double a=pow(8,5);
double a=15^8;
double a=Math.pow(5,8); (*)
13. Which line of Java code properly calculates the area of a triangle using A=1/2(b)(h) where b and h are Java primitive integers? Mark for Review
(1) Points
double A=1/2bh;
double A=(double)1/(double)2*b*h; (*)
double A=(double)(1/2)*b*h;
double A=1/2*b*h;
14. What is the output of the following lines of code?
int j=7,k=5,m=8,result;
result=j/m*k;
System.out.println(result); Mark for Review
(1) Points
0.175
280
4.375
0 (*)
15. Which of the following is not a legal name for a variable? Mark for Review
(1) Points
theLastValueButONe
zero
year2000
2bad (*)
1. What is the purpose of the Eclipse Editor Area and Views? Mark for Review
(1) Points
(Choose all correct answers)
To modify elements. (*)
To choose the file system location to delete a file.
To navigate a hierarchy of information. (*)
2. A _______________ is used to organize Java related files. Mark for Review
(1) Points
Project
Collection
Package (*)
Workspace
3. A workspace can have one or more stored projects. True or false? Mark for Review
(1) Points
True (*)
False
4. Which of the two diagrams below illustrate the general form of a Java program?
Mark for Review
(1) Points
Example A
Example B (*)
5. The following defines a class keyword: Mark for Review
(1) Points
Precedes the name of the class. (*)
Provides the compiler information that identifies outside classes used within the current class.
Defines where this class lives relative to other classes, and provides a level of access control.
6. The following defines a package keyword: Mark for Review
(1) Points
Provides the compiler information that identifies outside classes used within the current class.
Defines where this class lives relative to other classes, and provides a level of access control. (*)
Precedes the name of the class.
7. Which of the two diagrams below illustrate the general form of a Java program?
Mark for Review
(1) Points
Example A
Example B (*)
8. Examine the following code:
What is the value of variable x? Mark for Review
(1) Points
14
2 (*)
6
2.5
9. Which of the following is not correct Java code? Mark for Review
(1) Points
double x=Math.pow; (*)
double x=Math.sqrt(16);
double x=Math.pow(3,4)*5.0;
double x=Math.PI*5.0;
10. What is the output of the following lines of code?
int j=7,k=5,m=8,result;
result=j/m*k;
System.out.println(result); Mark for Review
(1) Points
0.175
280
4.375
0 (*)
11. What is the output of the following lines of code?
int j=6,k=8,m=2,result;
result=j-k%3*m;
System.out.println(result); Mark for Review
(1) Points
-42
0
2 (*)
6
12. What two values can a boolean variable have? Mark for Review
(1) Points
Arithmetic and logic operators
Integers and floating point types
Numbers and characters
Relational and logic operators
True and false (*)
13. What is printed by the following code segment?
Mark for Review
(1) Points
\\\\\\\\\\\\\\
\\\\
\\\\\\\ (*)
\\
14. Declaring and instantiating a String is much like any other type of variable. However, once instantiated, they are final and cannot be changed. True or false? Mark for Review
(1) Points
True (*)
False
15. Consider the following code snippet.
What is printed? Mark for Review
(1) Points
AtlanticPacificIndianArcticSouthern
Code does not compile
87658
55555
ArrayIndexOutofBoundsException is thrown (*)
1. In Java, a function is a method that must return a value. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 2 Lesson 14.
2. You have a Class representing Cat. Each Cat can meow, purr, catch mice, and so on. When you create a new cat, what is it called? Mark for Review
(1) Points
A subprogram
A subclass
A variable class
An instance (*)
A submethod
[Incorrect] Incorrect. Refer to Section 2 Lesson 14.
3. An event is any action initiated by the user that is designed to influence the program?s execution during play. Mark for Review
(1) Points
True (*)
False
[Correct] Correct
4. In Alice, what tab would you choose to start a new animation with a pre-populated world? Mark for Review
(1) Points
Starters (*)
Recent
My Projects
Blank Slate
[Correct] Correct
5. In Alice, which of the following programming statements moves the alien backward the distance to the asteroid, minus 2 meters? Mark for Review
(1) Points
this.Alien move backward {this.Alien getDistanceTo this.Asteroid -2} (*)
this.Asteroid move backward {this.Alien getDistanceTo this.Asteorid / 2}
this.Alien move backward {this.Alien getDistanceTo this.Asteroid * 2}
this.Alien move forward {this.Asteroid getDistanceTo this.Alien / 2}
[Correct] Correct
6. Alice uses built-in math operators. They are: Mark for Review
(1) Points
Add
Subtract
Multiply
Divide
All of the above (*)
[Incorrect] Incorrect. Refer to Section 2 Lesson 9.
7. Which of the following IF control structures command the blue tang fish to roll and simultaneously move down if it collides with a shark, or move forward if it does not collide with a shark? Mark for Review
(1) Points
(*)blue.tang is colliding shark
do togehter : bluetang move down 2, bluetang roll rigt 4
else
bluetang foward 2
[Correct] Correct
8. The Alice If control structure requires the false statement to be populated. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 2 Lesson 8.
9. When presenting your Alice animation, ensure that your presentation is thoroughly tested and complete. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
10. From your Alice lessons, at what point in the animation process do you confirm the items on the "Checklist for Animation Completion"? Mark for Review
(1) Points
At the end of the animation process. (*)
During the animation process.
At the beginning of the animation process.
After adding each procedure to the Code editor.
[Correct] Correct
11. In Alice, as part of the recording process you can demonstrate the events that are programmed within your animation. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
12. The initializer of a variable with a TextString value type could be (select all that apply): Mark for Review
(1) Points
(Choose all correct answers)
"Greetings" (*)
"Howdy" (*)
"4" (*)
None of the above.
[Incorrect] Incorrect. Refer to Section 2 Lesson 10.
13. Which is an example of the Boolean variable type? Mark for Review
(1) Points
3
An object
Hello World
True or False (*)
[Incorrect] Incorrect. Refer to Section 2 Lesson 10.
14. What is the result of the following code?
Mark for Review
(1) Points
x > y : true
x < y : false (*)
x > y : false
x < y : true
x > y : 1
x < y : 0
x > y : 0
x < y : 1
x > y : x > y
x < y : x < y
[Correct] Correct
15. A typical application uses various values and these values continuously change while the program is running. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
1. An instance variable can be saved and accessed later, even if the instance no longer exists. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 2.
2. In Greenfoot, methods can be called in the act method. When the Act button is clicked in the environment, the methods in the method body of the act method are executed. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
3. In Greenfoot, the body of the method is located in between which of the following characters? Mark for Review
(1) Points
Curly brackets { } (*)
Square brackets [ ]
Asterisks **
Parnetheses ( )
[Correct] Correct
4. In Greenfoot, which of the following options are not possible when associating an image file with an instance? Mark for Review
(1) Points
Import an image
Select an image from the Greenfoot library
Draw an image
Add a video (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 2.
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()
[Incorrect] Incorrect. Refer to Section 3 Lesson 3.
6. The list below displays components of the Greenfoot source code editor except one. Which one should be removed? Mark for Review
(1) Points
Instance creator (*)
Documentation
Method body
Comments
Class description
[Correct] Correct
7. From your Greenfoot lessons, a scenario is a game or simulation implemented in Greenfoot. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
8. In Greenfoot, after a subclass is created, what has to occur before instances can be added to the scenario? Mark for Review
(1) Points
Creation of an instance
Creation of source code
Editing of source code
Compilation (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 1.
9. In Greenfoot, after a subclass is created and compiled, you cannot edit the subclass's source code. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 1.
10. In Greenfoot, which of the following are execution controls? Mark for Review
(1) Points
(Choose all correct answers)
Speed (*)
Move
Turn
Run (*)
Act (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 1.
11. When designing a game in Greenfoot, it helps to define the actions that will take place in a textual storyboard. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
12. From your Greenfoot lessons, when does an if-else statement execute it's second code segment? Mark for Review
(1) Points
When a random number is less than 10.
When an instance is created.
If a condition is true.
If a condition is false. (*)
After the first code segment is executed.
[Incorrect] Incorrect. Refer to Section 3 Lesson 5.
13. From your Greenfoot lessons, which type of constructor can be used to automate creation of Actor instances? Mark for Review
(1) Points
Animal
Vector
Actor
World (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 5.
14. Which keyword indicates that Greenfoot needs to create a new object? Mark for Review
(1) Points
addObject
new (*)
newObject
newClass
[Incorrect] Incorrect. Refer to Section 3 Lesson 5.
15. From your Greenfoot lessons, which programming statement creates a new Bee object, and places it at x = 120, y = 100 in the world? Mark for Review
(1) Points
Move(120,100);
addWorld (new Bee( ), 120, 100);
addClass (new Bee( ), 120, 100);
addObject (new Bee( ), 120, 100); (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 5.
1. In Greenfoot you can only access the methods of the current class? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 9.
2. Use your Greenfoot knowldege: If an Actor class Fly has a variable defined to store the current speed, which of the following statements would successfully add a Fly and define the current speed as 2? Mark for Review
(1) Points
addObject (new Fly(2, 90), 150, 150);
addObject (new Fly(), 150, 150);
addObject (new Fly(), 2, 150, 150);
addObject (new Fly(2), 150, 150); (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 9.
3. In Java what is casting? Mark for Review
(1) Points
Casting is when we remove an object from the world
Casting is when we change the coordinates of an actor
Casting is when we reset the state of an instance.
Casting is when we want to tell the java compiler that a class we are accessing is really another type of class (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 9.
4. In Greenfoot when you use the method to retrieve input from the user, the scenario will continue to run in the background? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 7.
5. In Greenfoot, you can only interact with the scenario using a keyboard. Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 7.
6. In Greenfoot, what type of parameter does the isKeyDown method expect? Mark for Review
(1) Points
Integer
Boolean
Method
String (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 7.
7. Use your Greenfoot knowledge to answer the question. One reason to write a defined method in a class is to make it easier to read. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
8. In Greenfoot, which of the following statement is true about Defined Methods? Mark for Review
(1) Points
A defined method is only relevant to the Greenfoot Development team.
A defined method only relates to the World class.
A defined method must be called by your source code, normally in the Act method. (*)
A defined method is automatically executed once created.
[Incorrect] Incorrect. Refer to Section 3 Lesson 6.
9. In Greenfoot, defined methods must be used immediately. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 6.
10. In a Greenfoot loop constructor, which component is a counter that controls how many times the statement is executed? Mark for Review
(1) Points
Local loop
While loop
Condition
Loop variable (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 10.
11. Use your Greenfoot knowledge: An array object holds a single variable. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 10.
12. In Greenfoot, arrays are a way to hold and access multiple 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] Correct
13. In Greenfoot, what is the purpose of the variable type? Mark for Review
(1) Points
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.
Defines the access specifier used with the variable.
[Correct] Correct
14. Which operator is used to test if values are equal? Mark for Review
(1) Points
>
!>
== (*)
<
[Incorrect] Incorrect. Refer to Section 3 Lesson 8.
15. In Greenfoot, a constructor has a void return type. True or false? Mark for Review
(1) Points
True
False (*)
(1) Points
The symbol = is used in if statements and == is used in loops.
The symbol == is used to assign values to variables and the = is used in declarations.
The = is use to assign values to variables and the == compares values. (*)
There is no difference.
[Incorrect] Incorrect. Refer to Section 5 Lesson 1.
2. Which of the following correctly initializes an instance of Scanner, called "in", that reads input from the console screen? Mark for Review
(1) Points
Scanner in = new Scanner("System.in");
Scanner in = Scanner(System.in);
Scanner in = new Scanner(System.in); (*)
System.in in = new Scanner();
[Incorrect] Incorrect. Refer to Section 5 Lesson 1.
3. Determine whether this boolean expression evaluates to true or false:
!(3 < 4 && 6 > 6 || 6 <= 6 && 7 - 2 == 6) Mark for Review
(1) Points
True (*)
False
[Correct] Correct
4. What will print if the following Java code is executed?
if ((5.1 > 4.3 && 6.2 < 8.4) && !(7.2 < 3.5 || 1.2 == 2.1 || 2.2 != 2.25))
System.out.print("TRUE");
else
System.out.print("FALSE"); Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 5 Lesson 1.
5. Determine whether this boolean expression evaluates to true or false:
!(3 < 4 && 5 > 6 || 6 <= 6 && 7 - 1 == 6) Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 5 Lesson 1.
6. The three logic operators in Java are: Mark for Review
(1) Points
&, |, =
&&, ||, ! (*)
&&, !=, =
!=, =, ==
[Incorrect] Incorrect. Refer to Section 5 Lesson 1.
7. How would you use the ternary operator to rewrite this if statement?
if (gender == "male")
System.out.print("Mr.");
else
System.out.print("Ms."); Mark for Review
(1) Points
(gender == "male") ? "Ms." : "Mr." ;
System.out.print( (gender == "male") ? "Mr." : "Ms." ); (*)
(gender == "male") ? "Mr." : "Ms." ;
System.out.print( (gender == "male") ? "Ms." : "Mr." );
[Incorrect] Incorrect. Refer to Section 5 Lesson 1.
8. This keyword is used to instruct specific code when the input for a switch statement that does not match any of the cases. Mark for Review
(1) Points
switch
case
break
default (*)
None of the above
[Incorrect] Incorrect. Refer to Section 5 Lesson 1.
9. When the for loop condition statement is met the construct is exited. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 5 Lesson 2.
10. All of the following are essential to initializing a for loop, except which one? Mark for Review
(1) Points
Having an if statement. (*)
Initializing the iterator(i).
Having a conditional statement.
Updating the counter.
[Correct] Correct
11. The syntax below represents a valid initialization of a for loop counter. True or False?
public class ForLoop {
public static void main (String args[])
{
for (int i=10; i <20; i++)
{System.out.println("i: "+i); }
}
}
Mark for Review
(1) Points
True (*)
False
[Correct] Correct
12. What is the function of the word "break" in Java? Mark for Review
(1) Points
It continues onto the next line of code.
It does not exist in Java.
It stops the program from running.
It exits the current loop or case statement. (*)
[Incorrect] Incorrect. Refer to Section 5 Lesson 2.
13. A counter used in a for loop cannot be initialized within the For loop statement. True or False? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 5 Lesson 2.
14. In a for loop the counter is not automatically incremented after each loop iteration. Code must be written to increment the counter. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
15. 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 total 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. (*)
[Incorrect] Incorrect. Refer to Section 5 Lesson 2.
1. Suppose you misspell a method name when you call it in your program. Which of the following explains why this gives you an exception? Mark for Review
(1) Points
Because the interpreter does not recognize this method since it was never initialized, the correct spelling of the method was initialized.
This will not give you an exception, it will give you an error when the program is compiled. (*)
Because the interpreter tries to read the method but when it finds the method you intended to use it crashes.
Because the parameters of the method were not met.
[Incorrect] Incorrect. Refer to Section 6 Lesson 2.
2. Which of the following could be a reason to throw an exception? Mark for Review
(1) Points
You have a fatal error in your program.
To make the user interface harder to navigate.
To eliminate exceptions from disrupting your program. (*)
You have encountered a Stack Overflow Error.
[Incorrect] Incorrect. Refer to Section 6 Lesson 2.
3. Which of the following correctly matches the symbol with its function? Mark for Review
(1) Points
(Choose all correct answers)
== (two equal signs) compares values of primitive types such as int or char. (*)
.equals() compares the value of non-primitive objects. (*)
== (two equal signs) compares the memory location of non-primitive objects. (*)
= (single equals sign) compares the value of primitive types such as int or char.
== (two equal signs) compares the values of non-primitive objects.
[Incorrect] Incorrect. Refer to Section 6 Lesson 2.
4. If an exception has already been thrown, what will the interpreter read next in the program? Mark for Review
(1) Points
The user input.
The next line of the program even if it is not the catch block of code.
Where the program catches the exception. (*)
The end of the program.
[Incorrect] Incorrect. Refer to Section 6 Lesson 2.
5. Which of the following would be a correct way to handle an index out of bounds exception? Mark for Review
(1) Points
(Choose all correct answers)
Throw the exception that prints out an error message. There is no need to have the catch handle the exception if it has already been thrown.
Do nothing, it will fix itself.
Throw the exception and catch it. In the catch, set the index to the index of the array closest to the one that was out of bounds. (*)
Rewrite your code to avoid the exception by not permititng the use of an index that is not inside the array. (*)
[Incorrect] Incorrect. Refer to Section 6 Lesson 2.
6. Which of the following statements print every element of the one dimensional array prices to the screen? Mark for Review
(1) Points
for(int i=1; i <= prices.length; i++){System.out.println(prices[i]);}
for(int i=0; i <= prices.length; i++){System.out.println(prices[i]);}
for(int i=0; i < prices.length; i++){System.out.println(prices[i]);} (*)
System.out.println(prices.length);
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
7. What is the output of the following segment of code?
Mark for Review
(1) Points
1111
This code doesn't compile.
11 (*)
111
321111
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
8. What is the output of the following segment of code if the command line arguments are "apples oranges pears"?
Mark for Review
(1) Points
oranges
pears (*)
This code does not compile.
args
apples
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
9. Which of the following declares a one dimensional array name scores of type int that can hold 14 values? Mark for Review
(1) Points
int[] scores=new scores int[14];
int score= new int[14];
int scores;
int[] scores=new int[14]; (*)
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
10. What is the output of the following segment of code?
Mark for Review
(1) Points
643432
1286864
This code does not compile.
666666 (*)
262423242322
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
11. Which of the following declares and initializes a one dimensional array named values of size 5 so that all entries contain 1? Mark for Review
(1) Points
int[] values={1};
int[] values={1,1,1,1,1}; (*)
int values[]={1,1,1,1,1,1};
int values={1,1,1,1,1};
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
12. What is the output of the following segment of code?
int array[][] = {{1,2,3},{3,2,1}};
for(int i=0;i<2;i++)
for(int j=0;j<3;j++)
System.out.print(2*array[1][1]); Mark for Review
(1) Points
444444 (*)
222222
246642
This code doesn't compile.
123321
[Correct] Correct
13. Which of the following declares a one dimensional array named "score" of type int that can hold 9 values? Mark for Review
(1) Points
int[] score=new int[9]; (*)
int score;
int score=new int[9];
int[] score;
[Correct] Correct
14. The following creates a reference in memory named k that can refer to six different integers via an index. True or false?
int k[]= int[6]; Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
15. What is the output of the following segment of code if the command line arguments are "apples oranges pears"?
Mark for Review
(1) Points
1
This code does not compile.
0
3 (*)
2
[Incorrect] Incorrect. Refer to Section 6 Lesson 1.
1. Which of the following is a goal of the object model? Mark for Review
(1) Points
(Choose all correct answers)
Concealing implementation. (*)
Protecting information and limiting other classes' ability to change or corrupt data. (*)
Data abstraction. (*)
Providing modular code that can be reused by other programs or classes. (*)
[Incorrect] Incorrect. Refer to Section 7 Lesson 5.
2. It is possible to inherit from an abstract class. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
3. Which of the following are true about abstract methods? Mark for Review
(1) Points
(Choose all correct answers)
They must be declared in an abstract class. (*)
They must be overloaded.
They must be overridden in a non-abstract subclass. (*)
They cannot have a method body. (*)
They may contain implementation.
[Incorrect] Incorrect. Refer to Section 7 Lesson 5.
4. Which of the following may be part of a class definition? Mark for Review
(1) Points
instance variables
instance methods
constructors
comments
all of the above (*)
[Incorrect] Incorrect. Refer to Section 7 Lesson 1.
5. Which of the following creates a Object from the Animal class listed below?
Mark for Review
(1) Points
Animal dog=new Animal();
Animal dog=new Animal(50,30); (*)
Animal dog=Animal(50,30);
Animal dog=new Animal(50);
[Incorrect] Incorrect. Refer to Section 7 Lesson 1.
Which of the following adds a constructor to the class below?
Mark for Review
(1) Points
(*)
[Correct] Correct
7. How is it possible for overloading to work? Mark for Review
(1) Points
There is no such thing as overloading.
Java Virtual Machine searches until it finds a constructor name and argument type match. (*)
The interpreter doesn't care what you name your constructors.
The code has to be declared as private.
[Incorrect] Incorrect. Refer to Section 7 Lesson 2.
8. A team is working on a coding project. They desire that all portions of their code should have access to the classes that they write. What access modifier should be used for each class? Mark for Review
(1) Points
public (*)
protected
private
default
All of the above
[Correct] Correct
9. Which of the following can be used as a parameter? Mark for Review
(1) Points
(Choose all correct answers)
Integers (*)
Objects (*)
Constructors
Strings (*)
Arrays (*)
[Incorrect] Incorrect. Refer to Section 7 Lesson 2.
10. You can create static class methods inside any Java class. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
11. Static classes can return instances of their parent class. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
12. Static classes can't return instances of the parent class when the parent class uses a private constructor. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 7 Lesson 3.
13. What is a hierarchy? Mark for Review
(1) Points
A structure that categorizes and organizes relationships among ideas and concepts of things with the most general at the top and the most specific at the bottom. (*)
A keyword that allows subclasses to access methods, data, and constructors from their parent class.
A programming philosophy that promotes simpler, more efficient coding by using existing code for new applications.
A programming philosophy that promotes protecting data and hiding implementation in order to preserve the integrity of data and methods.
[Correct] Correct
14. Where should the constructor for a superclass be called? Mark for Review
(1) Points
Anywhere inside the subclass.
The super constructor does not need to be called inside the subclass.
The last line in the constructor of the subclass.
Inside the main method of the subclass.
The first line of the constructor in the subclass. (*)
[Incorrect] Incorrect. Refer to Section 7 Lesson 4.
15. Which of the following correctly describes the use of the keyword super? Mark for Review
(1) Points
A keyword that allows subclasses to access methods, data, and constructors from their parent class. (*)
A keyword that restricts access to only inside the same class.
A keyword that allows access from anywhere.
A keyword that signals the end of a program.
[Correct] Correct
What will the following code segment output?
Mark for Review
(1) Points
"\\" (*)
"\\\"
\"\\\\\"
"\\\\\"
2. The String methods equals and compareTo perform similar functions and differ in their return type. True or false? Mark for Review
(1) Points
True (*)
False
3. Consider the following code snippet. What is printed?
String river = new String("Hudson"); System.out.println(river.length()); Mark for Review
(1) Points
8
7
Hudson
river
6 (*)
4. Which of the following defines a driver class? Mark for Review
(1) Points
Contains a main method and other static methods. (*)
Contains classes that define objects.
Contains a main method, a package, static methods, and classes that define objects.
None of the above.
5. The following defines a class keyword: Mark for Review
(1) Points
Provides the compiler information that identifies outside classes used within the current class.
Precedes the name of the class. (*)
Defines where this class lives relative to other classes, and provides a level of access control.
6. Which of the two diagrams below illustrate the general form of a Java program?
Mark for Review
(1) Points
Example A
Example B (*)
7. When importing another package into a class you must import only the package classes that will be called and not the entire package. True or false? Mark for Review
(1) Points
True
False (*)
8. What two values can a boolean variable have? Mark for Review
(1) Points
Relational and logic operators
Arithmetic and logic operators
True and false (*)
Numbers and characters
Integers and floating point types
9. Which line of Java code assigns the value of 5 raised to the power of 8 to a? Mark for Review
(1) Points
int a=Math.pow(5,8);
double a=Math.pow(5,8); (*)
double a=15^8;
int a=Math.pow(8,5);
double a=pow(8,5);
10. What is the output of the following lines of code?
int j=6,k=8,m=2,result;
result=j-k%3*m;
System.out.println(result); Mark for Review
(1) Points
-42
2 (*)
6
0
11. What will the method methodA print to the screen?
Mark for Review
(1) Points
15
6
3
18 (*)
12. Write a declaration statement that will hold a number like 2.541. Mark for Review
(1) Points
float number; (*)
boolean number;
char number;
int number;
13. For every opening curly brace { there must be a closing curly brace} or the program will not compile without error. True or False? Mark for Review
(1) Points
True (*)
False
14. You can return to the Eclipse Welcome Page by choosing Welcome from what menu? Mark for Review
(1) Points
Close
Edit
File
Help (*)
15. Tabs are used when more than one file is open in the edit area. True or False? Mark for Review
(1) Points
True (*)
False
1. Consider the following:
You are writing a class and are using a global variable. Inside a method you declare a local variable with the same name as the global variable.
This programming style is poor because inside the method the global variable will have precedence over the local variable with the same name.
True or false? Mark for Review
(1) Points
True
False (*)
2. Which of the following statements correctly assigns "3 times 10 to the 4th power" to the variable number? Mark for Review
(1) Points
double number=3(e4);
double number=3*10e4;
double number=3*10^4;
double number=3e4; (*)
3. Which line of code does not assign 3.5 to the variable x? Mark for Review
(1) Points
3.5=x; (*)
x=7.0/2.0;
double x=3.5
x=3.5;
4. A local variable has precedence over a global variable in a Java method. True or false? Mark for Review
(1) Points
True (*)
False
5. What does the following program output?
Mark for Review
(1) Points
"total cost: " 48
total cost: 48
"total cost: " 40
total cost: + 40
total cost: 40 (*)
6. For every opening curly brace { there must be a closing curly brace} or the program will not compile without error. True or False? Mark for Review
(1) Points
True (*)
False
7. The ______________ is the location into which you will store and save your files. Mark for Review
(1) Points
Perspective
Workspace (*)
Editor
None of the above
8. What symbols are required for a compiler to ignore a comment? Mark for Review
(1) Points
/*/
/*
*/
// (*)
9. The following program prints "Equal". True or false?
Mark for Review
(1) Points
True
False (*)
10. Suppose that s1 and s2 are two strings. Which of the statements or expressions are valid? Mark for Review
(1) Points
(Choose all correct answers)
String s3 = s1 + s2; (*)
String s3 = s1 - s2;
s1.compareTo(s2); (*)
int m = s1.length(); (*)
s1 <= s2
11. Declaring and instantiating a String is much like any other type of variable. However, once instantiated, they are final and cannot be changed. True or false? Mark for Review
(1) Points
True (*)
False
12. The following defines a package keyword: Mark for Review
(1) Points
Defines where this class lives relative to other classes, and provides a level of access control. (*)
Provides the compiler information that identifies outside classes used within the current class.
Precedes the name of the class.
13. The following defines a class keyword: Mark for Review
(1) Points
Provides the compiler information that identifies outside classes used within the current class.
Precedes the name of the class. (*)
Defines where this class lives relative to other classes, and provides a level of access control.
14. The following defines a class keyword: Mark for Review
(1) Points
Precedes the name of the class. (*)
Defines where this class lives relative to other classes, and provides a level of access control.
Provides the compiler information that identifies outside classes used within the current class.
15. When importing another package into a class you must import the entire package as well as the package classes that will be called. True or False? Mark for Review
(1) Points
True
False (*)
1. Match each of the following literals ('x', 10, 10.2, 100L, "hello") with its respective data type. Mark for Review
(1) Points
char, boolean, float, long, String
char, double, int, long, String
char, int, long, float, String
boolean, byte, int, long, Short
char, int, double, long, String (*)
2. Which line of Java code will assign the value of the square root of 11 to a variable named a? Mark for Review
(1) Points
int a=Math.sqrt(11);
double a=11^(1/2);
double a=Math.sqrt*11;
double a=Math.sqrt(11); (*)
double a=sqrt(11);
3. Which of the following statements displays 12345?
I. System.out.println( 123 * 100 + 45);
II. System.out.println("123" + 45);
III. System.out.println( 12 + "345"); Mark for Review
(1) Points
All of the above. (*)
I only.
I and II only.
II and III only.
None of the above.
4. Consider the following:
You are writing a class and are using a global variable. Inside a method you declare a local variable with the same name as the global variable.
This programming style is poor because inside the method the global variable will have precedence over the local variable with the same name.
True or false? Mark for Review
(1) Points
True
False (*)
5. Select the declaration and initialization statement that will hold the letter J. Mark for Review
(1) Points
String letter='J';
char letter='J'; (*)
int letter='J';
float letter='J';
6. For every opening curly brace { there does not need to be a closing curly brace} for the program to compile without error. True or False? Mark for Review
(1) Points
True
False (*)
7. Two variables are required to support a conversion of one unit of measure to another unit of measure. True or False? Mark for Review
(1) Points
True (*)
False
8. Eclipse provides views to help you navigate a hierarchy of information. True or False? Mark for Review
(1) Points
True (*)
False
9. The == operator can be used to compare two String objects. The result is always true if the two strings are identical. True or false? Mark for Review
(1) Points
True
False (*)
10. Consider the following code snippet
String forest = new String("Black");
System.out.println(forest.length());
What is printed? Mark for Review
(1) Points
Forest
7
6
Black
5 (*)
11. The following program prints "Equal". True or false?
Mark for Review
(1) Points
True (*)
False
12. The following defines a package keyword: Mark for Review
(1) Points
Provides the compiler information that identifies outside classes used within the current class.
Defines where this class lives relative to other classes, and provides a level of access control. (*)
Precedes the name of the class.
13. Which of the two diagrams below illustrate the general form of a Java program?
Mark for Review
(1) Points
Example A
Example B (*)
14. Which of the two diagrams below illustrate the general form of a Java program?
Mark for Review
(1) Points
Example A
Example B (*)
15. Which of the following defines a driver class? Mark for Review
(1) Points
Contains a main method and other static methods. (*)
Contains classes that define objects.
Contains a main method, a package, static methods, and classes that define objects.
None of the above.
1. In Eclipse, when you run a Java Application, the results are displayed in a new window. True or False? Mark for Review
(1) Points
True
False (*)
2. Multiple windows are used when more than one file is open in the edit area. True or False? Mark for Review
(1) Points
True
False (*)
3. What is the purpose of the Eclipse Editor Area and Views? Mark for Review
(1) Points
(Choose all correct answers)
To choose the file system location to delete a file.
To modify elements. (*)
To navigate a hierarchy of information. (*)
4. The following defines an import keyword: Mark for Review
(1) Points
Precedes the name of the class.
Defines where this class lives relative to other classes, and provides a level of access control.
Provides the compiler information that identifies outside classes used within the current class. (*)
5. The following defines a package keyword: Mark for Review
(1) Points
Precedes the name of the class.
Provides the compiler information that identifies outside classes used within the current class.
Defines where this class lives relative to other classes, and provides a level of access control. (*)
6. The following defines a class keyword: Mark for Review
(1) Points
Defines where this class lives relative to other classes, and provides a level of access control.
Precedes the name of the class. (*)
Provides the compiler information that identifies outside classes used within the current class.
7. The following defines a class keyword: Mark for Review
(1) Points
Provides the compiler information that identifies outside classes used within the current class.
Defines where this class lives relative to other classes, and provides a level of access control.
Precedes the name of the class. (*)
8. The following code is an example of creating a String reference:
String s;
True or false? Mark for Review
(1) Points
True (*)
False
9. Which of the following statements declares a String object called name? Mark for Review
(1) Points
String name; (*)
String name
double name;
int name;
10. Given the code below, which of the following would equate to true?
String s1 = "yes";
String s2 = "yes";
String s3 = new String(s1);
Mark for Review
(1) Points
(Choose all correct answers)
s1 == s2 (*)
s3.equals(s1) (*)
s1.equals(s2) (*)
s1 = s2
s3 == s1
11. Which line of Java code will assign the value of the square root of 11 to a variable named a? Mark for Review
(1) Points
double a=11^(1/2);
double a=sqrt(11);
double a=Math.sqrt(11); (*)
double a=Math.sqrt*11;
int a=Math.sqrt(11);
12. Which line of Java code assigns the value of 5 raised to the power of 8 to a? Mark for Review
(1) Points
int a=Math.pow(5,8);
int a=Math.pow(8,5);
double a=pow(8,5);
double a=15^8;
double a=Math.pow(5,8); (*)
13. Which line of Java code properly calculates the area of a triangle using A=1/2(b)(h) where b and h are Java primitive integers? Mark for Review
(1) Points
double A=1/2bh;
double A=(double)1/(double)2*b*h; (*)
double A=(double)(1/2)*b*h;
double A=1/2*b*h;
14. What is the output of the following lines of code?
int j=7,k=5,m=8,result;
result=j/m*k;
System.out.println(result); Mark for Review
(1) Points
0.175
280
4.375
0 (*)
15. Which of the following is not a legal name for a variable? Mark for Review
(1) Points
theLastValueButONe
zero
year2000
2bad (*)
1. What is the purpose of the Eclipse Editor Area and Views? Mark for Review
(1) Points
(Choose all correct answers)
To modify elements. (*)
To choose the file system location to delete a file.
To navigate a hierarchy of information. (*)
2. A _______________ is used to organize Java related files. Mark for Review
(1) Points
Project
Collection
Package (*)
Workspace
3. A workspace can have one or more stored projects. True or false? Mark for Review
(1) Points
True (*)
False
4. Which of the two diagrams below illustrate the general form of a Java program?
Mark for Review
(1) Points
Example A
Example B (*)
5. The following defines a class keyword: Mark for Review
(1) Points
Precedes the name of the class. (*)
Provides the compiler information that identifies outside classes used within the current class.
Defines where this class lives relative to other classes, and provides a level of access control.
6. The following defines a package keyword: Mark for Review
(1) Points
Provides the compiler information that identifies outside classes used within the current class.
Defines where this class lives relative to other classes, and provides a level of access control. (*)
Precedes the name of the class.
7. Which of the two diagrams below illustrate the general form of a Java program?
Mark for Review
(1) Points
Example A
Example B (*)
8. Examine the following code:
What is the value of variable x? Mark for Review
(1) Points
14
2 (*)
6
2.5
9. Which of the following is not correct Java code? Mark for Review
(1) Points
double x=Math.pow; (*)
double x=Math.sqrt(16);
double x=Math.pow(3,4)*5.0;
double x=Math.PI*5.0;
10. What is the output of the following lines of code?
int j=7,k=5,m=8,result;
result=j/m*k;
System.out.println(result); Mark for Review
(1) Points
0.175
280
4.375
0 (*)
11. What is the output of the following lines of code?
int j=6,k=8,m=2,result;
result=j-k%3*m;
System.out.println(result); Mark for Review
(1) Points
-42
0
2 (*)
6
12. What two values can a boolean variable have? Mark for Review
(1) Points
Arithmetic and logic operators
Integers and floating point types
Numbers and characters
Relational and logic operators
True and false (*)
13. What is printed by the following code segment?
Mark for Review
(1) Points
\\\\\\\\\\\\\\
\\\\
\\\\\\\ (*)
\\
14. Declaring and instantiating a String is much like any other type of variable. However, once instantiated, they are final and cannot be changed. True or false? Mark for Review
(1) Points
True (*)
False
15. Consider the following code snippet.
What is printed? Mark for Review
(1) Points
AtlanticPacificIndianArcticSouthern
Code does not compile
87658
55555
ArrayIndexOutofBoundsException is thrown (*)
1. In Java, a function is a method that must return a value. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 2 Lesson 14.
2. You have a Class representing Cat. Each Cat can meow, purr, catch mice, and so on. When you create a new cat, what is it called? Mark for Review
(1) Points
A subprogram
A subclass
A variable class
An instance (*)
A submethod
[Incorrect] Incorrect. Refer to Section 2 Lesson 14.
3. An event is any action initiated by the user that is designed to influence the program?s execution during play. Mark for Review
(1) Points
True (*)
False
[Correct] Correct
4. In Alice, what tab would you choose to start a new animation with a pre-populated world? Mark for Review
(1) Points
Starters (*)
Recent
My Projects
Blank Slate
[Correct] Correct
5. In Alice, which of the following programming statements moves the alien backward the distance to the asteroid, minus 2 meters? Mark for Review
(1) Points
this.Alien move backward {this.Alien getDistanceTo this.Asteroid -2} (*)
this.Asteroid move backward {this.Alien getDistanceTo this.Asteorid / 2}
this.Alien move backward {this.Alien getDistanceTo this.Asteroid * 2}
this.Alien move forward {this.Asteroid getDistanceTo this.Alien / 2}
[Correct] Correct
6. Alice uses built-in math operators. They are: Mark for Review
(1) Points
Add
Subtract
Multiply
Divide
All of the above (*)
[Incorrect] Incorrect. Refer to Section 2 Lesson 9.
7. Which of the following IF control structures command the blue tang fish to roll and simultaneously move down if it collides with a shark, or move forward if it does not collide with a shark? Mark for Review
(1) Points
(*)blue.tang is colliding shark
do togehter : bluetang move down 2, bluetang roll rigt 4
else
bluetang foward 2
[Correct] Correct
8. The Alice If control structure requires the false statement to be populated. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 2 Lesson 8.
9. When presenting your Alice animation, ensure that your presentation is thoroughly tested and complete. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
10. From your Alice lessons, at what point in the animation process do you confirm the items on the "Checklist for Animation Completion"? Mark for Review
(1) Points
At the end of the animation process. (*)
During the animation process.
At the beginning of the animation process.
After adding each procedure to the Code editor.
[Correct] Correct
11. In Alice, as part of the recording process you can demonstrate the events that are programmed within your animation. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
12. The initializer of a variable with a TextString value type could be (select all that apply): Mark for Review
(1) Points
(Choose all correct answers)
"Greetings" (*)
"Howdy" (*)
"4" (*)
None of the above.
[Incorrect] Incorrect. Refer to Section 2 Lesson 10.
13. Which is an example of the Boolean variable type? Mark for Review
(1) Points
3
An object
Hello World
True or False (*)
[Incorrect] Incorrect. Refer to Section 2 Lesson 10.
14. What is the result of the following code?
Mark for Review
(1) Points
x > y : true
x < y : false (*)
x > y : false
x < y : true
x > y : 1
x < y : 0
x > y : 0
x < y : 1
x > y : x > y
x < y : x < y
[Correct] Correct
15. A typical application uses various values and these values continuously change while the program is running. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
1. An instance variable can be saved and accessed later, even if the instance no longer exists. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 2.
2. In Greenfoot, methods can be called in the act method. When the Act button is clicked in the environment, the methods in the method body of the act method are executed. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
3. In Greenfoot, the body of the method is located in between which of the following characters? Mark for Review
(1) Points
Curly brackets { } (*)
Square brackets [ ]
Asterisks **
Parnetheses ( )
[Correct] Correct
4. In Greenfoot, which of the following options are not possible when associating an image file with an instance? Mark for Review
(1) Points
Import an image
Select an image from the Greenfoot library
Draw an image
Add a video (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 2.
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()
[Incorrect] Incorrect. Refer to Section 3 Lesson 3.
6. The list below displays components of the Greenfoot source code editor except one. Which one should be removed? Mark for Review
(1) Points
Instance creator (*)
Documentation
Method body
Comments
Class description
[Correct] Correct
7. From your Greenfoot lessons, a scenario is a game or simulation implemented in Greenfoot. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
8. In Greenfoot, after a subclass is created, what has to occur before instances can be added to the scenario? Mark for Review
(1) Points
Creation of an instance
Creation of source code
Editing of source code
Compilation (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 1.
9. In Greenfoot, after a subclass is created and compiled, you cannot edit the subclass's source code. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 1.
10. In Greenfoot, which of the following are execution controls? Mark for Review
(1) Points
(Choose all correct answers)
Speed (*)
Move
Turn
Run (*)
Act (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 1.
11. When designing a game in Greenfoot, it helps to define the actions that will take place in a textual storyboard. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
12. From your Greenfoot lessons, when does an if-else statement execute it's second code segment? Mark for Review
(1) Points
When a random number is less than 10.
When an instance is created.
If a condition is true.
If a condition is false. (*)
After the first code segment is executed.
[Incorrect] Incorrect. Refer to Section 3 Lesson 5.
13. From your Greenfoot lessons, which type of constructor can be used to automate creation of Actor instances? Mark for Review
(1) Points
Animal
Vector
Actor
World (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 5.
14. Which keyword indicates that Greenfoot needs to create a new object? Mark for Review
(1) Points
addObject
new (*)
newObject
newClass
[Incorrect] Incorrect. Refer to Section 3 Lesson 5.
15. From your Greenfoot lessons, which programming statement creates a new Bee object, and places it at x = 120, y = 100 in the world? Mark for Review
(1) Points
Move(120,100);
addWorld (new Bee( ), 120, 100);
addClass (new Bee( ), 120, 100);
addObject (new Bee( ), 120, 100); (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 5.
1. In Greenfoot you can only access the methods of the current class? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 9.
2. Use your Greenfoot knowldege: If an Actor class Fly has a variable defined to store the current speed, which of the following statements would successfully add a Fly and define the current speed as 2? Mark for Review
(1) Points
addObject (new Fly(2, 90), 150, 150);
addObject (new Fly(), 150, 150);
addObject (new Fly(), 2, 150, 150);
addObject (new Fly(2), 150, 150); (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 9.
3. In Java what is casting? Mark for Review
(1) Points
Casting is when we remove an object from the world
Casting is when we change the coordinates of an actor
Casting is when we reset the state of an instance.
Casting is when we want to tell the java compiler that a class we are accessing is really another type of class (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 9.
4. In Greenfoot when you use the method to retrieve input from the user, the scenario will continue to run in the background? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 7.
5. In Greenfoot, you can only interact with the scenario using a keyboard. Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 7.
6. In Greenfoot, what type of parameter does the isKeyDown method expect? Mark for Review
(1) Points
Integer
Boolean
Method
String (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 7.
7. Use your Greenfoot knowledge to answer the question. One reason to write a defined method in a class is to make it easier to read. True or false? Mark for Review
(1) Points
True (*)
False
[Correct] Correct
8. In Greenfoot, which of the following statement is true about Defined Methods? Mark for Review
(1) Points
A defined method is only relevant to the Greenfoot Development team.
A defined method only relates to the World class.
A defined method must be called by your source code, normally in the Act method. (*)
A defined method is automatically executed once created.
[Incorrect] Incorrect. Refer to Section 3 Lesson 6.
9. In Greenfoot, defined methods must be used immediately. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 6.
10. In a Greenfoot loop constructor, which component is a counter that controls how many times the statement is executed? Mark for Review
(1) Points
Local loop
While loop
Condition
Loop variable (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 10.
11. Use your Greenfoot knowledge: An array object holds a single variable. True or false? Mark for Review
(1) Points
True
False (*)
[Incorrect] Incorrect. Refer to Section 3 Lesson 10.
12. In Greenfoot, arrays are a way to hold and access multiple 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] Correct
13. In Greenfoot, what is the purpose of the variable type? Mark for Review
(1) Points
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.
Defines the access specifier used with the variable.
[Correct] Correct
14. Which operator is used to test if values are equal? Mark for Review
(1) Points
>
!>
== (*)
<
[Incorrect] Incorrect. Refer to Section 3 Lesson 8.
15. In Greenfoot, a constructor has a void return type. True or false? Mark for Review
(1) Points
True
False (*)
EmoticonEmoticon