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 only answer if you are sure your answer is

ID: 3697746 • Letter: T

Question

These are all Java questions. Please only answer if you are sure your answer is correct. Negative reviews will be given for incorrect answers.

1C.

Insert the missing code in the following code fragment. This fragment is intended to read an input file.

Select one:

a. new Scanner(inputFileName)

b. new Scanner(outputFileName)

c. new Scanner(inputFile)

d. new Scanner(System.in)

2C.

Consider the following code snippet:

Which of the following statements about this code is correct?

Select one:

a. The main method is designed to catch and handle all types of exceptions.

b. The main method is designed to catch and handle the IOException.

c. The main method should simply terminate if the IOException occurs.

d. The main method will not terminate if any exception occurs.

3C.

Which of the following is the correct syntax for starting a Java program named myProg from a command line if the program requires two arguments named arg1 and arg2 to be supplied?

Select one:

a. java myProg arg1 arg2

b. java myProg(arg1, arg2)

c. java myProg "arg1" "arg2"

d. java myProg arg1, arg2

4C.

If the current method in a program will not be able to handle an exception, what should be coded into the method?

Select one:

a. The throws clause should list the name of the method to which the exception should be passed.

b. The method declaration should be enclosed in a try/catch block.

c. The method should include a try/catch block for all possible exceptions.

d. The throws clause should list the names of all exceptions that the method will not handle.

5C.

Consider the following code snippet:

Which of the following statements about this code is correct?

Select one:

a. This code constructs an object of type IllegalArgumentException and throws the object.

b. This code throws an existing IllegalArgumentException object.

c. This code constructs an object of type IllegalArgumentException and reserves it for future use.

d. This code will not compile.

Explanation / Answer

These are all Java questions. Please only answer if you are sure your answer is
correct. Negative reviews will be given for incorrect answers.

1C.Insert the missing code in the following code fragment. This fragment is intended
to read an input file.

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

{

   String inputFileName = "dataIn.txt";

   String outputFileName = "dataOut.txt";

   File inputFile = new File(inputFileName);

   Scanner in = _______________;

   . . .

}

Select one: c (Scanner() expecting file parameter )
a. new Scanner(inputFileName)
b. new Scanner(outputFileName)
c. new Scanner(inputFile)
d. new Scanner(System.in)

2C. Consider the following code snippet:
public static void main(String[] args) throws IOException
Which of the following statements about this code is correct?

Select one:c (For example The file might not exist)
a. The main method is designed to catch and handle all types of exceptions.
b. The main method is designed to catch and handle the IOException.
c. The main method should simply terminate if the IOException occurs.
d. The main method will not terminate if any exception occurs.

3C.

Which of the following is the correct syntax for starting a Java program named
myProg from a command line if the program requires two arguments named arg1 and
arg2 to be supplied?

Select one:a (String args[]-> args[0] contains arg1, args[1] contains arg2)
a. java myProg arg1 arg2
b. java myProg(arg1, arg2)
c. java myProg "arg1" "arg2"
d. java myProg arg1, arg2

4C.
If the current method in a program will not be able to handle an exception, what
should be coded into the method?

Select one:d(public static void main(String[] args) throws IOException,FileNotFoundException{})
a. The throws clause should list the name of the method to which the exception
should be passed.
b. The method declaration should be enclosed in a try/catch block.
c. The method should include a try/catch block for all possible exceptions.
d. The throws clause should list the names of all exceptions that the method will
not handle.

5C.
Consider the following code snippet:
throw new IllegalArgumentException("This operation is not allowed!");
Which of the following statements about this code is correct?

Select one:a

a. This code constructs an object of type IllegalArgumentException and throws the
object.
b. This code throws an existing IllegalArgumentException object.
c. This code constructs an object of type IllegalArgumentException and reserves it
for future use.
d. This code will not compile.

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