COMPILER DESIGN

ADVANCED TOPICS IN COMPILER DESIGN

CODE GENERATION FOR OBJECT ORIENTED LANGUAGES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which of these is an incorrect array declaration?
A
int arr[] = new int[5];
B
int arr[5] = new int [];
C
int arr[];arr = new int[5];
D
int [] arr = new int[5];
Explanation: 

Detailed explanation-1: -Explanation: int arr[] = int [5] is an incorrect array declaration because Operator new must be succeeded by array type and array size.

Detailed explanation-2: -int x[5]=1, 2; ⇒ is an incorrect declaration of one dimensional array. One dimensional array : Before using an array variable in a program, it must be declared. A data type (int, float, char, double, etc. ), variable name, and subscript must all be included in the declaration.

Detailed explanation-3: -To create an array, define the data type (like int ) and specify the name of the array followed by square brackets []. To insert values to it, use a comma-separated list, inside curly braces: int myNumbers[] = 25, 50, 75, 100;

There is 1 question to complete.