Write a class called FileOperations that accepts a string value in a variable ca
ID: 3814297 • Letter: W
Question
Write a class called FileOperations that accepts a string value in a variable called str which represents the name of a text file residing on an external storage device. Provide the following: (a) A constructor that accepts the string str, representing the file name, and creates a LineNumber object. (b) A mutator method that the line by line until the is empty. (c) An accessor method that determines if the actual file exists. (d) An accessor method that returns the number of bytes in the file. (e) An accessor method that returns the name of the file. (f) The declaration of appropriate variables and use of Exception when necessary. Given that the following method definition belongs to a class. int evaluate(int x) {if(x == 1) return 1; else return x + evaluate(x - 1);} What is displayed when the following statement is called? System.out.println("The result is "+evaluate(5); Select one: a. 5 4 3 2 1 b. The code not compile because the keyword, if, wants the associated, else. c. 21 d. 15 e. 6 4 3 2 1 0 What class if the superclass of all streams that input byte-oriented data? Select one: a. BufferedInputStream b. ByteInputStream c. InputStream d. InputStream What method does the class DataOutputStream has that determines the number of bytes in a file? Select one: a. size() b. length() c. getSize() d. getSize() getFileSize() e. available()Explanation / Answer
Question 8
Answer:
a. LineNumberReader lnr = new LineNumberReader(new FileReader(str));
b. lnr.readLine()
c. lnr.available
e.
String str ="abc.txt";
FileReader fr = null;
LineNumberReader lnr = null;
Question 6
Answer: d. 15
In this logic, we are adding the numbers from 1 to x.
so 5 + 4 + 3 + 2 + 1 = 15
Question 3
Answeer:
c. InputStream
Question 17
Answer:
e. available
Question
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.