Read chapter 11 of Big Java 6 th Edition and provide short answers to the follow
ID: 3792235 • Letter: R
Question
Read chapter 11 of Big Java 6th Edition and provide short answers to the following questions. Submit your answers in a text document (plain text or Microsoft Word format, please).
a. What happens if you try to opening a file for writing that doesn't exist? Assume that you can create files in the directory where the file would be.
b. This code to create a File object to use with a Scanner causes the compilation error “Unknown escape sequence” in Java:
File f = new File("C:UsersjaneDesktopoutput.dat");
How should this line be written correctly?
c. How would you write a piece of code that throws a RuntimeException with the message “An incorrect parameter was given”?
Explanation / Answer
a. The emply file is automatically created for writing in the directory
b. File f = new File("C:\Users\jane\Desktop\output.dat");
c.
public class Test {
public static void main(String[] args){
throw new RuntimeException(“An incorrect parameter was given”);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.