• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 1 out of 3 pages
Exam (elaborations)

CSCI-C201 FINAL EXAM QUESTIONS & ANSWERS

Document preview thumbnail
Preview 1 out of 3 pages

CSCI-C201 FINAL EXAM QUESTIONS & ANSWERS

Content preview

CSCI-C201 FINAL EXAM QUESTIONS & ANSWERS
What is the purpose of Serializable interface? How one could use it? - Answers -The
purpose of the serializable interface is to allow for objects to be saved easier. When an
object is serialized, it is converted into a series of bytes that contain the object's data.
The resulting set of bytes can be saved to a file for later retrieval. You can use the
serializable interface by implementing it into your Java class.

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
_____________. - Answers -The first catch clause that is able to handle the exception

In the following code, assume that inputFile references a Scanner object that has been
successfully used to open a file:
double totalIncome = 0.0;while (inputFile.hasNext()){ try{ totalIncome +=
inputFile.nextDouble(); }catch(InputMismatchException e){ System.out.println("Non-
numeric data encountered " + "in the file."); inputFile.nextLine(); }finally{ totalIncome =
35.5; }}
What will be the value of totalIncome after the following values are read from the file?
2.58.53.05.5abc1.0
35.5 - Answers -35.5

What is Random Access File? Explain the I/O operations of Random Access Files. -
Answers -Random Access File is a file that allows a program to jump to any location in
the file. Items in a Random Access File are accessed in any order. The Random Access
File class treats a file as a stream of bytes. Bytes are numbered, starting at 0, similar to
an array. Java accesses the file through a file pointer. When the file is first opened, the
file pointer is set to 0. When an item is read it reads from that byte. This allows data to
be read and written at any byte location in the file.

If an exception is thrown and the program does not handle it, what happens? - Answers
-If an exception is thrown and the program does not handle it, it is thrown up to calling
method. It is handled by the default exception handler which will print an error message
and crash the program.

What will be the result of the following statements?

FileInputStream fstream = new FileInputStream("Input.dat");
DataInputStream inFile = new DataInputStream(fstream); - Answers -The
DataInputStream object is stored in the variable called inFile. The inFile variable will
reference an object that is able to read binary data from the file.

Assume that the classes BlankISBN, NegativePrice, and NegativeNumberOrdered are
exception classes that inherit from Exception. The following code is a constructor for the
Book class. What must be true about any method that instantiates the Book class with

Document information

Uploaded on
June 19, 2025
Number of pages
3
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$10.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
GEEKA
3.8
(367)
Sold
2181
Followers
1449
Items
61169
Last sold
4 hours ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions