KODNEST
ARRAYS IMPORTANT QUESTIONS AND ANSWERS
R.PUNITH KUMAR
kodnest
KODNEST WWW.KODNEST.COM PH: 7411615623
1. When should an array data structure be used?
(Array data structure should be used when numerous data of
the same type has to be stored.)
2. What is an advantage of an array data structure?
(Creation of an array is simple, inserting data into an array
is simple by making use of loops. Extracting data from the
array is also simple by making use of loops)
3. What are the different types of arrays in Java?
(1-dimensional, 2-dimensional, 3-dimensional, …… n-
dimensional regular and jagged array)
4. Design an array data structure to collect marks of 100
students of a class?
(int a[] = new int[100];)
5. Design an array data structure to collect marks of students in
5 classes each with 100 students?
(int a[][] = new int[5][100];)
6. Design an array data structure to collect marks of students in
3 schools each with 5 classes each with 100 students?
(int a[][][] = new int[3][5][100];)
KODNEST WWW.KODNEST.COM PH: 7411615623
7. What is the advantage of jagged array data structure?
(In real life, the data is not regular rather in most of the time,
data is irregular or jagged. Hence, to provide a solution for the
jagged data, java supports jagged array data structure.)
8. Are arrays objects in Java?
(Yes)
9. What are the default values associated with an array?
(The default value of an array depends upon the data type of
an array.
Eg: int-0, float-0.0, char-blank character, boolean -false)
10. What is the default value present in objects array?
(null)
----------------------------------------------------
Research on the following:
i) Write a java program to search an element in an character
array using liner search algorithm.
ii) Write a java program to search an element in an float array
using binary search algorithm.
KODNEST WWW.KODNEST.COM PH: 7411615623
iii) Can we copy the contents of 2-d array into another 2-d
array and a 3-d array into another 3-d array ? if yes ! then go
give a try by writing the code.
iv) You can create an integer array , float array , boolean array
etc.. but can you create a Student array ?
I mean ….
Can we write a code like this ?
class Student
{
int id;
int age;
}
class StudentApp
{
public static void main(String args[])
{
Student arr[]=new Student[5];
}
}