JAVA Programming :: Basic Concepts - Discussion
Home > JAVA Programming > Basic Concepts > MCQs Questions Discussion
14 / 64
Output of the below partial code.
String[] elements = {"Java","is","platform","independent"};
String result = (elements.length > 0) ? elements[0]:null;
System.out.printf(result);
String[] elements = {"Java","is","platform","independent"};
String result = (elements.length > 0) ? elements[0]:null;
System.out.printf(result);
Anull
BJava
CJav
DCompilation fails
Answer: Option (Login/Signup)
Show Explanation
The condition (elements.length>0) will result to True, since the length size of elements array is 4, which is greater than 0.
Therefore, elements[0] will be stored in result, or we can simply say, result = "Java".
Hence, output will be Java.
Asked In ::
STEP-BY-STEP
The condition (elements.length>0) will result to True, since the length size of elements array is 4, which is greater than 0.
Therefore, elements[0] will be stored in result, or we can simply say, result = "Java".
Hence, output will be Java.
Read Full Answer
Report Error
Please Login First Click Here