Test Series - java

Test Number 41/64

Q: An Array in Java is a collection of elements of ___ data type.
A. Same
B. Different
C. none
D. 0
Solution: no solution
Q: The Java Virtual Machine (JVM) implements arrays as ___ type.
A. Primitive
B. Object
C. None
D. 0
Solution: That is the reason why Java Array has predefined methods.
Q: Unlike C-Arrays, the Java-Arrays have ___.
A. Names
B.  Values
C. Methods and Fields
D. None
Solution: no solution
Q: An array declaration in Java without initialization ___ memory.
A. Does not allocate
B. Allocates memory
C. None
D. 0
Solution: Only initialization causes memory to be allocated.
Q: In Java language, an array index starts with ___.
A.  -1
B. 0
C. 1
D. Any integer
Solution: no solution
Q: Which are the special symbols used to declare an array in Java?
A. Braces { }
B. Parentheses ()
C. Square Brackets [ ]
D. Angled Brackets < >
Solution: no solution
Q: Which are the special symbols used to initialize an array at the time of the declaration itself?
A. Parentheses ( )
B. Square Brackets [ ]
C. Braces { }
D. Angled Brackets < >
Solution: int[] nums = {1,3,6};
Q: It is possible to skip initializing some elements of the array during Shorthand Initialization. (TRUE / FALSE)
A. FALSE
B. TRUE
C. None
D. 0
Solution: No, you can not skip any elements. All elements need to be initialized in one go or at the same time.
Q: In Java, an array can be declared without initialization without mentioning the size. (TRUE / FALSE)
A. TRUE
B. FALSE
C. None
D. 0
Solution: It is a Lazy initialization of an array.
Q: What is the output of the below Java code snippet with arrays?
static int[] nums; 
public static void main(String args[])
{
  System.out.println(nums.length);
}
A. 0
B. null
C. Compiler error
D. Runtime Exception - Null Pointer Exception
Solution: no solution

You Have Score    /10