A

Admin • 831.35K Points
Coach

Q. Determine output:

Code:
public class Test{
public static void main(String... args){
int a=5 , b=6, c=7;
System.out.println("Value is "+ b + c);
System.out.println(a + b + c);
System.out.println("String " + (b+c));
}
}
  • (A) Value is 67 18 String 13
  • (B) Value is 13 18 String 13
  • (C) Value is 13 18 String
  • (D) Value is 13 18 StringD.Compilation fails
  • Correct Answer - Option(A)
  • Views: 18
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
If the left hand operand is not a String then + operator treat as plus BUT if the left hand operand is a String then + perform String concatenation.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.