Question
Question 7: Because String objects in Java are immutable, incrementally building up a String can be wasteful as it produces many objects that are discarded
Question 7:
Because String objects in Java are immutable, incrementally building up a String can be wasteful as it produces many objects that are discarded and eventually have to be garbage collected. Which of the following classes can be used to incrementally build up a String without creating excessive garbage objects?
a- StringBuilder
b- StringJoiner
c- None of these
d- AttributedString
e- StringWriter
Question 8:
Text files use line endings (i.e., CR, CRLF, or LF) to mark the end of each line. This allows methods like readLine() to exist in supported classes.
True or False: Binary files have no delimiters to separate or mark the start/end of each value/structure.
a- True
b- False
Question 9:
The Java platform provides the Reader and Writer abstract classes so that the actual details of reading and writing (e.g., the location, type, etc. of the data source/sink) can be encapsulated, leaving most parts of a program to only worry about abstract read/write concepts.
a- True
b- False
Question 10:
The Java compiler can analyze unchecked exceptions, that is, the compiler knows when such an exception might arise from a given section of code.
a- True
b- False
Question 11:
Under what conditions is it possible to have a try block without an associated catch block? That is, in what circumstances would the absence of a catch block not necessarily result in a compilation error?
a- When using a try-with-resources in a method that declares throws for all of its checked exceptions.
b- When a try is used with a finally in a method that declares throws for all of its checked exceptions.
c- When the code enclosed in the try block has the potential to throw only unchecked exceptions.
d- When the -Werror command-line option is NOT passed to the Java compiler.
Question 12:
By default, an exception stack trace includes method parameters
a- True
b- False
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started