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
King(a. has eaten b.ate c.had eaten) when Airah called​
Alenkinab [10]

Answer:

c

Explanation:

king had eaten when Airah called

3 0
3 years ago
You have an Active Directory forest of two trees and eight domains. You haven’t changed any of the operations master domain cont
Vikentia [17]

Answer:

Option C is the correct option.

Explanation:

The following option is correct because the user has two trees and also has eight domains of the Active Directory Forest and the user not done any alteration on the operations of the master domain controllers then, the schema master is on the 1st domain controller that is in forest root domain controller.

8 0
4 years ago
Write a function called cipher(phrase,shift)that accepts two parameters: a string phrase and an integer shift.The integer shift
Aleks [24]

Answer:

Following is given the code according to requirement.

The code is attached as an image so that the indentation is understood by the user. Comments are given inside the code where necessary.

The output of code is also attached as well  in end.

I hope it will help you!

Explanation:

7 0
3 years ago
Common term is used by security testing professionals to describe vulnerabilities in a network?
Valentin [98]

Holes is a common term is used by security testing professionals to describe vulnerabilities in a network.

Therefore, the answer is Holes.

5 0
3 years ago
I used a walmart MoneyCard and now it says its prepaid. Its my dad's card.
Scorpion4ik [409]

Answer:

oh- Did he find out-

Explanation:

8 0
3 years ago
Other questions:
  • How do say phone in French?
    10·2 answers
  • In Google search results, how are organic links different from sponsored links?
    13·2 answers
  • This inventor made their own fortune. They had little to no help in become one of the first black millionaires. They invented a
    9·1 answer
  • How do you turn off amber alerts on iphone?
    13·2 answers
  • _________________________ was designed to provide devices with a method for notifying each other that a link is experiencing con
    15·1 answer
  • my pc wants to run the highest graphics even though I restart it everyday and it gets around 10 fps and I have a 1080 Nvidia gra
    7·1 answer
  • the id selector uses the id attribute of an html element to select a specific element give Example ?​
    11·1 answer
  • Write a statement that takes a variable named file_object that contains a file object and reads its contents into a Python list
    7·1 answer
  • does anyone know the what the tuition fee is for UC Berkeley PER YEAR. My smooth brain can't find it ANYWHERE.
    10·2 answers
  • Write a recursive method called, doMyMath, which takes as input any positive integer and calculates the factorial (use comments
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!