Java Fundamentals Final Project
Java Fundamentals Final Project
Section 4
(Answer all questions in this section)
True or false?
True
False (*)
Correct
True or false?
True (*)
False
Correct
What is printed?
Cayrbniz
CayrbnizCayrbniz
yr (*)
ay
ArrayIndexOutofBoundsException is thrown
Correct
\" \"
""\
""
\
""
\
"
\
" (*)
"
\
"
\
"
"
Correct
s1 == s2
s1 = s2
s3 == s1 (*)
s1.equals(s2)
s3.equals(s1)
Correct
Section 4
(Answer all questions in this section)
Correct
Correct
8. Which of the following is not a legal name for a variable? Mark for Review
(1) Points
2bad (*)
zero
theLastValueButONe
year2000
Correct
9. Which of the following is the name of a Java primitive data type? Mark for Review
(1) Points
Object
Rectangle
double (*)
String
Correct
10.A workspace can not have more than one stored projects. True or Mark for Review
false? (1) Points
True
False (*)
Correct
Section 4
(Answer all questions in this section)
11.Multiple windows are used when more than one file is open in the Mark for Review
edit area. True or False? (1) Points
True
False (*)
12.What symbols are required for a compiler to ignore a comment? Mark for Review
(1) Points
// (*)
/*
*/
/*/
Correct
13.You need to _______________ Java code to generate a .class file Mark for Review
(1) Points
Collect
Compile (*)
Package
Assemble
Correct
14.What is the purpose of the Eclipse Editor Area and Views? Mark for Review
(1) Points
Correct
Section 5
(Answer all questions in this section)
15.switch statements work on all input types including, but not limited Mark for Review
to, int, char, and String. True or false? (1) Points
True
False (*)
Correct
Section 5
(Answer all questions in this section)
16.How would you use the ternary operator to rewrite this if statement? Mark for Review
(1) Points
if (gender == "female") System.out.print("Ms.");
else
System.out.print("Mr.");
17.Determine whether this boolean expression evaluates to true or false: Mark for Review
(1) Points
!(3<4&&6>6||6<=6&&7-2==6)
True (*)
False
18.In the code fragment below, the syntax for the for loop's initialization Mark for Review
is correct. True or false? (1) Points
True
False (*)
19.When the for loop condition statement is met the construct is exited. Mark for Review
True or false? (1) Points
True
False (*)
Correct
20.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
Section 6
(Answer all questions in this section)
21Which of the following statements add all of the elements of the one Mark for
. dimensional array prices, and then prints the sum to the screen? Review
(1) Points
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
22What is the output of the following segment of code if the command line Mark for
. arguments are "a b c d e f g"? Review
(1) Points
f
e (*)
c
d
This code doesn't compile.
321123
642
642246 (*)
312213
This code doesn't compile.
Correct
Correct
It is missing a semicolon.
It does not compile. (*)
It gives you an out of bounds exception.
There is nothing wrong with this code.
Correct
Section 6
(Answer all questions in this section)
26.Selection sort is a sorting algorithm that involves finding the Mark for Review
minimum value in the list, swapping it with the value in the first (1) Points
position, and repeating these steps for the remainder of the list. True
or false?
True (*)
False
Correct
27.Of the options below, what is the fastest run-time? Mark for Review
(1) Points
n
n^2
lg(n) (*)
n*lg(n)
Correct
28.Bubble Sort is a sorting algorithm that involves swapping the Mark for Review
smallest value into the first index, finding the next smallest value and (1) Points
swapping it into the next index and so on until the array is sorted.
True or false?
True
False (*)
Correct
Correct
Section 7
(Answer all questions in this section)
30.Which of the following is the correct way to code a method with a Mark for Review
return type an object Automobile? (1) Points
Correct
Section 7
(Answer all questions in this section)
31.Which of the following specifies accessibility to variables, methods, Mark for Review
and classes? (1) Points
Methods
Parameters
Overload constructors
Access modifiers (*)
protected (*)
public (*)
secured
default (no access modifier) (*)
private (*)
Correct
34.Which segment of code correctly defines a method that contains two Mark for Review
objects of class Tree as parameters? (1) Points
Correct
Section 7
(Answer all questions in this section)
36.Identify the correct way to declare an abstract class. Mark for Review
(1) Points
Correct
37.Abstract classes cannot implement interfaces. True or false? Mark for Review
(1) Points
True
False (*)
Correct
38.A linear recursion requires the method to call which direction? Mark for Review
(1) Points
Forward
Backward (*)
Both forward and backward
None of the above
Correct
39.There is only one copy a static class variable in the JVM. True or Mark for Review
false? (1) Points
True (*)
False
Correct
40.Static methods can't change any class variable values at run-time. Mark for Review
True or false? (1) Points
True
False (*)
Correct
Section 7
(Answer all questions in this section)
41In Java, an instance field referenced using the this keyword generates a Mark for
. compilation error. True or false? Review
(1) Points
True
False (*)
Correct
True (*)
False
Correct
43A constructor must have the same name as the class where it is declared. Mark for
. True or false? Review
(1) Points
True (*)
False
Correct
44Identify the driver class that correctly initializes employees Jane and Mark for
. Brandon. The Employee class is below. Review
(1) Points
public class Employee {
private String name;
private int age;
private double salary;
public Employee(String n, int a, double s) {
name = n;
age = a;
salary = s;
}
//methods for this class would go here
}
(*)
46.The following code creates an object of type Horse: Mark for Review
Whale a=new Whale(); (1) Points
True
False (*)
Correct
47.Which of the following is the correct way to call an overriden Mark for Review
method needOil() of a super class Robot in a subclass (1) Points
SqueakyRobot?
Robot.needOil(SqueakyRobot);
SqueakyRobot.needOil();
super.needOil(); (*)
needOil(Robot);
Correct
48.If a variable in a superclass is private, could it be directly accessed or Mark for Review
modified by a subclass? Why or why not? (1) Points
49.Which of the following show the correct UML representation of the Mark for Review
super class Planet and its subclass Earth? (1) Points
(*)