Examveda
Examveda

What will be output?
String S1 = "S1 ="+ "123"+"456";
String S2 = "S2 ="+(123+456);

A. S1=123456, S2=579

B. S1=123456,S2=123456

C. S1=579,S2=579

D. None of This

Answer: Option A

Solution(By Examveda Team)

If a number is quoted in "" then it becomes a string, not a number any more.


This Question Belongs to Java Program >> Strings

Join The Discussion

Comments ( 3 )

  1. Prince Jain
    Prince Jain :
    2 years ago

    None of these,
    Coz the output will be
    S1 =123456, S2 =579
    S1 with space and = after number
    Same for s2

  2. Balachandar Balu
    Balachandar Balu :
    4 years ago

    What would be behaviour if the constructor has a return type?
    Select one:
    a. Compilation and runs successfully
    b. Compilation error
    c. Runtime error
    d. Only String return type is allowed

  3. Hypnotoad
    Hypnotoad :
    7 years ago

    Mistakes have been made...

Related Questions on Strings