What happens when you assigned a 'double' value to
a 'String'?

Answer Posted / cleon

@Pankaj:
What are you trying to do?, trying to call a function from
primitive type/reference, that that will never work. You can
call function on Object types.

Double d = 5.5D; //D is optional as by default it is treated
to be double value
String s = d.toString();

If one tries to do something like
String s = 5.5;
A type mismatch errors will be shown during compilation itself!!

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is scope of a variable?

593


Can an integer be null java?

548


Does java vector allow null?

528


What is dot operator?

563


What is tcp ip in java?

579






Difference between static binding and dynamic binding?

551


What does string mean in java?

616


Does string is thread-safe in java?

582


How to provide security in java

1795


What are static variables and functions?

613


What is garbage collection? What is the process that is responsible for doing that in java?

641


What is java abstraction with example?

545


How will you reverse a singly-link list?

586


How big is a gigabyte?

607


What is a generic type?

550