Array Instance Variables

Array Instance Variables

We know that Array is a type of object. its also declared but not explicitly initialized for the value of Null.just as other object reference instance variable.Here most imp line is \" Array elements are always always always given default values, regardless of where the array itself is declared or instantiated\".

When we would like to initialize an array and that time object reference elements value is equal to null.

public class BirthDays {
static int [] year = new int[100];
public static void main(String [] args) {
for(int i=0;i<100;i++)
System.out.println(\"year[\" + i + \"] = \" + year[i]);

Date:2024-02-09 00:00:00

Post Your Answers

User Email:

User Name:

Related SCJP1.5 chap1 Links

SCJP1.5 chap1 interview questions and answers for experienced and fresher