Examveda
Examveda

What will be the output of the following Java program?
class Abc
{
    public static void main(String[]args)
    {
        String[] elements = { "for", "tea", "too" };
        String first = (elements.length > 0) ? elements[0]: null;
    }
}

A. Compilation error

B. An exception is thrown at run time

C. The variable first is set to null

D. The variable first is set to elements[0]

Answer: Option D


This Question Belongs to Java Program >> Overriding And Overloading

Join The Discussion

Related Questions on Overriding and Overloading