go to previous page   go to home page   go to next page hear noise highlighting
int x = 1;
int y = 9;
System.out.println( Math.sqrt( (double)x/y ) );

Answer:

Yes.


Type Casting

In the above, the integer in x is converted to double before the division is done. Now y must also be converted to double and double precision floating point division is performed.

Next the result (0.111111111) is sent to sqrt() as an argument. The expected result (0.33333333) is returned.


QUESTION 17:

Are these details a little overwhelming?


go to previous page   go to home page   go to next page