what is the output?

what is the output?

public class MyAr{ public static void main(String argv[]) { int[] i=new int[5]; System.out.println(i[5]); } }

View Answers

March 14, 2011 at 1:10 PM

It gives ArrayIndexOutOfBoundsException as you haven't add element to array.

Correct Program is:

public class MyAr{
    public static void main(String argv[]) {
        int[] i=new int[5];
        i[0]=1;
        i[1]=2;
        i[2]=3;
        i[3]=4;
        i[4]=5;
        System.out.println(i[4]);
        }
        }









Related Tutorials/Questions & Answers:
outputs - Java Beginners
counting identifiers,no.of inputs and outputs - Java Magazine
Advertisements
Java program that inputs a document and then outputs a bar-chart pit
java outputs - Java Beginners
what is bit
what is hibernate.archive.autodetection
what is hibernate.archive.autodetection
what is hibernate.archive.autodetection
what is hibernate.archive.autodetection
what is hibernate.archive.autodetection
What is procedure
what is hibernate.archive.autodetection
What is Hibernate
What is Hibernate
What is JDBC?
What is FBT
What is ActionServlet?
What is Trigger?
What is VLR ?
What's PHP ?
What is an interface?
What is DML?
What is Index?
What is SQLLoader?
What is a "constraint"?
what is Savepoint ?
What is this keyword?
what is collections?
what are indices?
What is Hibernate
What is Hibernate
What is Externalizable?
What is the % operator?
What is casting?
What is DataAccessException?
What is IOC ?
What is SQLExceptionTranslator?
What are Struts?
What is WAP?
What is SPOOL?
What is CRM?
What is webservices?
What is Ajax?
What is NSRangeException
What is portal
What is a tuple?
what is RUP?
What was ENIAC
what is posting?
What is workflow

Ads