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
trapecia [35]
3 years ago
5

Java

Computers and Technology
1 answer:
Triss [41]3 years ago
7 0

The program illustrates the use of catching exceptions using try and catch.

  • Exceptions are simply errors that can crash a program
  • Try and catch are used to prevent errors from crashing a program

The required try and catch block is as follows:

<em>try { </em>

<em>        System.out.print(names[index]); </em>

<em>    } </em>

<em>    catch (ArrayIndexOutOfBoundsException e) { </em>

<em>   System.out.println(e.getMessage()); </em>

<em>}</em>

The flow of the above code segment is as follows:

First, we begin with the try block

<em>try {</em>

Then the program prints the element at the index

<em>        System.out.print(names[index]);     }</em>

If the index does not exist in the array (e.g. -1 or 11), then the catch block is executed

<em>    catch (ArrayIndexOutOfBoundsException e) {</em>

This prints the appropriate exception

<em>   System.out.println(e.getMessage()); }</em>

See attachment for sample run

Read more about similar programs at:

brainly.com/question/21330187

You might be interested in
In an advanced word processing program which type of image or graphic is available in a variety of formats and styles?
ira [324]
IS it coding?If not sorry
5 0
3 years ago
Read 2 more answers
0.6 tenths of an hour would be how many minutes?
astraxan [27]

Answer:

17 min bro

Explanation:

8 0
3 years ago
Read 2 more answers
In response to a recent outbreak of computer viruses, Babbage Industries, a large technology company, installs computer virus pr
Vinil7 [7]

Answer:

The answer is antivirus solution implementation and planning.

Explanation:

Enterprises use antivirus implementation to protect from threats of different types such as Trojan horses, rootkits, ransomware, spyware, and botnets. Withing organizations, this implementation requires a proper planning and implementation plan that helps companies to protect the enterprise system. So, antivirus implementation and planning is the answer.

8 0
3 years ago
Read 2 more answers
Def build_dictionary(string):
MissTica

Answer:

Follows are the code to this question:

def build_word_counter(string):#defining a method build_word_counter that accepts string as a parameter  

   d = dict()#defining d variable as a dictionary

   for x in string:#defining for loop that use string

       x = x.lower()#Use lower method  

       if not d.get(x):#defining if block that holds value in d variable

           d[x] = 1#use dictionary to hold value in 1

       else:#defining else block

           d[x] += 1#use dictionary to increment value by 1

   return d#return dictionary

print(build_word_counter(["Like","like","LIKE"]))#use print method to call method

def build_letter_distribution(string):#defining a method build_letter_distribution that accepts string variable

   d = dict()#defining d variable as a dictionary

   for i in string:#defining for loop to count string value

       for j in i:#defining for loop to hold string as number

           if not d.get(j):#defining if block that doesn't get value in dictionary  

               d[j] = 1#hold value in dictionary  

           else:#defining else block

               d[j] += 1#use dictionary to increment the dictionary value

   return d#return dictionary

print(build_letter_distribution(["Like","test","abcdEFG"]))#use print method to return its value

Output:

please find the attached file.

Explanation:

In the first program a method, "build_word_counter" is defined that accepts a string variable in its parameter, and inside the method, a dictionary variable "d" is defined that uses the for loop to hold string value and convert all value into lower case.

In the next step, a conditional statement is used that holds value in the dictionary and count its word value.

In the second program a method, "build_letter_distribution" is defined that holds string variable in its parameter, and inside the method, a dictionary variable "d" is defined that uses the two for loop and in if the block, it holds value in the dictionary and returns its value, and use print method to print its return its value.

4 0
3 years ago
A condition-controlled loop uses a while loop.<br><br> true<br><br> false
matrenka [14]

Answer:

true

Explanation:

a while loop is a condition-controlled loop. While loops continue no matter what under a certain condition, unless you insert the keyword <em>break.</em>

One example in python is this:

while x > y:

      <em>pass</em>

The keyword to break a while loop may vary depending on the coding language you are using.

<u>Tip</u> The pass keyword allows a no error contact between loop and the terminal. Pass in a nutshell is almost as if saying nothing at all, but just leaving the condition blank. We only use pass because it prevents errors instead of no value.

8 0
2 years ago
Other questions:
  • Question # 6
    13·1 answer
  • Java languageThe cost to ship a package is a flat fee of 75 cents plus 25 cents per pound.1. Declare a constant named CENTS_PER_
    5·2 answers
  • Which actions can be performed on tables in Word? Check all that apply.
    13·2 answers
  • Can you put iPhone voice memos on repeat?
    6·2 answers
  • If you hear that an airplane crashes into the Empire State Building, and you immediately think of the 9/11 terrorist attack on t
    9·1 answer
  • 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
  • Question # 2 Multiple Select You wrote a program to compare the portion of drivers who were on the phone. Which statements are t
    15·1 answer
  • Match each method of communication with its intended purpose.
    14·1 answer
  • PLZ PLZ PLZ PLZ HELP I ONLY HAVE 5 MINUTES IT SAYS THE SUBJECT IS COMPUTERS AND TECHNOLOGY BUT ITS ACTUALLY MEDIA LIT
    5·1 answer
  • Which of the following will you do in step X in the following series of clicks to change the bounds of
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!