chap 11 Flashcards

1
Q

What is a call stack?

A

an internal list of all the methods that are currently executing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a stack trace?

A

a list of all the methods in the call stack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a random access file?

A

a file that allows a program to read data from any location within the file, or write data to any location within the file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is object serialization?

A

the process of converting an object to a series of bytes and saving them to a file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Deserialization

A

the process of reconstructing a serialized object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When an exception is thrown ____
a) it may be ignored
b) it must always be handled by the method that throws it
c) the program terminates even if the exception is handled
d) it must be handled by the program of by the default exception handler

A

d) it must be handled by the program of by the default exception handler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When writing a string to a binary file or reading a string from a binary file, it is recommended that you use ____
a) the FileReader and Writer class methods
b) the Scanner class methods
c) the System.In and System.out methods
d) methods that use UTF-8 encoding

A

d) methods that use UTF-8 encoding

When writing or reading strings to/from a binary file, it’s recommended to use methods that handle character encoding properly, such as those that use UTF-8 encoding. This ensures that the characters are properly encoded and decoded without losing information or encountering unexpected behavior.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When an exception is thrown by code in its try block, the JVM begins searching the try statement for a catch clause that can handle it and passes control of the program to ___
a) each catch clause that can handle the exception
b) the statement that appears immediately after the catch block
c) the first catch clause that can handle the exception
d) the last catch clause that can handle the exception

A

When an exception is thrown by code in its try block, the JVM begins searching the try statement for a catch clause that can handle it and passes control of the program to:

c) the first catch clause that can handle the exception

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

to read data from a binary file, you create objects from which of the following classes
a) File and PrintWriter
b) FileInputStream and DataInputStream
c) BinaryFileReader and BinaryDataReader
d) File and Scanner

A

b) FileInputStream and DataInputStream

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Beginning with Java7, to catch multiple exceptions with a single catch, you can use ___
a) catch templates
b) multi-catch
c) catchAll
d) multi-try

A

b) multi-catch

Beginning with Java 7, you can catch multiple exceptions with a single catch block using the multi-catch feature. This allows you to write cleaner and more concise exception handling code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

to serialize an object and write it to the file, use the ____ method of the ObjectOutputStream class
a) Serialize
b) SerializeObject
c) SerializeAndWrite
d) WriteObject

A

d) WriteObject

When you want to serialize an object and write it to a file in Java, you use the WriteObject method of the ObjectOutputStream class. This method is specifically designed to write the state of an object to the underlying stream, allowing you to persist the object’s data to a file for later retrieval or transmission. It’s a standard practice for object serialization in Java.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what happens if a program does not handle an unchecked exception?

a) The program is halted and the default exception handler handles the exception
b) A compiler error will occur
c) This isn’t possible; the program will handle the exception
d) The exception is ignored

A

If a program does not handle an unchecked exception, the following occurs:

a) The program is halted and the default exception handler handles the exception

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the main difference between checked and unchecked exceptions?

A

The main difference between checked and unchecked exceptions in Java is that checked exceptions are checked at compile time, while unchecked exceptions are not checked at compile time.

Checked exceptions are subclasses of Exception class, excluding RuntimeException and its subclasses.

Unchecked exceptions are subclasses of RuntimeException and Error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the file pointer?

A

The file pointer holds the byte number of a location in the file. When a file is first opened, the file pointer is set to 0. This causes it to “point” to the first byte in the file. When an item is read from the file, it is read from the byte that the file pointer points to.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly