0% found this document useful (0 votes)
6 views1 page

Java Array Operations and Outputs

Uploaded by

xanderanonuevo22
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Java Array Operations and Outputs

Uploaded by

xanderanonuevo22
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Name: _____________________________________

ComProg ____ 6. What is the output of the following code fragment?

1. How to declare an array of integers named number? int [ ] items = {2, 7, 3, 5, 8, 9};
int funny = items[0];
___________________________________________ for (int i = 0; i < [Link]; i++)
{
2. What is the output of the following code fragments? if (items[ i ] > funny)
funny = items[ i ];
int [ ] fun = new int [5]; }
fun[0] = 1; [Link](funny);
fun[1] = 2;
fun[2]=3; ______________________________________________
fun[3] = 4;
fun[4] = 5 7. What is the output of the following code fragment?
int j = 3;
[Link](fun[ j-1]) ; double [ ] x = new double [ 4];
x[0] = 8.5;
__________________________________________________ x[1] = 6.5;
x[2] = 9.5;
3. What is the output of the following code fragment? x[3] = 12.5;
[Link](x[1 + 2]);
int [ ] odd = {1, 3, 5, 7, 9, 11 }; ______________________________________________
[Link]( odd[0] + " " + odd[3] ) ;

__________________________________________________ 8. What is the output for the following code fragment?

4. What does the following method do? int [ ] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};


for (int j = 0; j < [Link]; j++)
public static void numbers (int [ ] num) [Link](numbers[ j ] + " ");
{
for(int x = 1; x < [Link]; x++) _______________________________________________
num[x] = num[0];
} 9. What is the output from the following code fragment?

__________________________________________________ String [ ] name = { "Joe", "Sue", "Tom", "Jill", "Patty"};


for (int i = 0; i < [Link]; i = i + 2)
5. What is the output of the following code fragment? [Link](name[i] + " ");

int [ ] evens = {2, 4, 6, 8, 10}; _____________________________________________


evens[0] = 44;
evens[4] = evens[2]; 10. What is the length of this array?
[Link](evens[0] + " " + evens[4]);
double[ ] stuff = {1.5, 2.5, 3.5, 4.5, 5.5, 6.5};
____________________________________________
_______________________________________________

You might also like