Important concept about Arrays Flashcards

1
Q
  1. what is an anonoymous Array?
A
  1. An ananomous Array is an array without a variable referencing it.
    example: new int[] {1,2,3,4,5};
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. how do we return array from method?
A

int[] numbers = {2,3,4,5,6};
return numbers;

  1. return new int[] {2,3,4,5,6}
    // this code does the same thing as the code above
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

methods used to print array

A

1.printArrays(); this method print array.
2.toString(); // this method print the string representation of array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

method to fill Array

A

1.fill(); // this method fill the whole array. example: string[] names = new string[3] // this create an array object in the computer memory.
Arrays.fill( string, “matthew”); // this method fill the array with the value/data matthew.

2.fill(array,fromindex, toindex, value); // this method fill the array at a specific index.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. How to get the sum in an array.
A

Sum += number[i] // this is how we get the sum of the element in an array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. How do we get the product of the element in an array.
A

product *= number[i] // this is how we get the product of the element in an array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. How do we get the average of the element in an array.
A

double average = double(sum) / number.length;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. how do we search an array.
A

if(searchElement == number[i])
// this search the element in an array. and see if searchelement is equal to the element in the array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  1. How do we pass object and primitive data to method.
A

we can pass a primitive and non primitive to a method at the same time.
example: (int[] numbers, int n );

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly