What is the result of expression 5.45 + "3.2"?

Questions by vanajsri6

Showing Answers 1 - 24 of 24 Answers

rariedel

  • May 27th, 2008
 

The result of the expression depends entirely on the rest of the statement in which it appears. If 5.45 is treated as a flow, then a compiler error is thrown:

    float a = 5.45 + "3.2" ;

If 5.45 is converted to a String, then the result is "5.453.2":

  String a = 5.45 + "3.2" ;

vaneet

  • Jun 3rd, 2008
 

yes absolutely .
if the receiving type is String, then both teh operands will concatenate and form 5.453.2 as an answer.

but if teh recieving type is a primitive type, then that wud be a error.

  Was this answer useful?  Yes

rajkr11

  • Sep 4th, 2008
 

If the expression is assigned to string then result will be 5.453.2, if assign to other type like double, float, int etc. it will gives error.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions