Starting Out with Java: Early Objects (6th Edition)
6th Edition
ISBN: 9780134462011
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 10, Problem 5MC
FileNotFoundException inherits from __________.
- a. Error
- b. IOException
- c. JavaException
- d. FileException
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What is the error in readFile()?
publicvoidreadFile(){FileInputStream fbStream = null; Scanner inFS = null; int value = 0; fbStream = new FileInputStream("data.txt");inFS = new Scanner(fbStream);value = inFS.nextInt();System.out.println("Value: " + value);fbStream.close(); }
a.
There is a data input mismatch
b.
readFile( ) does not throw IOException
c.
inFS is not closed
d.
The code has no errors
JAVA
Please complete these files. There are two text files attached. Running the code should result in the creation of an output file ("PE_output.txt"). Please give full reasoning to the answer. Please also paste the full java code and please attach a screenshot of the successful program run.
package solution;
import java.io.*;import java.util.Scanner;
public class PE_1_problem {@SuppressWarnings("resource")public static String readFirstLetters(String filename) {String result = "";File f = new File(filename);// Surround the next command inside a try/catch block,// as it is possible the file doesn't exist.try {Scanner fileContents = new Scanner(f);while (fileContents.hasNextLine()) {// 1. Get the next line and store in a variable// 2. Check the length of the line. If the line is not an// empty string, add the character at the start of the line// to the result string.// 3. Otherwise, add an empty space to the result string.}fileContents.close();} catch (FileNotFoundException e) {…
Which is true?
a.
The FileOutputStream class includes println( )
b.
A PrintWriter object should be closed using close( )
c.
A PrintWriter constructor requires an OutputStream object
d.
A FileOutputStream object opens an existing file
JAVA
Chapter 10 Solutions
Starting Out with Java: Early Objects (6th Edition)
Ch. 10.1 - Prob. 10.1CPCh. 10.1 - Prob. 10.2CPCh. 10.1 - Prob. 10.3CPCh. 10.1 - Prob. 10.4CPCh. 10.1 - Prob. 10.5CPCh. 10.1 - Prob. 10.6CPCh. 10.1 - Prob. 10.7CPCh. 10.1 - Prob. 10.8CPCh. 10.1 - Prob. 10.9CPCh. 10.1 - When does the code in a finally block execute?
Ch. 10.1 - What is the call stack? What is a stack trace?Ch. 10.1 - Prob. 10.12CPCh. 10.1 - Prob. 10.13CPCh. 10.1 - Prob. 10.14CPCh. 10.2 - What does the throw statement do?Ch. 10.2 - Prob. 10.16CPCh. 10.2 - Prob. 10.17CPCh. 10.2 - Prob. 10.18CPCh. 10.2 - Prob. 10.19CPCh. 10.3 - What is the difference between a text file and a...Ch. 10.3 - What classes do you use to write output to a...Ch. 10.3 - Prob. 10.22CPCh. 10.3 - What class do you use to work with random access...Ch. 10.3 - What are the two modes that a random access file...Ch. 10.3 - Prob. 10.25CPCh. 10 - Prob. 1MCCh. 10 - Prob. 2MCCh. 10 - Prob. 3MCCh. 10 - Prob. 4MCCh. 10 - FileNotFoundException inherits from __________. a....Ch. 10 - Prob. 6MCCh. 10 - Prob. 7MCCh. 10 - Prob. 8MCCh. 10 - Prob. 9MCCh. 10 - Prob. 10MCCh. 10 - Prob. 11MCCh. 10 - Prob. 12MCCh. 10 - Prob. 13MCCh. 10 - Prob. 14MCCh. 10 - Prob. 15MCCh. 10 - This is the process of converting an object to a...Ch. 10 - Prob. 17TFCh. 10 - Prob. 18TFCh. 10 - Prob. 19TFCh. 10 - True or False: You cannot have more than one catch...Ch. 10 - Prob. 21TFCh. 10 - Prob. 22TFCh. 10 - Prob. 23TFCh. 10 - Prob. 24TFCh. 10 - Find the error in each of the following code...Ch. 10 - // Assume inputFile references a Scanner object,...Ch. 10 - Prob. 3FTECh. 10 - Prob. 1AWCh. 10 - Prob. 2AWCh. 10 - Prob. 3AWCh. 10 - Prob. 4AWCh. 10 - Prob. 5AWCh. 10 - Prob. 6AWCh. 10 - The method getValueFromFile is public and returns...Ch. 10 - Prob. 8AWCh. 10 - Write a statement that creates an object that can...Ch. 10 - Assume that the reference variable r refers to a...Ch. 10 - Prob. 1SACh. 10 - Prob. 2SACh. 10 - Prob. 3SACh. 10 - Prob. 4SACh. 10 - Prob. 5SACh. 10 - Prob. 6SACh. 10 - What types of objects can be thrown?Ch. 10 - Prob. 8SACh. 10 - Prob. 9SACh. 10 - Prob. 10SACh. 10 - What is the difference between a text file and a...Ch. 10 - What is the difference between a sequential access...Ch. 10 - What happens when you serialize an object? What...Ch. 10 - TestScores Class Write a class named TestScores....Ch. 10 - Prob. 2PCCh. 10 - Prob. 3PCCh. 10 - Prob. 4PCCh. 10 - Prob. 5PCCh. 10 - FileArray Class Design a class that has a static...Ch. 10 - File Encryption Filter File encryption is the...Ch. 10 - File Decryption Filter Write a program that...Ch. 10 - TestScores Modification for Serialization Modify...Ch. 10 - Prob. 11PC
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
The ________ object is assumed to exist and it is not necessary to include it as an object when referring to it...
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
State whether each of the following is true or false. A set of statements contained within a pair of parenthese...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Write a for loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 ... 1000
Starting Out with C++ from Control Structures to Objects (8th Edition)
Assume mystring references a string. Write a statement that uses a slicing expression and displays the last 3 c...
Starting Out with Python (3rd Edition)
Consider the following C program void fun (void) { int a, b, c; / defiinition.1 / . . . while (. . .) int b, c,...
Concepts Of Programming Languages
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
- I am having error E0020 and E0140 in C++. How can I fix it? /*Christopher JimenezCIS247CATM application24 November */ // bring in our libraries //Step #1#include <iostream>#include <conio.h>#include <string>#include <fstream> // read/write to files#include <ctime> // time(0)#include <iomanip> //setprecision()using namespace std; // prototypesvoid deposit(double* ptrBalance);void withdrawal(double* ptrBalance, float dailyLimit); // overloaded method - this version does not take withdrawal amountvoid withdrawal(double* ptrBalance, float dailyLimit, float amount); //overloaded method that takes withdrawal amount ///Entry point to the applicationint main(){ // create constant values -- cannot be changedconst int EXIT_VALUE = 5;const float DAILY_LIMIT = 400.0F;const string FILENAME = "Account.txt"; //create balance variabledouble balance = 0.0; // look for the starting balance; otherwise generate a ramdom starting balanceifstream iFile(FILENAME.c_str());…arrow_forwardWhich of the following opens the employ.txt file and allows the computer to write new data to the end of the files existing data? a. outFile = I0.File.AddText("employ.txt") b. outFile = I0.File.AppendText("employ.txt") c. outFile = I0.File.InsertText("employ.txt") d. outFile = I0.File.WriteText("employ.txt")arrow_forwardA student wants to write into a file called myfile, without deleting its existing content. Which one of the following functions should he or she use? f = open('myfile', 'r') f = open('myfile', 'w+b') f = open('myfile', '+') f = open('myfile', 'a')arrow_forward
- Which class is not used in file handling?Single choice. Scanner None of these Buffered Reader FileinputStreamarrow_forwardOverviewYou should enter this task, ask the user for a word and then search for a file to see if that word is among the words in the file. Task Write a java programThis exercise comes with three text files named wordlist1.txt, wordlist2.txt and wordlist3.txt. These files contain a large amount of words in English. Each file contains more and more words. Each word in these files is on a separate line and the words contain only lowercase letters. Your task is to write a program that reads all these words from the file and checks if a keyword, which the user entered, is among the entered words. The program should also count the total number of words contained in the file used. The program should measure how long it takes to complete the search, ie how long it takes to read all the words and check if the keyword is among the words or not. The program should start by asking the user for the word to be searched for. Then the words in the file should be counted and compared if the keyword…arrow_forwardUsing the FileReader or FileInputStream and the FileWriter or the FileOutputStream, create an I/O application for the StudentRecord Application. USE JAVA PROGRAMMINGarrow_forward
- public static void doSomething(String str) { System.out.println(str); } public static void main(String[] args) { try { Scanner fileHandler = new Scanner(new File("file.txt")); while(fileHandler.hasNext()) { doSomething(fileHandler.nextLine()); } }catch(IOException io) { // what happens if the file is not there?? } } Contents of file.txt are: Hello CS 1 I hope you are enjoying, yourself!arrow_forwardplease edit this code so it does not contain breaks, while(true) and BufferedReader. Also keep getting this error " *** IOException *** phonebook.text (No such file or directory) the desired output has been given in the picture. here is the code to edit: import java.io.*; import java.util.Scanner; public class Phonebook { public static void main(String[] args) { int lookupCount = 0; int revLookupCount = 0; int phoneEntryCount = 0; Scanner inputReader = new Scanner(System.in); try { File file = new File("phonebook.txt"); BufferedReader phonebookReader; PhonebookEntry phonebookEntry[] = new PhonebookEntry[100]; phonebookReader = new BufferedReader(new FileReader(file)); String line = phonebookReader.readLine(); while (line != null) { if (phoneEntryCount >= 100) { throw new Exception( "Phonebook capacity exceeded - increase size of underlying array"); } phonebookEntry[phoneEntryCount++] = new PhonebookEntry(line); line = phonebookReader.readLine(); } phonebookReader.close(); mainLoop:…arrow_forwardWrite an application that displays the name, containing folder, size, and time of last modification for the file FileStatistics.java.arrow_forward
- #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> int main(){ int stdout_bak = dup(STDOUT_FILENO); // make a backup of stdout system("rm -f mystery.txt"); // remove file using a shell command int out_fd = open("mystery.txt", // open file mystery.txt O_WRONLY|O_CREAT, // for writing, create if needed S_IRUSR|S_IWUSR); // give user read/write permission if(out_fd == -1){ // check for errors opening file perror("Couldn't open file 'mystery.txt'"); exit(1); // bail out if open fails } printf("1. Now you see me.\n"); // print to the screen dup2(out_fd, STDOUT_FILENO); // change stdout to go to mystery.txt printf("2. Now you don't!\n"); // print goes to mystery.txt close(out_fd); // close mystery.txt dup2(stdout_bak, STDOUT_FILENO); // restore stdout to screen…arrow_forward. Which of the following options can be used to read the first line of a text file "Myfile.txt"? a. myfile = open('Myfile.txt'); print(myfile.read(line)) b. myfile = open('Myfile.txt','r'); print(myfile.read(1)) c. myfile = open('Myfile.txt'); print(myfile.readline()) d. myfile = open('Myfile.txt'); print(myfile.readlines())arrow_forwardWhich of the following reads an image from a file? Group of answer choices a) imshow b) imread c) image d) readmatrixarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
- COMPREHENSIVE MICROSOFT OFFICE 365 EXCEComputer ScienceISBN:9780357392676Author:FREUND, StevenPublisher:CENGAGE LLINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.Computer ScienceISBN:9781337569798Author:ECKERTPublisher:CENGAGE L
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L
LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
Computer Science
ISBN:9781337569798
Author:ECKERT
Publisher:CENGAGE L
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License