Which of the following is a valid declaration of a two-dimensional array in Java that can store 3 rows and 4 columns of integers?
Aint arr[][] = new int[3][4];
Bint[] arr[] = new int[3][4];
Cint[][] arr = new int[3][4];
DAll of the above
Correct Answer:
D. All of the above
EXPLANATION
All three declarations are syntactically valid in Java and represent the same 2D array structure. The position of brackets doesn't matter for 2D array declaration - they all create a 3x4 integer array.
Which of the following statements about Java's garbage collection is TRUE?
AGarbage collection is guaranteed to run at specific time intervals
BThe programmer must explicitly call System.gc() to free memory
CGarbage collection automatically reclaims memory used by unreferenced objects
DJava does not have automatic garbage collection mechanism
Correct Answer:
C. Garbage collection automatically reclaims memory used by unreferenced objects
EXPLANATION
Java's garbage collector automatically identifies and reclaims memory of objects that are no longer referenced. While System.gc() can be suggested, it's not guaranteed to execute immediately.