Core Java - Interview Questions and Answers for 'Arithmetic calculation' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Core Java - Interview Questions and Answers for 'Arithmetic calculation' - 1 question(s) found - Order By Newest

 Q1. What will be the output of following code and Why ?

int x = 5;
int y = 7;
float f = 5f;
float z = y / x * f;
System.out.println(z);
Core Java
Ans. 5.0

operation between two ints generate int only. so 7/5 generates 1 and not 1.4. Multiplication between int and float generates float and hence

1 * 5.0 = 5.0

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     arithmetic calculation  data types


Related Questions

  Which of the following exception is thrown when we try to access element which is beyond the size ?
 Can you explain following exception

java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.



Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: