Java OCA OCP Practice Question 1475

Question

What will be the output of the following lines ?

System.out.println ("" +6 + 6);   //1 
System.out.println (6 + "" +6);   // 2 
System.out.println (6 + 6 +"");   // 3 
System.out.println (6 + 6);       // 4 

Select 1 option

  • A. 66, 66, 12, 12
  • B. 12, 66, 12, 12
  • C. 66, 66, 66, 12
  • D. 66, 66, 66, 66
  • E. 66, 66, 12, 66


Correct Option is  : A

Note

In line 1, "" + 6 + 6 => "6"+6 => "66"

In line 2, 6 + "" +6 => "6"+6 => "66"

In line 3, 6 + 6 +"" => 12+"" => "12"

In line 4, 6 + 6 => 12 => "12"




PreviousNext

Related