Arrays
- Which of these method of Array class is used sort an array or its subset?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
sort()
- Which of this method is used to make all elements of an equal to specified value?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
fill() method assigns a value to all the elements in an array, in other words, it fills the array with specified value.
- Which of these standard collection classes implements all the standard functions on list data structure?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Array
- What is the output of this program?
public class Result
{
public static void main(String[] args)
{
int []p[] = {{1,2}, {3,4,5}, {6,7,8,9}};
int [][]q = p;
System.out.println("Alligator");
System.out.println(q[0][0]);
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Both p,and q are pointing to the same array.
- What is the output of this program?
public class Result
{
public static void main(String args[])
{
int array1[] = new int[8];
int array2[] = {5, 8, 7, 6, 9};
System.out.println(array1.length + " " + array2.length);
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Arrays in java are implemented as objects, they contain an attribute that is length which contains the number of elements that can be stored in the array. Hence array1.length gives 8 and array2.length gives 5.
output: 8 5