Question
16) Given an array called numArray that contains the following integer values: {5, 1, 8, 4, 6, 3, 7, 9} and the code: for (int
16)
Given an array called numArray that contains the following integer values:
{5, 1, 8, 4, 6, 3, 7, 9}
and the code: for (int index = 3; index if (numArray[index] > 4) System.out.print(numArray[index] + " "); }
What is output?
17) Given an input data file containing one line:
2 14 5 16
Assume that the file has already been opened for reading using a Scanner variable called fileInput. What will be output by the following code:
18)
Given:
double gpa = 3.7839;
Assume that an output file has just been opened for writing, using a PrintWriter variable called fileOutput.
Give one line of Java code that will write the value of gpa to the file, rounded to 1 decimal place, with no spaces before or after the value, and no newline afterwards.
19) Given that the method readSomething() may throw an IOException,
here is some code that calls the readSomething() method: int result; try { result = readSomething(); } // missing code to handle the exception
Supply the missing code to handle the exception by displaying any message passed back from the thrown exception, and setting result to 0.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started