Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 4
(Answer all questions in this section)
1. What 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
2. Which line of Java code will assign the value of the square root of 11 to a
variable named a?
Mark for
Review
(1) Points
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
3. A _______________ is used to organize Java related files.
Mark for
Review
(1) Points
Project
Workspace
Package (*)
Collection
Correct
Mark for
Review
(1) Points
Collect
Compile (*)
Package
Assemble
Correct
5. A workspace can not have more than one stored projects. True or false?
Mark for
Review
(1) Points
True
False (*)
Correct
6.
A perspective is described as:
(1) Points
Correct
7.
Multiple windows are used when more than one file is open in the edit area. True or False?
True
False (*)
Correct
8.
The String methods equals and compareTo perform similar functions and differ in their return
Mark for
Review
(1) Points
True (*)
False
Correct
9.
True or false?
Mark for
Review
(1) Points
True (*)
False
Mark for
Review
(1) Points
\" \"
""\
""
\
""
\
"
\
" (*)
"
\
"
\
"
"
Correct
11.
True
False (*)
Correct
12.
String s1 = "abcdef";
String s2 = "abcdef";
String s3 = new String(s1);
Which of the following would equate to false?
(1) Points
s1 == s2
s1 = s2
s3 == s1 (*)
s1.equals(s2)
s3.equals(s1)
Correct
13.
form of a Java program?
Example A
Example B (*)
Correct
14.
Contains a main method, a package, static methods, and classes that define
objects.
Correct
Section 5
(Answer all questions in this section)
15.
if statement?
if (balance < 500)<
fee = 10;
else
fee = 0;
(1) Points
Correct
16.
This keyword is used to instruct specific code when the input for a switch statement that
Switch
Case
Break
Default (*)
Correct
17.
switch statements work on all input types including, but not limited to, int, char, and
Mark for
Review
(1) Points
True
False (*)
Correct
18.
All of the following are essential to initializing a for loop, except which one?
Correct
19.
In a for loop the counter is not automatically incremented after each loop iteration. Code
Mark for
Review
(1) Points
True (*)
False
Correct
20.
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
Section 6
(Answer all questions in this section)
n^2
lg(n) (*)
Mark for
n*lg(n)
Correct
22. Selection 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?
Mark for
Review
(1) Points
True (*)
False
Correct
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.
Correct
24. Big-O Notation is used in Computer Science to describe the performance of Sorts and Searches
on arrays. True or false?
Review
(1) Points
Mark for
True (*)
False
Correct
25. 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. (*)
Which of the following statements add all of the elements of the one dimensional
int total = 0;
for(int i = 0; i
total+=prices[i];
int total = 0;
for(int i = 0; i
total+=prices[i];
System.out.println(total); (*)
int total = 0;
for(int i = 1; i
total = total+prices[i];
System.out.println(prices);
int total = 0;
for(int i = 0; i
total+=prices[i];
System.out.println(prices);
Correct
27.
True (*)
False
Correct
28.
M
ark for Review
(1) Points
321111
11 (*)
111
1111
Correct
29.
What is the output of the following segment of code if the command line
M
ark for Review
(1) Points
6 (*)
Correct
Section 7
(Answer all questions in this section)
30.
Static classes can't return instances of the parent class when the parent class uses
True
False (*)
Mark for
Review
(1) Points
True (*)
False
Correct
32.
A linear recursive
method directly calls how many copies of itself in the recursive case?
Mark for
Review
(1) Points
1 (*)
2 or more
Correct
33.
Mark for
The super constructor does not need to be called inside the subclass.
Correct
34.
Which of the
Mark for
Review
(1) Points
Correct
35.
Applet?
(1) Points
It is the virtual machine that translates Java code into a representation that the
computer can understand.
What is encapsulation?
Correct
37.
Correct
38.
Mark for Review
(1) Points
Having more than one constructor with the same name but different
arguments. (*)
Having more than one constructor with different names and the same
arguments.
A type of access specifier that only allows access from inside the same class.
Correct
39.
protected (*)
public (*)
secured
private (*)
Correct
40.
False?
(1) Points
True (*)
False
Correct
41.
Choose the correct implementation of a public access modifier for the method
divide.
(1) Points
Correct
42.
True
False (*)
Correct
43.
Classes
Methods
Local variables
Method parameters
Correct
44.
What is Polymorphism?
A way of redefining methods with the same return type and parameters.
A way to create multiple methods with the same name but different
parameters.
The concept that a variable or reference can hold multiple types of objects. (*)
Correct
45.
Mark for Review
(1) Points
(*)
Correct
46.
method is called?
31
32
10
11 (*)
Correct
47.
True
False (*)
Correct
48.
least one parameter. True or false?
(1) Points
True
False (*)
Correct
49.
class below?
ThisClass t;
Correct
50.
declaration?
class Account{ ;
private int number;
private String name;;
public Account;
}
Mark for Review
(1) Points
Correct