Test Series - java

Test Number 43/64

Q: Shorthand array initialization in Java needs the keyword "new" to allocate memory to the array and elements. State TRUE or FALSE.
A. FALSE
B. TRUE
C. none
D. 0
Solution: Only lazy initialization of array needs the keyword "new" to allocate memory.
Q: Lazy initialization of array requires the keyword "new" to allocate memory to the array and its elements. State TRUE or FALSE.
A. FALSE
B. TRUE
C. none
D. 0
Solution: int[] ary;
ary = new int[5];
Q: What is the default value of an element of Object type array?
A. 0
B. null
C. -1
D. Garbage value
Solution: Objects can be String, ArrayList, HashMap, HashSet etc.
Q:  What is the default value of byte, short, int or long data type elements of an array in Java?
A. -1
B. 1
C. 0
D. Garbage value
Solution: no solution
Q: What is the default value of float or double data type elements of an array in Java?
A. 0
B. 0.0
C. 1
D. 1.0
Solution: no solution
Q: What is the default value of boolean data type elements of an array in Java?
A. TRUE
B. FALSE
C. none
D. 0
Solution: no solution
Q: Allocating memory with the keyword "new" causes the array elements to carry default values. State TRUE or FALSE.
A. TRUE
B. FALSE
C. none
D. 0
Solution: no solution
Q: What is the output of the below Java program?
int balls[], rounds=3;
balls = new int[rounds];
for(int i=0; i
A. 0,2,4,
B. 1,2,3,
C. 2,4,6,
D. Compiler error
Solution: no solution
Q: What is the output of the below Java program with arrays?
String[] ary = {"KITE", "AIR"};
String str = "PLANE";
ary[1] = str;
str = "FLY";
System.out.println(ary[1]);
A. AIR
B. PLANE
C. FLY
D. Compiler error
Solution: no solution

You Have Score    /9