-
What is the output of this program?
public class Result
{
public static void main(String[]args)
{
String[] array = { "for", "tea", "too" };
String num= (array.length > 2) ? array[2]: null;
}
}
-
- The variable num is set to elements[0].
- The variable num is set to null
- An exception is thrown at run time
- Compilation error
- None of these
Correct Option: A
The value at the 0th position will be assigned to the variable num.