Question

in java Write a program that contains a bounds error. Run the program. What happens on...

in java Write a program that contains a bounds error. Run the program. What happens on your computer?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Error output will be:

Code is shown below:

public class Main
{
public static void main(String[] args)
{
int array[] = {1, 2, 3};
for (int i=0; i<=array.length; i++)
System.out.println(array[i]);
}
}

Note:

This error cannot be find at the compilation time.

It can be hit only after the execution.

An exception will be thrown to the computer screen intimating the user about the out of bounds of an array occurred.

Here 0,1,2 position only filled, but we are trying to access the 3rd position that throws the exception.

Please rate it if the above solution helps you in any way or if you have any concerns comment it, I will help you through again.

Add a comment
Know the answer?
Add Answer to:
in java Write a program that contains a bounds error. Run the program. What happens on...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT