Java Fundamental Final Exam
Java Fundamental Final Exam
Correct
2The following program prints "Not Equal". True or false?
Mark for
.
Review
(1) Points
True
False (*)
Page 1 of 10
Section 4
(Answer all questions in this section)
6. For every opening curly brace { there does not need to be a
Mark for Review
closing curly brace} for the program to compile without
(1) Points
error. True or False?
True
False (*)
Correct
8. In Eclipse, when you run a Java Application, the results are
Mark for Review
displayed in a new window. True or False?
(1) Points
True
False (*)
Correct
9. Eclipse does not provide views to help you navigate a
Mark for Review
hierarchy of information. True or False?
(1) Points
True
False (*)
Correct
10. The ______________ is the location into which you will
Mark for Review
store and save your files.
(1) Points
Perspective
Workspace (*)
Editor
None of the above
Page 2 of 10
he
Mark for Review
following
(1) Points
defines a
package
keyword:
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
13. What two values can a boolean variable
Mark for Review
have?
(1) Points
Numbers and characters
True and false (*)
Relational and logic operators
Arithmetic and logic operators
Integers and floating point types
Correct
14. What is the result when the following code
Mark for Review
segment is compiled and executed?
(1) Points
int x = 22, y = 10;
double p = Math.sqrt( ( x + y ) /2);
System.out.println(p);
Syntax error "sqrt(double) in
java.lang.Math cannot be applied to
int"
4.0 is displayed (*)
2.2 is displayed
5.656854249492381 is displayed
ClassCastException
Section 5
(Answer all questions in this section)
15. The six relational operators in Java are:
Mark for Review
(1) Points
>,<,=,!,<=,>=
>,<,==,!=,<=,>= (*)
>,<,=,!=,<=,>=
>,<,=,!=,=<,=>
Correct
Page 3 of 10
Section 5
(Answer all questions in this section)
16. Which of the following correctly
Mark for Review
matches the switch statement
(1) Points
keyword to its function?
(Choose all correct answers)
switch: tells the compiler the
value to compare the input
against
default: signals what code to
execute if the input does not
match any of the cases (*)
case: signals what code is
executed if the user input
matches the specified
element (*)
if: records the user's input
and sends it to the case
statements to find a possible
match
switch: identifies what
element will be compared to
the element of the case
statements to find a possible
match (*)
Incorrect. Refer to Section
5 Lesson 1.
17. Determine whether this boolean
Mark for Review
expression evaluates to true or
(1) Points
false:
!(3<4&&6>6||6<=6&&7-2==6)
True (*)
False
Correct
19. Why are loops useful?
Mark for Review
(1) Points
They save programmers
from having to rewrite code.
They allow for repeating
code a variable number of
times.
They allow for repeating
code until a certain argument
is met.
All of the above. (*)
Correct
20. When the for loop condition
Mark for Review
statement is met the construct is
(1) Points
exited. True or false?
True
False (*)
Correct
Page 4 of 10
Binary
Mark for
searches
Review
can be
(1) Points
performe
d on
sorted
and
unsorted
data.
True or
false?
True
False (*)
Correct
23. Which of the following is the correct lexicographical order
Mark for
for the conents of the int array?
Review
(1) Points
{17, 1, 1, 83, 50, 28, 29, 3, 71, 22}
{71, 1, 3, 28,29, 50, 22, 83, 1, 17}
{83, 71, 50, 29, 28, 22, 17, 3, 1, 1}
{1, 1, 17, 22, 28, 29, 3, 50, 71, 83}
{1, 2, 7, 0, 9, 5, 6, 4, 8, 3}
{1, 1, 3, 17, 22, 28, 29, 50, 71, 83} (*)
111
011
001
100
010
001
100
110
1 1 1 (*)
001
010
100
Incorrect. Refer to Section 6 Lesson 1.
Section 6
(Answer all questions in this section)
26.Which of the following
Mark for Review
declares and initializes a two
(1) Points
dimensional array that can
hold 6 Object reference
types?
String[] array=new
String[6];
Object array=new
Object[6];
Object[][] array=new
Object[2][3]; (*)
String[][]
array=String[6];
Correct
27.Which of the following
Mark for Review
declares and initializes a one
(1) Points
dimensional array named
values of size 5 so that all
entries contain 1?
int[] values={1,1,1,1,1};
(*)
int[] values={1};
int values={1,1,1,1,1};
int
values[]={1,1,1,1,1,1};
Incorrect. Refer to
Section 6 Lesson 1.
28.Which of the following
Mark for Review
declares a one dimensional
(1) Points
array named names of size 8
so that all entries can be
Strings?
String names=new
String[8];
String[] name=new
Strings[8];
String[] names=new
String[8]; (*)
String[]
name=String[8];
Correct
29.What does it mean to catch
Mark for Review
an exception?
(1) Points
It means you have fixed
the error.
It means to throw it.
It means to handle it. (*)
It means there was never
an exception in your
code.
Incorrect. Refer to
Section 6 Lesson 3.
Section 7
(Answer all questions in this section)
30.If it is possible to inherit
Mark for Review
from an abstract class, what
(1) Points
must you do to prevent a
compiler error from
occurring?
(Choose all correct answers)
It is not possible to
inherit from an abstract
class.
Create all new methods
and variables different
from the parent class.
Override all abstract
methods from the parent
class. (*)
Declare the child class
as abstract. (*)
Correct
Page 6 of 10
Section 7
(Answer all questions in this section)
31. What is Polymorphism?
Mark for
Review
(1) Points
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.
A class that cannot be initiated.
The concept that a variable or reference can hold multiple types
of objects. (*)
Correct
32. Abstract classes cannot implement interfaces. True or false?
Mark for
Review
(1) Points
True
False (*)
Correct
33. Which of the following creates an object from the Animal class listed
Mark for
below:
Review
(1) Points
Animal cat=new Animal();
Animal cat=Animal(50,30);
Animal cat=new Animal(50,30); (*)
Animal cat=new Animal(50);
Correct
34. Which of the following creates an instance of the class below?
Mark for
Review
(1) Points
Page 7 of 10
Section 7
(Answer all questions in this section)
36. Java's garbage collection is when
Mark for Review
all references to an object are
(1) Points
gone, the memory used by the
object is automatically
reclaimed. True or false?
True (*)
False
Correct
37. If the return type from a method
Mark for Review
is boolean then 2.5 is a valid
(1) Points
return value. True or false?
True
False (*)
Correct
38. A class always has a constructor.
Mark for Review
True or false?
(1) Points
True (*)
False
Correct
39. Which segment of code
Mark for Review
represents a correct way to
(1) Points
define a variable argument
method?
String easyArray(String ...
elems) {//code} (*)
String easyArray(... String
elems) {//code}
String ... easyArray(String
elems) {//code}
Integer easyArray ... (int
elems) {//code}
Correct
40. How is it possible for
Mark for Review
overloading to work?
(1) Points
There is no such thing as
overloading.
The code has to be declared
as private.
The interpreter doesn't care
what you name your
constructors.
Java Virtual Machine
searches until it finds a
constructor name and
argument type match. (*)
Correct
Page 8 of 10
Section 7
(Answer all questions in this section)
41. Which of the following specifies
Mark for Review
accessibility to variables,
methods, and classes? (1) Points
Methods
Parameters
Overload constructors
Access modifiers (*)
Correct
42. Which of the following could be
Mark for Review
a reason to return an object?
(1) Points
Because you wish to be able
to use that object inside of
the method.
It has faster performance
than returning a primitive
type.
The method makes changes
to the object and you wish to
continue to use the updated
object outside of the method.
(*)
None of the above. It is not
possible to return an object.
Correct
43. Which of the following is the
Mark for Review
definition for a variable
(1) Points
argument method?
A way to create a new class.
Specifies accessibility to
code.
Having more than one
constructor with the same
name but different
arguments.
A type of argument that
enables calling the same
method with a different
number of arguments. (*)
Correct
44. A static variable is always
Mark for Review
publicly available. True or false?
(1) Points
True
False (*)
Correct
45. Static methods can't change any
Mark for Review
class variable values at run-time.
(1) Points
True or false?
True
False (*)
Correct
Page 9 of 10
Section 7
(Answer all questions in this section)
46. Non-final static class variables
Mark for Review
should be private to prevent
(1) Points
changes from other classes. True
or false?
True (*)
False
Correct
49. Which of the following correctly
Mark for Review
describes the use of the keyword
(1) Points
super?
A keyword that restricts
access to only inside the
same class.
A keyword that allows
subclasses to access
methods, data, and
constructors from their
parent class. (*)
A keyword that signals the
end of a program.
A keyword that allows
access from anywhere.
Correct
50. Why are hierarchies useful for
Mark for Review
inheritance?
(1) Points
They keep track of where
you are in your program.
They restrict a superclass to
only have one subclass.
They organize constructors
and methods in a simplified
fashion.
They are used to organize
the relationship between a
superclass and its subclasses.
(*)
Correct
Page 10 of 10