Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 17.4, Problem 17.4.1CP
Explanation of Solution
Necessity of declaring “IOException”:
Most of the methods in the I/O classes throw “java.io.IOException” So, it is necessary to declare to throw “java.io.IOException”.
It is not possible to throw multiple exceptions in a single throw statement, because each throw statement handles only a single exception.
Declaration of exception in the method:
public static void main(String[] args)
{
thro...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Is the following true or false IN JAVA
In java it is possible to throw an exception, catch it, then re-throw that same exception if it is desired
2. GUIs are windowing interfaces that handle user input and output.
There are three clauses in Java’s Exception Handling. What are they? What are they for? Is it possible to create your own exception? Why would you think you might need it?
What is the difference between using @Test(expected = TypeOfException) and using try/catch when testing if a method or constructor properly returns an exception?
A. They do the same thing.
B. @Test(expected = ...) is the proper way to unit test in java, and try/catch should only be used when unit testing in Python.
C. @Test(expected = ...) will give a passing test as soon as one exception of the proper type is thrown and then stop the test, but using try/catch will allow you to test many examples in the same test and will only stop after running all examples or reaching a fail() or an assert statement that fails.
D. We should never use try/catch when unit testing, otherwise we will catch the exception and then won't know if it is actually thrown.
Chapter 17 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 17.2 - What is a text file and what is a binary file? Can...Ch. 17.2 - How do you read or write text data in Java? What...Ch. 17.3 - Prob. 17.3.1CPCh. 17.3 - How is a Java character represented in the memory,...Ch. 17.3 - If you write the string ABC to an ASCII text file,...Ch. 17.3 - If you write the string 100 to an ASCII text file,...Ch. 17.3 - What is the encoding scheme for representing a...Ch. 17.4 - Prob. 17.4.1CPCh. 17.4 - Why should you always close streams? How do you...Ch. 17.4 - Prob. 17.4.3CP
Ch. 17.4 - Does FileInputStream/Fi1eOutputStream introduce...Ch. 17.4 - What will happen if you attempt to create an input...Ch. 17.4 - How do you append data to an existing text file...Ch. 17.4 - Prob. 17.4.7CPCh. 17.4 - What is written to a file using writeByte(91) on a...Ch. 17.4 - How do you check the end of a file in an input...Ch. 17.4 - What is wrong in the following code? Import...Ch. 17.4 - Suppose you run the following program on Windows...Ch. 17.4 - After the following program is finished, how many...Ch. 17.4 - For each of the following statements on a...Ch. 17.4 - What are the advantages of using buffered streams?...Ch. 17.5 - How does the program check if a file already...Ch. 17.5 - How does the program detect the end of the file...Ch. 17.5 - How does the program count the number of bytes...Ch. 17.6 - Prob. 17.6.1CPCh. 17.6 - Prob. 17.6.2CPCh. 17.6 - Is it true that any instance of...Ch. 17.6 - Prob. 17.6.4CPCh. 17.6 - Prob. 17.6.5CPCh. 17.6 - What will happen when you attempt to run the...Ch. 17.7 - Can RandomAccessFi1e streams read and write a data...Ch. 17.7 - Create a RandomAccessFi1e stream for the file...Ch. 17.7 - What happens if the file test.dat does not exist...Ch. 17 - (Create a text file) Write a program to create a...Ch. 17 - (Create a binary data file) Write a program to...Ch. 17 - (Sum all the integers in a binary data file)...Ch. 17 - (Convert a text file into UTF) Write a program...Ch. 17 - Prob. 17.5PECh. 17 - Prob. 17.6PECh. 17 - Prob. 17.7PECh. 17 - (Update count) Suppose that you wish to track how...Ch. 17 - (Address book) Write a program that stores,...Ch. 17 - (Split files) Suppose you want to back up a huge...Ch. 17 - (Split files GUI) Rewrite Exercise 17.10 with a...Ch. 17 - Prob. 17.12PECh. 17 - (Combine files GUI) Rewrite Exercise 17.12 with a...Ch. 17 - (Encrypt files) Encode the file by adding 5 to...Ch. 17 - (Decrypt files) Suppose a file is encrypted using...Ch. 17 - (Frequency of characters) Write a program that...Ch. 17 - (BitOutputStream) Implement a class named...Ch. 17 - (View bits) Write the following method that...Ch. 17 - (View hex) Write a program that prompts the user...Ch. 17 - (Hex editor) Write a GUI application that lets the...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a constructor that takes two doubles (for r and i). In case that i is null, the constructor will throw an IllegalArgumentException exception with the message i must be non-zero. Notice that the constructor throws an exception (a run-time error) that appeared in a Project 5. You do not need to understand in detail how exceptions works in Java for answering this question.arrow_forward1. Write a program to demonstrate exception propagation in java?arrow_forwardthis is a java theory question write the answer carefully and do not plagarize or copy from internet please write in simple words so that i can understandarrow_forward
- import java.util.Scanner;import java.util.InputMismatchException; public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); /* Type your code here. */ }}arrow_forwardThis is for java. I need help asap. Thanks!arrow_forwardWhat is exception handling? Describe the use of exception handling in java with the help of example programarrow_forward
- In Java Only: My program is not working correctly, The history teacher at your school needs help grading a true/false test.The student's IDs and test answers are stored ina file, The first entry in the file contains the answers to the test in the following form: TFFTFFTTTTFFTFTFTFTT Every other entry in the file is the student;s ID, followed by a blank, followed by the student;s response. For example, the entry: ABC54301 TFTFTFTT TFTFTFFTTFT indicstes that the student;s ID is ABC54301 and the answer to question 1 is True, the answer to question 2 is false, and so on. This student did not answer question 9. he exam has 20 questions, and the class has more than 150 students. Each correct answer is awarded 2 points, each wrong answer gets -1 point, and no answer gets 0 points. Write a program that processes the test data. The output should be the student's ID, followed by the student's answers, followed by the test score, and then followed by the test grade. Here is my code, I keep…arrow_forwarddefine Write method ?arrow_forwardyou need to add a method for finding the list of passed modules and one method for total mark JAVAarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning