Introduction to Arrays

Advertisements
Advertisements
Advertisements3
Advertisements4
Advertisements6
Advertisements66

1. What is the output of the following pseudo-code?

String[] languages = {“Telugu”, “Tamil”, “Sanskrit”, “English”};
languages[4] = “Japanese”;
System.out.println(languages[0]);

Ans. Array Index Out of Bounds exception.

2. What is the syntax for initializing an array in Java?

Ans. type[] array Name = new type[size];

3. How do you access a specific element in a one-dimensional array in Java?

Ans. array[index];

4. What is the default value of an integer array element in Java?

Ans. 0.

 
 
 

Author: Lakshmi Prasanna Ponnala

Completed M.Tech in Digital Electronics and Communication Systems.

Leave a Reply

error: Content is protected !!

Discover more from ece4uplp

Subscribe now to keep reading and get access to the full archive.

Continue reading