[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

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);

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 :: Virtusa

Post Your Answer Here:     

Reply    
Rate This: +0 -0
    Report


Report Error

Please Login First Click Here