Computer Applications
Correct statement to declare an integer array of 10 elements.
- int[ ] arr = new int[10];
- int arr;
- int arr (10);
- int ( ) arr = new int (10);
Java Arrays
6 Likes
Answer
int[ ] arr = new int[10];
Reason — The correct syntax to declare an array is as follows:
datatype[ ] array_name = new datatype[size];
The statement int[ ] arr = new int[10]; follows the correct syntax of array declaration.
Answered By
4 Likes
Related Questions
Read the following text and choose the correct answer:
Public access specifier allows a class to expose its member variables and member functions to other functions and objects. Any public member can be accessed from outside the class.
Which of these access specifier must be used for class so that it can be inherited by another subclass?
- public
- private
- protected
- none of the mentioned
Assertion (A) The return statement causes program control to transfer back to the caller of the method.
Reason (R) The return statement immediately terminates the method in which it is executed.- Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of Assertion (A).
- Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of Assertion (A).
- Assertion (A) is true and Reason (R) is false.
- Assertion (A) is false and Reason (R) is true
Write the values of r and s after the execution of the following code.
int p = 11, q = 21, r, s; r = ++q; s = p++; r++;Observe the following code and find that how many times will the loop execute?
int sum = 0, score = 0; double t; do { score = score + 1; sum = sum + score; } while(score <= 3); t = sum / 3;