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

Can we overload run() method in java?

599


Is it safe to install java on my computer?

542


What is difference between iterator and enumeration in java?

527


Explain the difference between static and dynamic binding in java?

545


Can you extend singleton class?

602






What is api data?

540


What is console based application in java?

544


What is the use of pattern in java?

511


What is linkedlist in java?

510


What are the 3 types of control structures?

531


What are synchronized methods ?

617


Is main a function?

516


What is boolean in java?

512


What is a parameter in simple terms?

562


Does substring create a new object?

530