Arrays
- How to copy contents of array?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Arrays class contains various methods for manipulating arrays (such as sorting and searching). Array is not a valid class.
- Where is array stored in memory?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Array is stored in heap space.Whenever an object is created, it’s always stored in the Heap space and stack memory contains the reference to it.
- Can you make an array volatile?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
You can only make variable pointing to array volatile. If array is changed by replacing individual elements then guarantee provided by volatile variable will not be held.
- What is the output of this program?
public class arr_output
{
public static void main(String args[])
{
int arr_var[][] = {{ 1, 2, 3, 4}, { 4 , 5, 6, 7}, { 7, 8, 9, 10}};
int sum = 0;
for (int i = 0; i < 3; ++i)
{
for (int j = 0; j < 3 ; ++j)
{
sum = sum + arr_var[i][j];
}
}
System.out.print(sum / 2);
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
None
Output: 22
- How to sort an array?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Arrays class contains various methods for manipulating arrays (such as sorting and searching). Array is not a valid class.