Question
1. Using the following declarations, int counter = 0; double val; double [ ] bArray = new double [10]; To display the contents of bArray
1. Using the following declarations,
int counter = 0;
double val;
double [ ] bArray = new double [10];
To display the contents of bArray, show what the foreach loop control construct would resemble.
______________
HINT: Write the first line of the loop - the line that has the foreach on it. You are not writing the body...just the loop control statement.
2. Using just the following declarations,
int counter = 0;
int val;
int [ ] bArray = new int [10];
Write the body of the for loop that could be used to increment each element in bArray by 5.
__________________
HINT: You are not writing the control structure, just the body of the loop where counter will be the index used with the bArray.
3. Using the following declarations and a member of the Array class,
int [ ] bArray = new int [10];
int location;
Using a method of the Array class, write an assignment statement that would return the index in the bArray array where 14 is stored.
__________________________
HINT: You must write the full assignment statement which includes a call to a method in the Array class.
4. 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 order the values in the bArray array in ascending order.
___________________
HINT: You must write the full statement which includes a call to a method in the Array class.
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started