You are not logged in.

#1 2015-06-17 05:38:41

husnain
User RankUser RankUser RankUser RankUser RankUser Rank
Administrator
From: Chichawatni,Pakistan
Registered: 2014-10-03
Posts: 8,129
Website

Java Program Runs:

Java Quizzes Java Language Array

Directions:
public class Test{
        public static void main(String[] args){
                int[] x = new int[3];
                System.out.println("x[0] is " + x[0]);
        }
}

Question:
What will be the output?

Option A):
The program runs fine and displays x[0] is 0
Option B):
The program has a runtime error because the array element x[0] is not defined
Option C):
The program has a compile error because the size of the array wasn't specified when declaring the array
Option D):
The program has a runtime error because the array elements are not initialized

Correct Answer is Option A):
The program runs fine and displays x[0] is 0


You cannot discover the new oceans unless you have the courage to lose the sight of the shore.

2015-06-17 05:38:41

Advertisement
Ads By Google

Re: Java Program Runs:



\n

Board footer