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
πŸ’¬ Discuss
βœ… Correct Answer: (A) Value is 67 18 String 13
Explanation: 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.
Explanation by: Ritu Nagar
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.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
184
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Ritu Nagar
Publisher
πŸ“ˆ
89%
Success Rate