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
Your one output statement should occupy two lines in your program
satela [25.4K]

Answer:Use \n in your print function after text to keep writing in the next line

Explanation:

For example,

<em>print("first line \n second line")</em>

output would be:

<em>first line</em>

<em> second line</em>

8 0
3 years ago
What is cryptocurrency ? I need to do a research one it please help!
icang [17]

A cryptocurrency is a digital asset designed to work as a medium of exchange that uses strong cryptography to secure financial transactions, control the creation of additional units, and verify the transfer of assets.

8 0
4 years ago
Which element can be changed using the Print pane? Check all that apply.
Ronch [10]

Answer:

B

C

D

E

Explanation:

5 0
3 years ago
Read 2 more answers
Which of the following jobs usually requires some level of formal higher education other than vocational training?
Alexeev081 [22]

Answer:

(A.) Teaching.

Explanation:

You need to go to college and get a degree for teaching.

3 0
3 years ago
Read 2 more answers
What is the type of data in the list [103, 405, 527, 396, 503]?
Mariulka [41]

Answer:

alphanumeric.........

3 0
3 years ago
Read 2 more answers
Other questions:
  • Tasha purchased a new tablet. She has several questions about how to connect to the internet, download apps, install software, a
    5·1 answer
  • All of the following are types of data storage devices except CD/DVD computer monitor digital cameras flash drive
    15·1 answer
  • Physical access, security bypass, and eavesdropping are examples of how access controls can be ________.
    15·1 answer
  • Users generally do not understand the concept of network drive sharing. they only know they can store their files "on my f: driv
    8·1 answer
  • Computer programs and games are called what?
    13·1 answer
  • What is the grooming process as it relates to online predators?
    12·2 answers
  • Design a class named Person with fields for holding a person’s name, address, and telephone number. Write one or more constructo
    12·1 answer
  • The entress Effie cooks as a chef never vary by taste, quantity or quality
    6·1 answer
  • Private notes about individual slides that you leave for yourself or for others who might use the presentation file is called __
    13·1 answer
  • When adopting and implementing a software as a service (saas) platform such as salesforce for your business, which responsibilit
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!