Final Exam
Final Exam
Final Exam
Mark for
Review
(1) Points
double A=1/2*b*h;
double A=1/2bh;
double A=(double)1/(double)2*b*h; (*)
double A=(double)(1/2)*b*h;
Incorrect. Refer to Section 4 Lesson 3.
2Which of the following is the name of a Java primitive data type?
.
Mark for
Review
(1) Points
Object
Rectangle
double (*)
String
Correct
3The following defines an import 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.
Incorrect. Refer to Section 4 Lesson 2.
4The 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.
Provides the compiler information that identifies outside classes
used within the current class.
Mark for
Review
(1) Points
What is printed?
55555
87658
AtlanticPacificIndianArcticSouthern
Code does not compile
ArrayIndexOutofBoundsException is thrown (*)
Incorrect. Refer to Section 4 Lesson 4.
Section 4
(Answer all questions in this section)
6.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
7.What is printed by the following code segment?
Mark for
Review
(1) Points
alligator (*)
albatross alligator
albatross
a1
Correct
8.Which of the following instantiates a String named name to Oracle?
Mark for
Review
(1) Points
String name;
String Oracle="name";
String name="name";
String name="Oracle"; (*)
Incorrect. Refer to Section 4 Lesson 4.
9.The == operator tests if two String references are pointing to the same
String object. True or false?
Mark for
Review
(1) Points
True (*)
False
Incorrect. Refer to Section 4 Lesson 4.
1In Eclipse, when you run a Java Application, the results are displayed in
0.a new window. True or False?
Mark for
Review
(1) Points
True
False (*)
Correct
Section 4
(Answer all questions in this section)
1A perspective is described as:
1.
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True
False (*)
Correct
1In the image below, identify the components.
3.
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Project
Workspace
Package (*)
Collection
Incorrect. Refer to Section 4 Lesson 1.
Section 5
(Answer all questions in this section)
1In an if-else construct the condition to be evaluated must end with a
5.semi-colon. True or false?
Mark for
Review
(1) Points
True
False (*)
Correct
Section 5
(Answer all questions in this section)
16.This keyword is used to instruct specific code when the input for
a switch statement that does not match any of the cases.
Switch
Case
Break
Default (*)
None of the above
Incorrect. Refer to Section 5 Lesson 1.
17.Which of the following correctly matches the switch statement
keyword to its function?
(1) Points
It is a post-test loop.
It is a modified while loop that allows the program to run
through the loop once before testing the boolean condition.
It continues looping until the condition becomes false.
All of the above. (*)
Incorrect. Refer to Section 5 Lesson 2.
20.What should replace the comment "//your answer here" in the
code below if the code is meant to take no action when i % 2 is 0
(in other words when i is even)?
for(int i = 0; i < 10; i++){<br> if(i%2 == 0)
//your answer here
else
k+=3;
}
continue; (*)
break;
return;
k+=1;
Correct
Section 6
(Answer all questions in this section)
2The following array declaration is valid. True or false?
1.
int k[] = new int[10];
Mark for
Review
(1) Points
True (*)
False
Incorrect. Refer to Section 6 Lesson 1.
2What is the output of the following segment of code?
2.
Mark for
Review
(1) Points
321111
11 (*)
111
1111
This code doesn't compile.
Incorrect. Refer to Section 6 Lesson 1.
2The following segment of code initializes a 2 dimensional array of
3.references. True or false?
String[][] array={{"a", "b", "C"},{"a", "b", "c"}};
Mark for
Review
(1) Points
True (*)
False
Correct
2What is the output of the following segment of code?
4.
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]);
444444 (*)
Mark for
Review
(1) Points
123321
246642
222222
This code doesn't compile.
Correct
2Of the options below, what is the fastest run-time?
5.
Mark for
Review
(1) Points
n
n^2
lg(n) (*)
n*lg(n)
Correct
Section 6
(Answer all questions in this section)
26.Why might a sequential search be inefficient?
Sequential Search
Merge Sort
Selection Sort
Binary Search (*)
All of the above
Incorrect. Refer to Section 6 Lesson 2.
28.Big-O Notation is used in Computer Science to describe the
performance of Sorts and Searches on arrays. True or false?
True (*)
False
Correct
29.A logic error occurs if an unintentional semicolon is placed at the
end of a loop initiation because the interpreter reads this as the
only line inside the loop, a line that does nothing. Everything that
follows the semicolon is interpreted as code outside of the loop.
True or false?
True
False (*)
Correct
Section 7
(Answer all questions in this section)
30.Which of the following is the correct way to code a method with
a return type an object Automobile?
Section 7
(Answer all questions in this section)
3How is it possible for overloading to work?
1.
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True (*)
False
Incorrect. Refer to Section 7 Lesson 2.
3Which of the following are access modifiers?
3.
Mark for
Review
(1) Points
Mark for
Review
(1) Points
(*)
None of the above.
Incorrect. Refer to Section 7 Lesson 4.
Mark for
Review
(1) Points
Section 7
(Answer all questions in this section)
36.Where should the constructor for a superclass be called?
True
False (*)
Correct
40.If it is possible to inherit from an abstract class, what must you do
to prevent a compiler error from occurring?
Section 7
(Answer all questions in this section)
4It is possible to inherit from an abstract class. True or false?
1.
Mark for
Review
(1) Points
True (*)
False
Incorrect. Refer to Section 7 Lesson 5.
4The basic unit of encapsulation in Java is the primitive data type. True
2.or false?
Mark for
Review
(1) Points
True
False (*)
Correct
4The constructor method must always have at least one parameter. True
3.or false?
Mark for
Review
(1) Points
True
False (*)
Correct
4Which of the following creates a method that returns a boolean value?
4.
Mark for
Review
(1) Points
(*)
Mark for
Review
(1) Points
Section 7
(Answer all questions in this section)
46.What is true about the code below:
Car car1=new Car();
Car car2=new Car();
car2=car1;
True
False (*)
Correct
True (*)
False
Incorrect. Refer to Section 7 Lesson 3.
50.Static classes are designed as thread safe class instances. True or
false?
True
False (*)
Correct