GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java
Go To First  |  Previous Question  |  Next Question 
 Core Java  |  Question 476 of 502    Print  
What is the result of expression 5.45 + "3.2"?

  
Total Answers and Comments: 8 Last Update: September 08, 2008     Asked by: vanajsri6 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: for4me
 
The answer is 5.453.2

Above answer was rated as good by the following members:
yrus.exe, interviewprep9, sandeep549
May 04, 2008 09:40:37   #1  
for4me Member Since: May 2008   Contribution: 2    

RE: What is the result of expression 5.45 + "3.2"?
The answer is 5.453.2
 
Is this answer useful? Yes | NoAnswer is useful 2   Answer is not useful 0Overall Rating: +2    
May 27, 2008 15:58:11   #2  
rariedel Member Since: May 2008   Contribution: 8    

RE: What is the result of expression 5.45 + "3.2"?
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" ;


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
June 03, 2008 06:08:10   #3  
vaneet Member Since: July 2007   Contribution: 9    

RE: What is the result of expression 5.45 + "3.2"?
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.

 
Is this answer useful? Yes | No
July 23, 2008 08:35:40   #4  
jitendar singh Member Since: July 2008   Contribution: 1    

RE: What is the result of expression 5.45 + "3.2"?
yes sure .if the receiving type is String then both the operands will concatenate and form 5.453.2 as an answer.
 
Is this answer useful? Yes | No
July 24, 2008 08:49:26   #5  
ksrikanth5g Member Since: July 2008   Contribution: 3    

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

it will appen both as a 5.453.2


 
Is this answer useful? Yes | No
September 03, 2008 08:00:43   #6  
rajatsinghal21 Member Since: September 2008   Contribution: 2    

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

And what will be
String s 5.45 + 3.55 + 50 ;
String x 5.45 + 3.45 + 50;

and why?
A crunch point is here.

 
Is this answer useful? Yes | No
September 04, 2008 00:25:47   #7  
rajkr11 Member Since: January 2007   Contribution: 6    

RE: What is the result of expression 5.45 + "3.2"?
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.
 
Is this answer useful? Yes | No
September 07, 2008 18:54:31   #8  
Ramajayam Member Since: September 2008   Contribution: 4    

RE: What is the result of expression 5.45 + "3.2"?
If the variable 'str' is String
str 5.45+ 3.2 5.453.2

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape