Arrays
- What is the output of this program?
import java.util.*;
public class ArrayExample
{
public static void main(String args[])
{
int arr[] = new int [10];
for (int k = 10; k > 0; k--)
arr[10 - k] = k;
Arrays.sort(arr);
for (int k = 0; k < 7; ++k)
System.out.print(arr[k]);
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
Arrays.sort(arr) method sorts the array into 1,2,3,4,5,6,7.
- Which of these methods must be made static?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
main() method must be declared static, main() method is called by Java runtime system before any object of any class exists.
- Which of the following statements are incorrect?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Variables declared as final occupy memory
- Which of the following statements are incorrect?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
All objects of class share same static variable, when object of a class are declared, all the objects share same copy of static members, no copy of static variables are made.
- Which of these cannot be declared static?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
static statements are run as soon as class containing then is loaded, prior to any object declaration.