Professional Documents
Culture Documents
Review your answers, feedback, and question scores below. An asterisk (*) indicates a
correct answer.
Section 4
(Answer all questions in this section)
1. 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");
All of the above. (*)
I only.
I and II only.
II and III only.
None of the above.
True
False (*)
Correct
File
Edit
Help (*)
Close
Correct
5. A perspective is described as:
Mark for
Review
(1) Points
True
False (*)
Incorrect. Refer to Section 4 Lesson 1.
7. You need to _______________ Java code to generate a .class file
Mark for
Review
(1) Points
Collect
Compile (*)
Package
Assemble
Correct
8. Which of the two diagrams below illustrate the general form of a Java
program?
Mark for
Review
(1) Points
Example A
Example B (*)
Correct
9. Which of the following defines an object class?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
char string;
String Char; (*)
char Char;
char char;
String char;
Correct
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)
11What is printed by the following code segment?
.
Mark for
Review
(1) Points
alligator (*)
albatross alligator
albatross
a1
Correct
12The following program prints "Not Equal". True or false?
.
Mark for
Review
(1) Points
True
False (*)
Incorrect. Refer to Section 4 Lesson 4.
13The following code is an example of creating a String reference:
.
String s;
True or false?
Mark for
Review
(1) Points
True (*)
False
Incorrect. Refer to Section 4 Lesson 4.
14The == 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
Section 5
(Answer all questions in this section)
15How would you use the ternary operator to rewrite this if statement?
.
if (gender == "female") System.out.print("Ms.");
else
System.out.print("Mr.");
System.out.print( (gender == "female") ? "Mr." : "Ms." );
System.out.print( (gender == "female") ? "Ms." : "Mr." ); (*)
(gender == "female") ? "Mr." : "Ms." ;
(gender == "female") ? "Ms." : "Mr." ;
Correct
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True
False (*)
Correct
19. 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
20. When the for loop condition statement is met the construct is
exited. True or false?
Mark for
Review
(1) Points
True
False (*)
Correct
Mark for
Review
(1) Points
True (*)
False
Correct
22. Which of the following best describes lexicographical order?
Mark for
Review
(1) Points
Correct
23. Which of the following sorting algorithms utilizes a "divide and
conquer" technique to sort arrays with optimal speed?
Mark for
Review
(1) Points
Sequential Search
Merge Sort (*)
Selection Sort
Binary Search
All of the above
Correct
24. A sequntial search is an iteration through the array that stops at
the index where the desired element is found. True or false?
Mark for
Review
(1) Points
True (*)
False
Correct
25. 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
Mark for
Review
(1) Points
456789
777777 (*)
555555
987654
This code doesn't compile.
Correct
27Which of the following declares and initializes a two dimensional array
. that can hold 6 Object reference types?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True (*)
False
Incorrect. Refer to Section 6 Lesson 1.
29What is the output of the following segment of code?
.
int num[]={9,8,7,6,5,4,3,2,1};
for(int i=0;i<9;i=i+3)
System.out.print(num[i]);
9630
963 (*)
987654321
97531
Mark for
Review
(1) Points
Section 7
(Answer all questions in this section)
30Which of the following creates an object from the Animal class listed
. below:
Mark for
Review
(1) Points
Mark for
Review
(1) Points
31
32
10
11 (*)
Correct
32The basic unit of encapsulation in Java is the primitive data type. True
. or false?
Mark for
Review
(1) Points
True
False (*)
Correct
33What is wrong with the following class declaration?
.
class Account{ ;
private int number;
private String name;;
public Account;
}
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True (*)
False
Correct
Test: Java Fundamentals Final Exam
Review your answers, feedback, and question scores below. An asterisk (*) indicates a
correct answer.
Section 7
(Answer all questions in this section)
36. Which segment of code correctly defines a method that
contains two objects of class Tree as parameters?
True (*)
False
Correct
44. Which of the following is the correct way to call an overriden
method needOil() of a super class Robot in a subclass
SqueakyRobot?
Robot.needOil(SqueakyRobot);
SqueakyRobot.needOil();
super.needOil(); (*)
needOil(Robot);
Incorrect. Refer to Section 7 Lesson 4.
45. Consider the following method of the class Test:
public static List returnList(List list)
{
return list;
}
Which of the following program segments in Test's client class
will compile with no errors?
I. List nums = new ArrayList();
nums = Test.returnList(nums);
II. ArrayList nums = new ArrayList();
nums = Test.returnList(nums);
III. ArrayList nums1 = new ArrayList();
List nums2 = Test.returnList(nums1);
I only
I and III (*)
II only
II and III
I, II, and III
Correct
Test: Java Fundamentals Final Exam
Review your answers, feedback, and question scores below. An asterisk (*) indicates a
correct answer.
Section 7
(Answer all questions in this section)
46. What does it mean to override a method?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
48. The base case condition can work with a constant or variable.
True or false?
Mark for
Review
(1) Points
True (*)
False
Correct
49. Static methods can't change any class variable values at runtime. True or false?
Mark for
Review
(1) Points
True
False (*)
Correct
50. Non-final static class variables should be private to prevent
changes from other classes. True or false?
Mark for
Review
(1) Points
True (*)
False
Correct