Q. Which of the following is the correct syntax for declaring an array of integers in Java?

  • (A) int[] myArray = {1, 2, 3, 4, 5};
  • (B) int myArray[] = {1, 2, 3, 4, 5};
  • (C) int[] myArray = new int[5];
  • (D) int myArray[5] = {1, 2, 3, 4, 5};
πŸ’¬ Discuss
βœ… Correct Answer: (A) int[] myArray = {1, 2, 3, 4, 5};
Explanation: The syntax for declaring an array of integers in Java is to use the int[] keyword followed by the name of the array, an equal sign, and a list of values enclosed in curly braces.
Explanation by: Deepak Sahoo
The syntax for declaring an array of integers in Java is to use the int[] keyword followed by the name of the array, an equal sign, and a list of values enclosed in curly braces.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
265
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Deepak Sahoo
Publisher
πŸ“ˆ
91%
Success Rate