5. Using the following declarations and a member of the Array class, int [ ] bAr
ID: 3873750 • Letter: 5
Question
5. Using the following declarations and a member of the Array class,
int [ ] bArray = new int [10];
int location;
Using a method in the Array class, write a statement that would change the order of the elements in the bArray array. The contents of the first cell should hold what was in the last cell. The second cell should hold what was in the next to last cell.
__________________________
HINT: You must write the full statement which includes a call to a method in the Array class.
6. ____________ would create an array declaration to hold the names of five font strings. Use font as your identifier. HINT: Your declaration must be syntactically correct, complete with an ending semicolon.
7. _____________ would create an array declaration and do a compile-time initialization to hold the 5 most common single character middle initials. The most common are A, N, R, S and T. Use middleInitial as your identifier. HINT: Your declaration must be syntactically correct, complete with an ending semicolon.
8. Assume you have a method heading that reads
public static void DoSomething (int [ ] temp)
A call to invoke the method sending in the array would look like:
______________________________________
HINT: Your declaration must be syntactically correct, complete with an ending semicolon.
Explanation / Answer
Question 5
Answer:
for(location = 0;location<bArray.length/2;location++){
bArray[location] = bArray[bArray.length-1];
}
Question 6
Answer:
String font[] = new String[5];
Question 7
Answer:
int n = 5;
char middleInitial[] = new int[n];
Question 8
Answer:
int [ ] temp = new int[5];
DoSomething (temp );
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.