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
liberstina [14]
4 years ago
11

Write a try block in which you prompt the user for an integer and display the name in the requested position in the names array.

Create a catch block that catches the potential ArrayIndexOutOfBoundsException thrown when the user enters a number that is out of range. The catch block should also display the error message: Subscript out of range.
Computers and Technology
1 answer:
N76 [4]4 years ago
8 0

Explanation:

try{

     String[] names={"Tom","Suzie","Lina","Harry","Rosy"};

     Scanner input=new Scanner(System.in);

     System.out.println("Enter an integer: ");

     int position=input.nextInt();

     System.out.println(names[position]);

   }catch(ArrayIndexOutOfBoundsException e){

     System.out.println("Subscript out of range.");

   }

You might be interested in
If you need to use arrows in a chart, which feature or menu option of a word processing program would you use?
Jlenok [28]
B or e honestly either one
7 0
3 years ago
Read 2 more answers
What name are input devices, output devices, and auxiliary storage devices collectively known?
Oxana [17]
Peripheral devices. hope this helps
5 0
4 years ago
Who wont me???????????????
Svet_ta [14]

Answer:

whatatattatata

Explanation:

what are u talking about

8 0
3 years ago
Read 2 more answers
Match the items with their respective descriptions. organizes files make files easily searchable keeps track of file creation an
klemol [59]

Answer:

I'm not sure but I think its ,accessible file system are all on arrow right

4 0
3 years ago
A __________ is a sequence of characters.
choli [55]
String i think:)))))
7 0
3 years ago
Other questions:
  • Mica's creating his web page with a software that is free of charge for the first month. If he likes the program, he will have t
    7·2 answers
  • You realize your computer has been infected with malware. The program has been copying itself repeatedly, using up resources. Wh
    10·1 answer
  • What actions are considered positive body language?
    12·1 answer
  • What type of network component is Telnet?
    10·2 answers
  • __________ intelligence is an approach to boundary spanning which results from using sophisticated software to search through in
    15·1 answer
  • A Windows user right-clicks on his desktop. What is he planning to do?
    10·1 answer
  • Which of the following is an object such as a field which can be inserted into a document
    7·1 answer
  • The part of the screen where you see the results of your code is called the Editor.
    15·2 answers
  • Which three characteristics help identify a business opportunity? (Choose three)
    14·1 answer
  • Which network protocol is used to handle the reliable delivery of information?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!