COMPILER DESIGN

ADVANCED TOPICS IN COMPILER DESIGN

CODE GENERATION FOR OBJECT ORIENTED LANGUAGES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
How do you instantiate an array in Java?
A
int arr[] = new int(3);
B
int arr[];
C
int arr[] = new int[3];
D
int arr() = new int(3);
Explanation: 

Detailed explanation-1: -To instantiate an array, use this syntax: arrayName = new datatype[ size ]; where size is an expression that evaluates to an integer and specifies the number of elements. When an array is instantiated, the elements are assigned default values according to the array data type.

Detailed explanation-2: -Initializing an array Declaring an array does not initialize it. In order to store values in the array, we must initialize it first, the syntax of which is as follows: datatype [ ] arrayName = new datatype [size];

There is 1 question to complete.