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
Assume the existence of a class named window with functions named close and freeresources, both of which accept no parameters an
denis-greek [22]
In your question whereas there is a class named window and it would be like this:

class window {
//code here 
}

Next is there is a function called close and freeresource and it goes like this:

class window{
  function close( ){
   //code here
  }
  function freeresource( ){
  // code here
  }
 public destruct (){
this.close();
this.freeresource();
}

}
The last code function destruct invokes the function close and freeresource. Hope this would help 

7 0
3 years ago
When seeking information on the Internet about a variety of subjects, the most
liq [111]

Answer:

wikipedia

Explanation:

they have like almost everything.

6 0
4 years ago
Read 2 more answers
You are asked to install a device that will combine several connections to the Internet and provide the sum of the available net
ch4aika [34]

Answer:

load balancer.

Explanation:

Based on the scenario being described within the question it can be said that you are being asked to install a load balancer. This is a device that behaves as a reverse proxy in order to correctly and efficiently distribute all the network traffic across various servers in order to increase the amount of users that can use the server at the same time.

8 0
3 years ago
Read 2 more answers
How are the number of rows calculated.​
Eva8 [605]

Answer:

ROWS function

Explanation:

Hope this helped

6 0
3 years ago
write a c++ program that takes a string input from the user and removes all characters except numerals also display the number o
Xelga [282]

Answer:

hi

Explanation:

5 0
3 years ago
Other questions:
  • I will mark brainalist! ​
    5·1 answer
  • Write the definition of a class Counter containing: An instance variable named counter of type int. An instance variable named l
    14·1 answer
  • Cameron oversees inventory tracking in her school store. Which feature in a database allows her to organize the items from highe
    6·1 answer
  • Consider Statement 1: All prime numbers greater than 3 are equal to a multiple of six, plus 1 or minus 1. Let P(x) be the statem
    7·1 answer
  • Ok.,so i have a sopitify account and by accident i pressed the downlaod on button and it says start you free trial i pressed tha
    11·2 answers
  • Anyone else like hunter x hunter?<br> lets talk abt it uwu<br><br> good day :)
    14·2 answers
  • HELP PLS!!! In a presentation, what is layout?
    10·2 answers
  • List 10 examples of computer ethics<br>(please give even 1 if you can, I need it urgently) ​
    10·1 answer
  • Ema Company for business .
    14·1 answer
  • Think of some local businesses that have websites. Look online and identify two different websites for businesses or services in
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!