© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

Home Placements Interview Questions Java Interview Questions And Answers Java Interview Questions On Arrays and Data Types ▼

Java Interview Questions On Arrays and Data Types

3. What are all the default initialized values for java primitive data types?

Answer

Type of Element    Initial Value
byte                           0
short                          0
char                            '\u0000' ( unicode representation )
int                              0
long                           0L
float                           0.0f
double                        0.0d
boolean                      false
Object Reference       null

4. Select all the correct answers from the following ?
[a] An array can store many different types of values.
[b] An array subscript should normally be of 'double' data type.
[c] An array can store only same data type.
[d] An array can only stores objects

Answer
[c] An array can store only same data type.

5. What is the result when you compile and run the following program?
public class MyArray {
public static void main(String arg[]){
int myArray []= new int [10];
for (int i=0; i<myArray.length; i++) {
System.out.println(myArray[i]);
}
}
}

[a] Prints all 0's on the screen from 0 to 9 in sequence.
[b] Prints on the screen from 1 to 10 in sequence.
[c] Prints on the screen 0 only.
[d] Compile time error.

Answer

[a] Prints all 0's on the screen from 0 to 9 in sequence

6. Which of the following is used to find the length of an array?
[a] arrayName.length;
[b] arrayName.length();
[c] arrayName.size();
[d] arrayName.size;

Answer

[a] arrayName.length;
Previous Next
1 2 3
SLogix Student Projects
bottom