Академический Документы
Профессиональный Документы
Культура Документы
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?
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. The ______________ is the location into which you will store and save your files.
Perspective
Workspace (*)
Editor
None of the above
Correct
4. A workspace is:
The physical location onto which you will store and save your files.
The location where all projects are developed and modified.
The location where you can have one or more stored perspectives.
All of the above. (*)
Correct
5. A workspace can not have more than one stored projects. True or false?
True
False (*)
Correct
Page 1 of 10
Next Summary
Mark for
Review
(1) Points
File
Edit
Help (*)
Close
Correct
7. A perspective is described as:
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Mark for
Review
(1) Points
What is printed?
88888 (*)
88888888
1010778
101077810109
ArrayIndexOutofBoundsException is thrown
Incorrect. Refer to Section 4 Lesson 4.
Previous
Page 2 of 10
Next Summary
Mark for
Review
(1) Points
What is printed?
Cayrbniz
CayrbnizCayrbniz
yr (*)
ay
ArrayIndexOutofBoundsException is thrown
Incorrect. Refer to Section 4 Lesson 4.
12.Given the code:
String s = new String("abc");
Which of the following statements will change the length of s to the largest length?
Mark for
Review
(1) Points
s.trim()
s.replace("a", "aa")
s.substring(2)
s.toUpperCase()
None of the above will change the length of s. (*)
Correct
13.What is printed by the following code segment?
Mark for
Review
(1) Points
\\\\
\\\\\\\ (*)
\\\\\\\\\\\\\\
\\
Correct
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?
What is the value of count after the loop has finished?
Mark for
Review
(1) Points
Previous
Page 3 of 10
Next
Summary
True
False (*)
Incorrect. Refer to Section 5 Lesson 2.
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?
True (*)
False
Correct
18. Which of the following could be a reason to use a switch statement in a Java program?
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
19. Determine whether this boolean expression evaluates to true or false:
!(3<4&&6>6||6<=6&&7-2==6)
True (*)
False
Incorrect. Refer to Section 5 Lesson 1.
20. How would you use the ternary operator to rewrite this if statement?
if (balance < 500)<
fee = 10;
else
fee = 0;
Previous
Page 4 of 10
Next Summary
int scores;
int[] scores=new int[14]; (*)
int[] scores=new scores int[14];
int score= new int[14];
Incorrect. Refer to Section 6 Lesson 1.
22. What is the output of the following segment of code?
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 (*)
123321
246642
222222
This code doesn't compile.
Incorrect. Refer to Section 6 Lesson 1.
23. Which of the following declares and initializes a one dimensional array that can hold 5
Object reference types?
int number[];
float []averages;
double marks[5];
counter int[]; (*)
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
all elements are in the correct order?
Selection Sort
Merge Sort
Previous
Page 5 of 10
Next
Summary
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
Incorrect. Refer to Section 6 Lesson 2.
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. If a variable in a superclass is private, could it be directly accessed or modified by a
subclass? Why or why not?
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
Previous
Page 6 of 10
Next
Summary
Robot.needOil(SqueakyRobot);
SqueakyRobot.needOil();
super.needOil(); (*)
needOil(Robot);
Incorrect. Refer to Section 7 Lesson 4.
32. An access modifier is a keyword that allows subclasses to access methods, data, and
constructors from their parent class. True or false?
True (*)
False
Correct
33. What is encapsulation?
True (*)
False
Correct
35. Static methods can change instance variables at run-time. True or false?
True
False (*)
Incorrect. Refer to Section 7 Lesson 3.
Previous
Page 7 of 10
Next
Summary
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
38.Identify the correct way to declare an abstract class.
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True
False (*)
Incorrect. Refer to Section 7 Lesson 5.
40.A class can only have one constructor. True or false?
Mark for
Review
(1) Points
True
False (*)
Incorrect. Refer to Section 7 Lesson 1.
Previous
Page 8 of 10
Next
Summary
Mark for
Review
(1) Points
31
32
10
11 (*)
Incorrect. Refer to Section 7 Lesson 1.
42.What is the output of the following code segment:
int n = 13;
System.out.print(doNothing(n));
System.out.print(" ", n);
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Previous
Page 9 of 10
Next Summary
Mark for
Review
(1) Points
46. Which of the following specifies accessibility to variables, methods, and classes?
Methods
Parameters
Overload constructors
Access modifiers (*)
Correct
47. Which of the following correctly defines overloading?
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 variable argument method that returns an array.
A type of access specifier that only allows access from inside the same class.
Incorrect. Refer to Section 7 Lesson 2.
48. Which of the following is the correct definition of a parameter?
Previous
Page 10 of 10
Summary