Answered Questions

  • Output of Java Program

    What is the output of the following program?class A{ public static void main(String[] s) { System.out.println(s[1] + s[2] + s[3]);}}java A 12345Options(i) 1(ii) 12(iii)1234(iv)234(v) Compilation Error

    Star Read Best Answer

    Editorial / Best Answer


    • Member Since Jan-2008 | Apr 14th, 2008

    Khadar , i tried this code . it gives that exception

    for the foll reason : 
     when u give a CLA(command line argument) , it will be inserted in the index 0 of the array and then will proceed to 1 ,2 ....

    so as per the question , "12345" will be at s[0] . and length of that aray will be 1when u try to access s[1] , we are trying for 2nd element which is unavailable..... 

    Hope this answers u  :-)


    • Jun 2nd, 2018

    (v) Compilation Error


    • Mar 14th, 2018

    (v) Compilation Error