InterviewSolution
Saved Bookmarks
| 1. |
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);This intriguing question comes from Array and Array Operations in portion Abstract Data Types of Data Structures & Algorithms IThis question was addressed to me at a job interview. |
|
Answer» CORRECT ANSWER is (c) int ARR[] = NEW int[3]; For explanation: Note that int arr[]; is declaration whereas int arr[] = new int[3]; is to instantiate an array. |
|