Given the declarations int [ ] a = new int[10]; int [ ] b; Which of the following will cause an ArrayIndexOutOfBoundsException? a. a[0] = 10; b. a[6] = 10; c. b[0] = 10; d. b = a; e. none of the above
Added by Steven S.
Step 1
This creates an array `a` that can hold 10 integers, with valid indices ranging from 0 to 9. Show more…
Show all steps
Your feedback will help us improve your experience
Aditya Sood and 99 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
If you declare an array as int [ ] anArray = new int[5]; you can double the value stored in anArray [2] with the statement: a. anArray [2] = anArray [5] * 2; b. anArray = anArray * 2; c. anArray [2] *= anArray [2]Ć’*Ć’2; d. anArray [2] *= 2; e. none of the above
Which of the following array declarations would enable you to store the high temperature for each day of one full week? a. int temp1, temp2, temp3, temp4, temp5, temp6, temp7; b. int temp [7] = new int [7]; c. temp int [ ] = new temp[7]; d. int [ ] temp = new int [7]; e. int [ ] temp = new temp [8];
Which of the following statements about creating arrays and initializing their elements is false? a. The new keyword should be used to create an array. b. When an array is created, the number of elements must be placed in square brackets following the type of element being stored. c. The elements of an array of integers have a value of null before they are initialized. d. A for loop is commonly used to set the values of the elements of an array.
John B.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD