Test JAVA Fundamentals Final Exam
Test JAVA Fundamentals Final Exam
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 4
(Answer all questions in this section)
1. When importing another package into a class you must import only the package classe
True
False (*)
Correct
2. Which of the following defines a driver class?
True
False (*)
Correct
4. Consider the following code snippet.
What is printed?
55555
87658
AtlanticPacificIndianArcticSouthern
Code does not compile
ArrayIndexOutofBoundsException is thrown (*)
Incorrect. Refer to Section 4 Lesson 4.
5. The following program prints "Not Equal":
True or false?
True (*)
False
Correct
Page 1 of 10
Next
Summary
6. The String methods equals and compareTo perform similar functions and
True (*)
False
Correct
7. The == operator tests if two String references are pointing to the same
True (*)
False
Correct
8. Multiple windows are used when more than one file is open in the edit a
True
False (*)
9. When you open more than one file in Eclipse the system will ___________
10. In a project, 1 of the classes must contain a main method. True or False?
True (*)
False
Correct
Previous
Next
Page 2 of 10
Summary
True
False (*)
Correct
12. A combination of views and editors are referred to as _______________.
A workspace
A physical location
A perspective (*)
All of the above
Correct
13. What is the result when the following code segment is compiled and executed
int x = 22, y = 10;
double p = Math.sqrt( ( x + y ) /2);
System.out.println(p);
Correct
14. Which line of Java code will assign the value of the square root of 11 to a varia
double a=11^(1/2);
double a=sqrt(11);
int a=Math.sqrt(11);
double a=Math.sqrt*11;
double a=Math.sqrt(11); (*)
Correct
Section 5
(Answer all questions in this section)
15. The following prints Yes on the screen. True or false?
True
False (*)
Correct
Previous
Next
Page 3 of 10
Summary
18. All of the following are essential to initializing a for loop, except which on
20. A counter used in a for loop cannot be initialized within the For loop hea
True
False (*)
Correct
Previous
Next
Page 4 of 10
Summary
21. What will array arr contain after the following code segment has been executed
int [] arr = {5, 4, 2, 1, 0};
for (int i = 1; i < arr.length; i++)<br> {
arr[i - 1] += arr[i];
}
9, 6, 1, 3, 0
10, 6, 3, 1, 0
9, 6, 3, 1, 0 (*)
7, 3, 2, 1, 0
None of the above.
Correct
22. What is the output of the following segment of code?
456789
777777 (*)
555555
987654
This code doesn't compile.
Correct
23. What will be the content of the array variable table after executing the followin
1
0
0
1
0
0
1
1
1
0
0
1
1
1
0
0
1
0
0
1
1
0
1
0
1
1
1
0
0
1
0
0
1 (*)
1
0
0
Incorrect. Refer to Section 6 Lesson 1.
True
False (*)
Correct
Previous
Page 5 of 10
Next
Summary
26. Bubble Sort is a sorting algorithm that involves swapping the smallest v
True
False (*)
27. Which of the following sorting algorithms utilizes a "divide and conquer"
Sequential Search
Merge Sort (*)
Selection Sort
Binary Search
All of the above
28. A sequntial search is an iteration through the array that stops at the ind
True (*)
False
Correct
29. Of the options below, what is the fastest run-time?
n
n^2
lg(n) (*)
n*lg(n)
Section 7
(Answer all questions in this section)
30. If Oak extends Tree, it is possible to declare an object such that
Tree grandfatherT = new Oak();
True or false?
True (*)
False
Correct
Previous
Next
Page 6 of 10
Summary
33. Which of the following correctly describes the use of the keyword super?
34. Which of the following demonstrates the correct way to create an applet
True (*)
False
Correct
Previous
Page 7 of 10
Next
Summary
37. A constructor must have the same name as the class where it is declare
True (*)
False
Correct
38. What is the output of the following code segment:
int n = 13;
System.out.print(doNothing(n));
System.out.print(" ", n);
where the code from the method doNothing is:
public double doNothing(int n)
{
n = n + 8;
return (double) 12/n;
}
1.75, 13
0.571, 21
1.75, 21
0.571, 13 (*)
39. What operator do you use to call an object's constructor method and cre
+
new (*)
instanceOf
Correct
40. Identify the driver class that correctly initializes employees Jane and Bra
public class Employee {
private String name;
private int age;
private double salary;
public Employee(String n, int a, double s) {
name = n;
age = a;
salary = s;
}
//methods for this class would go here
}
Previous
Page 8 of 10
Next
Summary
42. Which of the following creates a class named Student with one construc
True (*)
False
Correct
Previous
Next
Page 9 of 10
Summary
46. Which segment of code represents a correct way to define a variable arg
48. Forward thinking helps when creating linear recursive methods. True or f
True
False (*)
Correct
49. Static classes can have different access specifiers than the parent class.
True (*)
False
Correct
50. A static variable is always publicly available. True or false?
True
False (*)
Correct
Previous
Page 10 of 10
Summary
Unanswered
Revie Statu
w
s Question
Section 4
When importing another
packa...
Mandator
y?
Points
Points
Available Awarded
14
12
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Section 5
The following prints Yes on
t...
Which of the following
could...
How would you use the
ternar...
Section 6
What will array arr contain ...
What is the output of the
fol...
What will be the content of
t...
The following array
declarat...
A logic error occurs if an u...
Section 7
21
19
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes