1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lina2011 [118]
4 years ago
9

Without changing the behavior (any part of the method body) and without changing the number of arguments the function takes or i

ts visibility, add the necessary code that will permit this code to compile without error.
Computers and Technology
1 answer:
S_A_V [24]4 years ago
4 0

Complete Question:

The method shown below,

public void makeJunk()

{

new File("junk").createNewFile();

}

generates compile-time error:

"unreported exception java.io.IOException; must be caught or declared to be thrown".

Without changing the behavior (any part of the method body) and without changing the number of arguments the function takes or its visibility, add the necessary code that will permit this code to compile without error.

Answer:

public void makeJunk() throws IOException {

new File("junk").createNewFile();

}

Explanation:

In Order to gain a better understanding of this answer let first explain some terms.

 Exception:

An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions. When an error occurs within a method, the method creates an object and hands it off to the run-time system.The object, called an exception object, contains information about the error, including its type and the state of the program when the error occurred. Creating an exception object and handing it to the run-time system is called throwing an exception.After a method throws an exception, the run-time system attempts to find something to handle it. The set of possible "somethings" to handle the exception is the ordered list of methods that had been called to get to the method where the error occurred

java.io.IOException:

This exception is related to Input and Output operations in the Java code. This exception happens when there is a failure during reading, writing and searching file or directory operations.

The  Compile- time error "unreported exception java.io.IOException; must be caught or declared to be thrown", means that the exception that would handle any errors that occurred during creating of the new file was not thrown in the first code so in order to solve the problem Without changing the behavior(any part of the method body) The exception that would handle that error was added to the solution code.  

   

You might be interested in
This OS was created by a developer named Torvalds.
GREYUIT [131]
The answer to this problem is Linux
7 0
3 years ago
HELPPPPPPPP
Reika [66]
The answer is visual hierarchy :)
4 0
3 years ago
Read 2 more answers
When _______ wordart, you need to consider both the font size of the text and the size of the text box that contains wordart?
padilas [110]
The correct answer is resizing. If you're making a logo and creating wordart. you have to care about resizing because the art needs to be clearly visible and appealing no matter the size. If you place it in a box, you have to care that it doesn't go over the edges of the box or anything similar that might seem appalling.
4 0
3 years ago
Int, char, bool, and double are all valid data types in c , true or false
arsen [322]
False. bool is in C++, ints are used in C.

6 0
3 years ago
Which of the following is false? A. The last element of an array has position number one less than the array size. B. The positi
Veseljchak [2.6K]

Answer:

C.A subscript cannot be an expression

Explanation:

The option C (A subscript cannot be an expression) is false

3 0
4 years ago
Other questions:
  • Which activity constitutes legal computer activity?
    12·1 answer
  • A business wants to centralize its administrative tasks. At the same time, it wants the existing systems to manage and sustain t
    5·1 answer
  • If num is an int which expression always evaluates to true if num holds an odd number
    14·1 answer
  • If you add the parameter, ____, the text in the applet window fades in and out as it scrolls.
    7·1 answer
  • Nathan took a picture of his friends while they were on a field trip. He wants upload this picture to a photo-sharing site. He w
    7·1 answer
  • Can you use public domain images without violating copyright laws?
    5·1 answer
  • Line spacing refers to the amount of space between each line in a paragraph. A. True B. False
    14·2 answers
  • There are how many GPS satellites orbiting the earth
    15·1 answer
  • Computer instructions are converted to binary when executed. Binary numbers use which set of digits?
    10·1 answer
  • Write your question here (Keep it clear and simple to get the best answer)
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!