Tuesday 3 November 2015

25 Java Array Interview Questions And Answers


1) What is ArrayStoreException in java? When you will get this exception? 
2) Can you pass the negative number as an array size? 
3) Can you change the size of the array once you define it? OR Can you insert or delete the elements after creating an array? 
4) What is an anonymous array? Give example? 
5) What is the difference between int[] a and int a[] ? 
6) There are two array objects of int type. one is containing 100 elements and another one is containing 10 elements. Can you assign array of 100 elements to an array of 10 elements? 
7) “int a[] = new int[3]{1, 2, 3}” – is it a legal way of defining the arrays in java? 
8) What are the differences between Array and ArrayList in java? 
9) What are the different ways of copying an array into another array? 
10) What are jagged arrays in java? Give example? 
11) How do you check the equality of two arrays in java? OR How do you compare the two arrays in java? 
12) What is ArrayIndexOutOfBoundsException in java? When it occurs? 
13) How do you sort the array elements? 
14) How do you find the intersection of two arrays in java? 
15) What are the different ways of declaring multidimensional arrays in java? 
16) While creating the multidimensional arrays, can you specify an array dimension after an empty dimension? 
17) How do you search an array for a specific element? 
18) What value does array elements get, if they are not initialized? 
19) How do you find duplicate elements in an array? 
20) What are the different ways to iterate over an array in java? 
21) How do you find second largest element in an array of integers? 
22) How do you find all pairs of elements in an array whose sum is equal to a given number? 
23) How do you separate zeros from non-zeros in an integer array? 
24) How do you find continuous sub array whose sum is equal to a given number? 
25) What are the drawbacks of the arrays in java? 

No comments:

Post a Comment