Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

These are all Java questions. Please do not answer if you are unsure that you an

ID: 3697738 • Letter: T

Question

These are all Java questions. Please do not answer if you are unsure that you answers are correct. Negative reviews will be given if wrong answers are submitted

1.

Which of the following statements about command line arguments is correct?

Select one:

a. Command line arguments must be read with a Scanner object.

b. You must declare additional parameters in the main method to receive command line argument values.

c. You cannot pass arguments to a program when starting the program from a command line prompt.

d. Command line arguments can be read using the main method's args parameter.

2.

Your program must read in an existing text file. You want the program to terminate if the file does not exist. Which of the following indicates the correct code for the main method header?

Select one:

a. public static void main(String[] args) throws FileMissingException

b. public static void main(String[] args) throws FileNotFoundException

c. public static void main(String[] args)

d. public static void main(String[] args) throws UnknownFileException

3.

Insert the missing code in the following code fragment. This code is intended to open a file and handle the situation where the file cannot be found.

Select one:

a. throws IOException exception

b. throws IOException, FileNotFound

c. throws IllegalArgumentException

d. throws IOException

4.

Consider the following code snippet.

Which of the following statements about this code is correct?

Select one:

a. This code will read in a word at a time from the input file.

b. This code will read in the entire input file in one operation.

c. This code will read in a line at a time from the input file.

d. This code will read in a character at a time from the input file.

5.

Insert the missing code in the following code fragment. This fragment is intended to write an output file named dataOut.txtthat resides in a folder named reports on the C: drive of a Windows system.

Select one:

a. new PrintWriter("c:/reports/dataOut.txt")

b. new PrintWriter("c://reports//dataOut.txt")

c. new PrintWriter("c: eportsdataOut.txt")

d. new PrintWriter("c: eports\dataOut.txt")

Explanation / Answer

1) D

command line arguments can be read using the main method's args parameter

The arguments passed in the command line are stored as string format in args[] array.

2) B

public static void main(String[] args) throws FileNotFoundexception

3) D

throws IOException

4) A

This code will read in a word at a time from the input file

if in.hasNextLine then it will read a line at a time

5) D

new PrintWriter("c: eports\dataOut.txt")

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote