Professional Documents
Culture Documents
Test FinalJAVAaa
Test FinalJAVAaa
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 4
1. In Eclipse, when you run a Java Application, where may the results display?
Mark for Review
(1) Points
Editor Window
Debug View
Task List
Correct
2. What are the Eclipse Editor Area and Views used for? Mark for Review (1)
Points
Correct
(1) Points
A workspace
A physical location
A perspective (*)
Correct
4. In the image below, identify the components.
Correct
5. A counter used in a For loop cannot be initialized within the For loop header.
True or false? Mark for Review (1) Points
True
False (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 4
6. In the code fragment below, the syntax for the for loop's initialization is
correct. True or false?
True
False (*)
Correct
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 (*)
Correct
8. Which of the two diagrams below illustrate the correct syntax for variables
used in an if-else statement? Mark for Review (1) Points
Example A (*)
Example B
Correct
9. What are Java's simple types? Mark for Review (1) Points
boolean, byte, char, double, float, int, long, and short (*)
Correct
10. Select the declaration and initialization statement that will hold the letter J.
Mark for Review
(1) Points
int letter='J';
float letter='J';
String letter='J';
Correct
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 4
11. Which of the following are relational operators in Java? Mark for Review
(1) Points
< (*)
<= (*)
!= (*)
Correct
int j=6,k=4,m=12,result;
result=j/m*k;
0 (*)
48
24
Correct
13. Which of the following is the name of a Java primitive data type? Mark for
Review
(1) Points
Object
Rectangle
double (*)
String
Correct
14. The three logic operators in Java are: Mark for Review (1) Points
!=,=,==
&&,!=,=
&,|,=
Correct
15. The six relational operators in Java are: Mark for Review (1) Points
>,<,=,!,<=,>=
>,<,==,!=,<=,>= (*)
>,<,=,!=,<=,>=
>,<,=,!=,=<,=>
Correct
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 5
16. All of the following are essential to initializing a FOR loop, except which
one? Mark for Review
(1) Points
Correct
17. Updating the input of a loop allows you to implement the code with the
next element rather than repeating the code always with the same element. True
or false? Mark for Review (1) Points
True (*)
False
Correct
int num = 7;
while(num >= 0)
num -= 3;
-2 (*)
Correct
19. Why are loops useful? Mark for Review (1) Points
int x=calculate(3,4);
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 5
21. A class can only have one constructor. True or false? Mark for Review (1)
Points
True
False (*)
Correct
22. What value will return for j when the setValue method is called?
Mark for Review (1) Points
31
32
10
11 (*)
Correct
23. The following statement compiles and executes. What do you know for
certain?
Correct
24. The following code creates an Object of type Animal. True or false?
True (*)
False
Correct
25. The following code creates an Object of type Horse. True or false?
True
False (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 5
26. The following code is a good example of using the this reference. True or
false?
True
False (*)
Correct
Section 6
True (*)
False
Correct
28. What is the output of the following segment of code? Mark for Review (1)
Points
456789
777777 (*)
555555
987654
Correct
29. Which of the following statements is not a valid array declaration? Mark
for Review
(1) Points
int number[];
float []averages;
double marks[5];
for(int i=0;i<2;i++)
for(int j=0;j<3;j++)
444444 (*)
123321
246642
222222
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 6
System.out.println(forest.length());
5 (*)
Black
Forest
Correct
32. Which of the following creates a String named Char? Mark for Review (1)
Points
char string;
char Char;
char char;
String char;
Correct
True
False (*)
Correct
34. The == operator can be used to compare two String objects. The result is
always true if the two strings are have the exact same characters in each
position of the String. True or false? Mark for Review (1) Points
True
False (*)
Correct
35. Which of the following could be a reason to throw an exception? Mark for
Review
(1) Points
Correct
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 6
36. 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.
(*)
= (single equals sign) compares the value of primitive types such as int or
char.
Correct
37. If an exception is thrown by a method, where can the catch for the
exception be? Mark for Review
(1) Points
The catch can be in the method that threw the exception or in any other
method that called the method that threw the exception. (*)
The catch must be immediately after the throw.
38. Suppose you are writing a program where the user is prompted to the give
coordinates where they believe the princess is inside of the castle.
Your program moves the prince to the coordinates that the user specified. If the
princess is not found at those coordinates, the user is given a clue that helps
them guess coordinates closer to the princess. The user is allowed to enter their
new guess of where the princess is.
Assume your program does not take into consideration the possibility that the
user may enter coordinates outside of the castle where the princess could not
be. What would be the result of the user entering coordinates outside of the
castle? How could this be handled in your code? Mark for Review
(1) Points
An exception would occur but could not be handled inside your code. The user
would have to restart the program and enter proper coordinates.
Section 7
True (*)
False
40. Which of the following is the correct way to call an overriden method
needOil() of a super class Robot in a subclass SqueakyRobot? Mark for Review
(1) Points
Robot.needOil(SqueakyRobot);
SqueakyRobot.needOil();
super.needOil(); (*)
needOil(Robot);
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
It is the virtual machine that translates Java code into a representation that
the computer can understand.
Correct
43. Which of the following is the correct way to code a method with a return
type an object Automobile? Mark for Review (1) Points
carA="Turbo";
return carA;}
carA.setTurbo("yes");
carA="Turbo";
return carA;}
upgrade(Automobile carA) Automobile{
carA.setTurbo("yes");
return carA;}
Correct
44. Choose the correct implementation of a public access modifier for the
method divide. Mark for Review (1) Points
Correct
45. Static methods can read instance variables. True or false? Mark for Review
(1) Points
True
False (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
46. Static methods can write to class variables. True or false? Mark for Review
(1) Points
True (*)
False
True
False (*)
Correct
48. Abstract classes cannot implement interfaces. True or false? Mark for
Review (1) Points
True
False (*)
True (*)
False
Correct
50. Abstract class cannot extend another abstract class. True or false? Mark
for Review
(1) Points
True
False (*)
Correct