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
Ivan
3 years ago
11

Consider the code below. Note that the catch statements in the code are not implemented, but you will not need those details. As

sume filename is a String, x is an int, a is a double array and i is an int. Use the comments i1, i2, i3, e1, e2, e3, e4, e5 to answer the question (i for instruction, e for exception handler).
try {

BufferedReader infile = new BufferedReader(new FileReader(filename)); // i1
int x = Integer.parseInt(infile.readLine( )); // i2
a[++i] = (double) (1 / x); // i3 }
catch (FileNotFoundException ex) {...} // e1
catch (NumberFormatException ex) {...} // e2
catch (ArithmeticException ex) {...} // e3
catch (ArrayIndexOutOfBounds ex) {...} // e4
catch (IOException ex) {...} // e5
Computers and Technology
1 answer:
Dmitriy789 [7]3 years ago
6 0

Missing Part of Question

An exception raised by the instruction in i3 would be caught by the catch statement labeled?

Answer:

e3 and e4.

Explanation:

The instruction tag i3 points to the following code segment

a[++i] = (double) (1 / x); // i3

The code segment above performs arithmetic operation (double)(1/x)

And then assigns the value of the arithmetic operations to an array element a[++I]

It's possible to have one or both of the following two exceptions.

1. Error in Arithmetic Operation

2. Index of Array out of bound

These are both represented in exception tags e3 and e4

catch (ArithmeticException ex) {...} // e3

catch (ArrayIndexOutOfBounds ex) {...} // e4

Exception e3 can arise when the program try to carry out invalid arithmetic operation.

For instance, 1/0 or 0/0.

This will lead to ArithmeticException to be thrown

Exception e4 can arise when the program tries to assign values to an index that's not in an array.

Say, the total index in a given array a is 5.

The index of this array is 0 to 4; i.e. a[0] to a[4]

The moment the program tries to assign values to array element other than the ones I listed above (e.g a[5]) ArrayIndexOutOfBounds exception will be thrown

You might be interested in
explain in detail how such a company can improve the focus and relationship with customers, and what they will benefit from this
Reil [10]
Advertisement maybe
6 0
3 years ago
AD and BC are equal perpendiculars to a line segment AB (see figure). Show that CD
Simora [160]
Show the picture to answer the question
7 0
3 years ago
Which of the following is a way to prevent wastes from contaminating the environment? A) Use absorbent pads to collect floor was
Firlakuza [10]

Answer

Dispose of absorbents as hazardous waste in its own hazardous waste container

Explanation

Hazardous waste is a waste that has chemical composition and properties which makes it capable of causing illness, death  or harm to humans and other life forms when released to the environment without proper management. The characteristics of such wastes include: toxic, ecotoxic, infectious substance, poisonous, explosive and flammability. Hazardous wastes can be destroyed by incineration, chemical process, and temporary on-site waste storage facilities such as waste piles and lagoons/ponds



8 0
3 years ago
Read 2 more answers
Which HTML tag is formatted correctly?
WITCHER [35]
A: This is a heading
3 0
3 years ago
What is the name of the technology that integrates vast data bases with georeferenced data in order to design, plan, and manage
ivanzaharov [21]

Answer:

"Geographic information systems " is the right answer.

Explanation:

  • This is indeed a computer-based method for observing and analyzing current events that are happening on the planet. GIS could enhance teaching and learning begin to understand geographical trends and regularities by relaying completely unconnected information.
  • It represent an experimental field and while the GIS supplier government offers us modern, improved, and quicker technical resources for the computer hardware.
7 0
3 years ago
Other questions:
  • Which of the following formats can algorithms NOT be written in:
    13·1 answer
  • Help PLEASE (in attachment)
    8·1 answer
  • Which of the following events would most likely produce an earthquake
    7·1 answer
  • An extranet is like an intranet except that it allows company employees access to corporate Web sites from the ______
    13·1 answer
  • Any executable files???
    5·1 answer
  • Short notes on Supply chain Management System (SCMS)
    12·1 answer
  • Find what the secret message is. Get Brainliest if you are fast and correct.
    13·2 answers
  • To change lowercase letters to uppercase letters in a smaller font size, which of the following should be done?
    10·1 answer
  • What is the difference between KE an PE
    8·1 answer
  • Challenge activity 1.11.1: using constant in expression is not working for me. Can any one help me find the right code?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!