Multiple choice

What will be the output of following code: class pattern { public static void main(String arts[]) String a = "WELCOME", b; for(i=0; i<=a.length(); i ++;) { b= a.substring(0,i); system.out.print(b); } } }

  1. WWEWELWELCWELCOWELCOMWELCOM

  2. WELCOMEWELCOMWELCOWELCWELWEW

  3. W WE WEL WELC WELCO WELCOM WELCOME

  4. WELCOME

  5. None of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

A is an array having value “WELCOME “. So at 0th position W is present.i=0a.substring(0,0) =>Wi=1a.substring(0,1) =>WEi=2a.substring(0,2) =>WELTherefore option ‘1’ is correct answer.