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 declarations are correct?
Mark for Review
(1) Points
(Choose all correct answers)
double duty; (*)
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;
Correct
3. The ______________ is the location into which you will store and save your files.
Mark for Review
(1) Points
Perspective
Workspace (*)
Editor
Correct
4. A workspace is:
Mark for Review
(1) Points
The physical location onto which you will store and save your files.
The location where you can have one or more stored perspectives.
Correct
5. A workspace can not have more than one stored projects. True or false?
Mark for Review
(1) Points
True
False (*)
Correct
Section 4
(Answer all questions in this section)
6. You can return to the Eclipse Welcome Page by choosing Welcome from what menu?
Mark for
Review
(1) Points
File
Edit
Help (*)
Close
Correct
Contains a main method, a package, static methods, and classes that define objects.
Correct
What is printed?
88888 (*)
88888888
1010778
101077810109
ArrayIndexOutofBoundsException is thrown
Section 4
(Answer all questions in this section)
11.Consider the following code snippet.
Mark for
Review
(1) Points
What is printed?
Cayrbniz
CayrbnizCayrbniz
yr (*)
ay
ArrayIndexOutofBoundsException is thrown
s.replace("a", "aa")
s.substring(2)
s.toUpperCase()
Correct
\\\\
\\\\\\\ (*)
\\\\\\\\\\\\\\
\\
Correct
14.The following code is an example of creating a String reference:
Mark for
String s; Review
(1) Points
True or false?
True (*)
False
Correct
Section 5
(Answer all questions in this section)
15.How many times will the following loop be executed?
What is the value of x after the loop has finished? Mark for
What is the value of count after the loop has finished? Review
(1) Points
int count = 17;
int x = 1;
while(count > x){
x*=3;
count-=3;
}
4; 8; 27
3; 27; 8 (*)
5; 27; 8
5; 30; 5
3; 9; 11
Correct
Section 5
(Answer all questions in this section)
16. One advantage to using a while loop over a for loop is that a while loop always has a
counter. True or false? Mark for Review
(1) Points
True
False (*)
17. 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
18. Which of the following could be a reason to use a switch statement in a Java program?
Mark for Review
(1) Points
Because it allows the code to be run through until a certain conditional statement
is true.
Because it allows the program to run certain segments of code and neglect to run
others based on the input given. (*)
Because it terminates the current loop.
Because it allows the user to enter an input in the console screen and prints out a
message that the user input was successfully read in.
Correct
True (*)
False
20. How would you use the ternary operator to rewrite this if statement?
Mark for Review
if (balance < 500)< (1) Points
fee = 10;
else
fee = 0;
fee = ( balance < 500) ? 0 : 10;
Section 6
(Answer all questions in this section)
21. Which of the following declares a one dimensional array name scores of type int that
can hold 14 values? Mark for Review
(1) Points
int scores;
123321
246642
222222
23. Which of the following declares and initializes a one dimensional array that can hold 5
Object reference types? Mark for Review
(1) Points
String[] array=new String[5];
String[] array=String[4];
float []averages;
double marks[5];
Correct
25. Which of the following is a sorting algorithm that involves repeatedly incrementing
through the array and swapping 2 adjacent values if they are in the wrong order until Mark for Review
all elements are in the correct order? (1) Points
Selection Sort
Merge Sort
Bubble Sort (*)
Sequential Search
Binary Search
Section 6
(Answer all questions in this section)
26. Which of the following is the correct lexicographical order for the conents of the int
array? Mark for Review
(1) Points
{17, 1, 1, 83, 50, 28, 29, 3, 71, 22}
{71, 1, 3, 28,29, 50, 22, 83, 1, 17}
{1, 2, 7, 0, 9, 5, 6, 4, 8, 3}
Correct
27. Which searching algorithm involves using a low, middle, and high index value to find
the location of a value in a sorted set of data (if it exists)? Mark for Review
(1) Points
Sequential Search
Merge Sort
Selection Sort
Binary Search (*)
28. Big-O Notation is used in Computer Science to describe the performance of Sorts and
Searches on arrays. True or false? Mark for Review
(1) Points
True (*)
False
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 Mark for Review
does nothing. Everything that follows the semicolon is interpreted as code outside of (1) Points
the loop. True or false?
True
False (*)
Correct
Section 7
(Answer all questions in this section)
30. If a variable in a superclass is private, could it be directly accessed or modified by a
subclass? Why or why not? Mark for Review
(1) Points
Yes. A subclass inherits full access to all contents of its super class.
Yes. Any variable passed through inheritance can be changed, but private
methods cannot.
No. A private variable can only be modified by the same class with which it is
declared regardless of its inheritance. (*)
No. Nothing inherited by the super class can be changed in the subclass.
Correct
Section 7
(Answer all questions in this section)
31. Which of the following is the correct way to call an overriden method needOil() of a
super class Robot in a subclass SqueakyRobot? Mark for Review
(1) Points
Robot.needOil(SqueakyRobot);
SqueakyRobot.needOil();
super.needOil(); (*)
needOil(Robot);
32. An access modifier is a keyword that allows subclasses to access methods, data, and
constructors from their parent class. True or false? Mark for Review
(1) Points
True (*)
False
Correct
34. Any instance of the same class can assign a new value to a static variable. True or
false? Mark for Review
(1) Points
True (*)
False
Correct
35. Static methods can change instance variables at run-time. True or false?
Mark for Review
(1) Points
True
False (*)
Section 7
(Answer all questions in this section)
36.A base case can handle nested conditions. True or false?
Mark for
Review
(1) Points
True (*)
False
Correct
37.If 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
False (*)
Section 7
(Answer all questions in this section)
41.What value will return for j when the setValue method is called?
Mark for
Review
(1) Points
31
32
10
11 (*)
0.571, 21
1.75, 21
0.571, 13 (*)
There is a Car object that car1 referenced that is now slated for removal by the
garbage collector.
There is a Car object that car2 referenced that is now slated for removal by the
garbage collector. (*)
Incorrect. Refer to Section 7 Lesson 1.
int x=calculate(3,4);
Correct
Correct
Section 7
(Answer all questions in this section)
46. Which of the following specifies accessibility to variables, methods, and classes?
Mark for Review
(1) Points
Methods
Parameters
Overload constructors
Correct
A type of access specifier that only allows access from inside the same class.
A variable in a method declaration that gets passed into the method. (*)
49. Which segment of code represents a correct way to call a variable argument method
counter that takes in integers as its variable argument parameter? Mark for Review
(1) Points
counter(String a, int b);
counter(int[] numbers);
counter("one","two",String[] nums);