Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


int a=1;
float b=1.0;
System.out.println(a==b);

Answers were Sorted based on User's Feedback



int a=1; float b=1.0; System.out.println(a==b); ..

Answer / aruna

this code will not compile since 1.0 will be taken as a
double instead of float, To make this code work, the
following changes shud b done

float b=1.0f;
or double = 1.0;

with these changes the SOP statement will print "true"

Is This Answer Correct ?    15 Yes 0 No

int a=1; float b=1.0; System.out.println(a==b); ..

Answer / anil kumar rai

error found when compile this code;
if u write 1 in place of 1.0 then output would be "true" or
if u write double in place of float then output would be
same :"true"

thank you

Is This Answer Correct ?    13 Yes 1 No

int a=1; float b=1.0; System.out.println(a==b); ..

Answer / ranga reddy

int a = 1;
float b = 1.0;
System.out.println(a==b);

if we declare float b = 1.o; by default it takes double value, then it will give compile time error as possiblelossofpression
then we declare as float b = 1.0f;

at this time System.out.println(a==b); gives

true

Is This Answer Correct ?    5 Yes 0 No

int a=1; float b=1.0; System.out.println(a==b); ..

Answer / saranya

ya its true only because content remains the same

Is This Answer Correct ?    4 Yes 0 No

int a=1; float b=1.0; System.out.println(a==b); ..

Answer / narasimha

i am sorry to say anil even if you put double in place
float also you are going to get flase not true.

Is This Answer Correct ?    5 Yes 3 No

int a=1; float b=1.0; System.out.println(a==b); ..

Answer / kavitha

if u just convert the float to double that will be sufficient
u get the answer "true"

Is This Answer Correct ?    2 Yes 0 No

int a=1; float b=1.0; System.out.println(a==b); ..

Answer / sudha

if u write
int a=1;
float b=1.0f;
system.out.println(a==b);

answer woill b true...as of now it wont compile

Is This Answer Correct ?    2 Yes 0 No

int a=1; float b=1.0; System.out.println(a==b); ..

Answer / praveenkumar managuli

nice answer aruna

Is This Answer Correct ?    1 Yes 0 No

int a=1; float b=1.0; System.out.println(a==b); ..

Answer / anilkumar munaganuri

in above question by providing explicit type casting as
float b=(float)1.0
then we can get output as true

Is This Answer Correct ?    1 Yes 0 No

int a=1; float b=1.0; System.out.println(a==b); ..

Answer / ravikiran

true because content remains the same

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More Core Java Interview Questions

What is the base class of all exception classes in java?

0 Answers  


What is the difference between a Window and a Frame?

6 Answers   Infosys, ProKarma,


How to convert string to int in java?

1 Answers  


in a constructor what happen if u call super and this in the same class? i know that it is not possible to call both in the same one? if we call what will happen?

10 Answers   ITC Infotech,


What is empty string literal in java?

0 Answers  


Explain java coding standards for methods?

0 Answers  


what is the difference b/w design pattern and architecture

4 Answers   Covansys,


What do you understand by access specifiers in Java?

0 Answers   Genpact,


What is the difference between char and char *?

0 Answers  


How does compareto method work?

0 Answers  


What is static import in java?

0 Answers  


What is left shift and right shift?

1 Answers  


Categories