Professional Documents
Culture Documents
Mark for
Review
(1) Points
True
False (*)
Correct
2.Suppose that str1 and str2 are two strings. Which of the statements or
expressions are valid?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
String name;
String Oracle="name";
String name="name";
String name="Oracle"; (*)
Correct
4.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?
True
Mark for
Review
(1) Points
False (*)
Correct
5.What is printed by the following code segment?
Mark for
Review
(1) Points
\\\\
\\\\\\\ (*)
\\\\\\\\\\\\\\
\\
(Answer all questions in this section)
6. You need to _______________ Java code to generate a .class file
Mark for
Review
(1) Points
Collect
Compile (*)
Package
Assemble
Correct
7. When you open more than one file in Eclipse the system will
__________________.
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True
False (*)
Correct
9. What is the purpose of the Eclipse Editor Area and Views?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True
False (*)
Correct
(Answer all questions in this section)
11The 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.
Correct
12Which 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.
Correct
13What is the output of the following lines of code?
.
int j=6,k=4,m=12,result;
result=j/m*k;
System.out.println(result);
Mark for
Review
(1) Points
2
0 (*)
48
24
Correct
14Examine the following code:
.
Mark for
Review
(1) Points
Section 5
(Answer all questions in this section)
15When the for loop condition statement is met the construct is exited. True or
. false?
Mark for
Review
(1) Points
True
False (*)
Correct
(Answer all questions in this section)
16. 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
17. Which of the following is true about a do-while loop?
Mark for
Review
(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. (*)
Correct
18. The three logic operators in Java are:
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True
False (*)
Incorrect. Refer to Section 5 Lesson 1.
20. switch statements work on all input types including, but not limited to, int,
char, and String. True or false?
Mark for
Review
(1) Points
True
False (*)
Correct
(Answer all questions in this section)
21What will be the content of the array variable table after executing the following
. code?
Mark for
Review
(1) Points
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
Mark for
Review
(1) Points
9, 6, 1, 3, 0
10, 6, 3, 1, 0
9, 6, 3, 1, 0 (*)
7, 3, 2, 1, 0
None of the above.
Incorrect. Refer to Section 6 Lesson 1.
23Which of the following declares and initializes a two dimensional array with 3
. rows and 2 columns?
Mark for
Review
(1) Points
int a={{1,1},{1,1},{1,1}};
int[][] a={{1,1},{1,1},{1,1}}; (*)
int[][] a={{1,1,1},{1,1,1}};
int a={{1,1,1},{1,1,1}};
Incorrect. Refer to Section 6 Lesson 1.
24double array[] = new double[8];
.
After execution of this statement, which of the following are true?
Mark for
Review
(1) Points
array[0] is undefined
array[4] is null
array[2] is 8
array.length is 8 (*)
Correct
25Selection sort is a sorting algorithm that involves finding the minimum value in
. the list, swapping it with the value in the first position, and repeating these
steps for the remainder of the list. True or false?
True (*)
False
Mark for
Review
(1) Points
Mark for
Review
(1) Points
n
n^2
lg(n) (*)
n*lg(n)
Correct
27. Bubble Sort is a sorting algorithm that involves swapping the smallest value
into the first index, finding the next smallest value and swapping it into the
next index and so on until the array is sorted. True or false?
Mark for
Review
(1) Points
True
False (*)
Incorrect. Refer to Section 6 Lesson 2.
28. Why might a sequential search be inefficient?
Mark for
Review
(1) Points
It utilizes the "divide and conquer" method, which makes the algorithm
more error prone.
It requires incrementing through the entire array in the worst case,
which is inefficient on large data sets. (*)
It involves looping through the array multiple times before finding the
value, which is inefficient on large data sets.
It is never inefficient.
Incorrect. Refer to Section 6 Lesson 2.
29. What are exceptions used for in Java?
Mark for
Review
(1) Points
Exceptions have no use, they are just a part of the Java language.
Helping the interpreter compile code quicker and handle user
interfaces.
Making the program easier to use for the user and reducing the
possibilities of errors occuring.
Correct
Section 7
(Answer all questions in this section)
30. Which of the following show the correct UML representation of the super
class Planet and its subclass Earth?
Mark for
Review
(1) Points
(*)
31. Which of the following correctly describes the use of the keyword super?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True (*)
False
Correct
33. Why are hierarchies useful for inheritance?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True
False (*)
Correct
35. Which of the following access modifiers doesn't work with a static variable?
Mark for
Review
(1) Points
public
protected
friendly (*)
default
private
Correct
(Answer all questions in this section)
36Static methods can read instance variables. True or false?
.
Mark for
Review
(1) Points
True
False (*)
Correct
37Identify the error(s) in the class below. Choose all that apply.
.
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True (*)
False
Incorrect. Refer to Section 7 Lesson 2.
39Which of the following is the correct way to code a method with a return type an
. object Automobile?
Mark for
Review
(1) Points
Automobile upgrade(String carA){
carA="Turbo";
return carA;}
Automobile upgrade(Automobile carA){
carA.setTurbo("yes");
return carA;} (*)
String upgrade(String carA){
carA="Turbo";
return carA;}
upgrade(Automobile carA) Automobile{
carA.setTurbo("yes");
return carA;}
None of the above. It is not possible to return an object.
Correct
40Which of the following specifies accessibility to variables, methods, and classes?
.
Mark for
Review
(1) Points
Methods
Parameters
Overload constructors
Access modifiers (*)
Incorrect. Refer to Section 7 Lesson 2.
(Answer all questions in this section)
41Which of the following is the definition for a variable argument method?
.
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True (*)
False
Correct
43The basic unit of encapsulation in Java is the primitive data type. True or false?
.
Mark for
Review
(1) Points
True
False (*)
Correct
44Which of the following creates a method that compiles with no errors in the
. class?
Mark for
Review
(1) Points
(*)
Mark for
Review
(1) Points
True
False (*)
Correct
(Answer all questions in this section)
46The following code creates an object of type Animal. True or false?
.
Animal a=new Animal();
Mark for
Review
(1) Points
True (*)
False
Correct
47Consider:
.
public class YourClass{ public YourClass(int i){/*code*/} // more code...}
To instantiate YourClass, what would you write?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True
False (*)
Incorrect. Refer to Section 7 Lesson 5.
50If we override the toString() method with the code below, what would be the
. result of printing?
Mark for
Review
(1) Points
It would print the array one element at a time. The console screen would
display: 0 18 215 64 11 42
It would print the string returned from the method. The console screen
would display: [0,18,215,64,11,42,] (*)
It would print the array backwards. The console screen would display: 42 11
64 215 18 0
It would print the string returned from the method. The console screen
would display: {0, 18, 215, 64, 11, 42}
Correct