JAVA Programming FINAL Exam
JAVA Programming FINAL Exam
Section 3
(Answer all questions in this section)
1. The Files class performs which of the following?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
A BufferedWriter stream
A PrintStream (*)
A BufferedReader stream
An OutputStream
A Reader stream
Incorrect. Refer to Section 3 Lesson 5.
3. You can read input by character or line.
True or false?
Mark for
Review
(1) Points
True (*)
False
Correct
Mark for
Review
(1) Points
/home/user/username
/
\Users\UserName\data
C:\Users\UserName\data (*)
data
Correct
5. Serialized classes are less flexible to change than non-serialized classes.
True or false?
Mark for
Review
(1) Points
True
False (*)
Correct
6. The
System.i
n is
what
type of
stream?
A BufferedWriter stream
A PrintStream
An InputStream (*)
A BufferedReader stream
A Reader stream
Correct
7. The Paths class provides a static get() method to find a valid Path.
True or false?
Mark for
Review
(1) Points
True (*)
False
Correct
8. The BufferedInputStream is a direct subclass of what other class?
Mark for
Review
(1) Points
InputStream
FilterInputStream (*)
InputStream
FileInputStream
PipedInputStream
Correct
9. Which of the following correctly defines a queue?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
vegetables += "Cabbage";
vegetables.get("Cabbage");
vegetables[0] = "Cabbage";
vegetables.add("Cabbage"); (*)
Correct
11. The
local
petting
zoo is
writing a
program
to be
able to
collect
be able
to group
animals
accordin
g to
species
to better
keep
track of
what
animals
they
have.
Which of
the
followin
g
correctly
defines
a
collectio
n that
may
create
these
types of
groupin
gs for
each
species
at the
zoo?
public class
animalCollection {}(*) (*)
public class
animalCollection(AnimalType T) {}
public class
animalCollection {}
public class
animalCollection(animalType) {}
None of the above.
Correct
12. When would an enum (or enumeration) be used?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
A pile of pancakes with which you add some to the top and
remove them one by one from the top to the bottom. (*)
A row of books that you can take out of only the middle of the
books first and work your way outward toward either edge.
A line at the grocery store where the first person in the line is the
first person to leave.
All of the above describe a stack.
Correct
14. Which of the following correctly initializes a generic class Telephones
with one generic type Type1?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Correct
19. What are maps that link a Key to a Value?
Mark for
Review
(1) Points
Arrays
ArrayLists
HashSets
HashMaps (*)
Correct
20. What is the correct way to initialize a HashSet?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True
False (*)
Correct
24. The instanceof operator works inside an if statement.
True or false?
Mark for
Review
(1) Points
True (*)
False
Correct
25. A method with default access can be subclassed.
True or false?
Mark for
Review
(1) Points
True
False (*)
Correct
26. Immutabl
e classes
can be
subclasse
d.
True or
false?
True
False (*)
Correct
27. A method with public access can be subclassed.
True or false?
Mark for
Review
(1) Points
True
False (*)
Correct
28. Virtual method invocation occurs when you call a method from a
superclass.
True or false?
Mark for
Review
(1) Points
True
False (*)
Correct
29. Virtual method invocation requires that the superclass method is
defined as which of the following?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True
False (*)
Correct
31. The
instance
of
operator
only
works
with
class
instance
s.
True or
false?
True (*)
False
Correct
32. The instanceof operator works with class instances and primitive
data types.
True or false?
Mark for
Review
(1) Points
True
False (*)
Correct
33. The instanceof operator finds subclasses when they are passed as a
superclass.
True or false?
Mark for
Review
(1) Points
True (*)
False
Correct
34. Abstract classes define what?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True
False (*)
Correct
40. Square brackets are a representation for any character in regular
expressions "[ ]".
True or false?
Mark for
Review
(1) Points
True
False (*)
Correct
41. Which of the
following
methods are
specific to
StringBuilder
s?
append
delete
inssert
replace
All of the above. (*)
Correct
42. Multiple exceptions can be caught in one catch statement.
True or false?
Mark for
Review
(1) Points
True (*)
False
Correct
43. Assertions are boolean statements to test and debug your
programs.
True or false?
Mark for
Review
(1) Points
True (*)
False
Correct
44. Methods can not throw exceptions.
True or false?
Mark for
Review
(1) Points
True
False (*)
Correct
45. When is the proper time to use exceptions?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
&&
(==) (equals equals)
None, multiple exceptions can't be handled in one catch
statement.
A single bar: | (*)
Correct
48. The finally clause only executes when an exception is not caught
and thrown.
True or false?
Mark for
Review
(1) Points
True
False (*)
Correct
49. When should you not use assertions?
Mark for
Review
(1) Points
Mark for
Review
(1) Points