Core Java - Interview Questions and Answers for 'Double' | 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 'Double' - 8 question(s) found - Order By Newest

 Q1. What is the difference between float and double?
Ans. Float can represent up to 7 digits accurately after decimal point, where as double can represent up to 15 digits accurately after decimal point.

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

   Like         Discuss         Correct / Improve     java   data types   float   double   difference between   basic interview question


 Q2. Have you ever faced problems with rounding decimal places and what were the reasons ? Core Java
Ans. 1. The problem with double (x*100)/100 doesn't return exact x but few fractions lesser than x and then if you are using floor rounding , it makes a big difference

2. Rounding only after getting a result vs rounding each outcome of 2 operand make difference

3. Usage of inappropriate Rounding mode and Rounding scale.

4. Results with double and BigDecimal

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

   Like         Discuss         Correct / Improve     BigDecimal  double  round  decimal


Rarely asked as it was introduced with Java 8.
 Q3. Difference between DoubleSummaryStatistics , IntSummaryStatistics and LongSummaryStatistics ?Core Java
Ans. They all does the same task i.e to compute statistical information on the stream of data. They differ by the way they store the statistical information as they expect a different data type of the values being used.

IntSummaryStatistics and LongSummaryStatistics expect non floating point values and hence stores the statistical information like min,max and sum as non floating values ( int or long ) whereas DoubleSummaryStatistics stores these information as floating value.

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

   Like         Discuss         Correct / Improve     java   java8   java 8   lambda expressions   doublesummarystatistics   intsummarystatistics   longsummarystatistics   summarystatistics


 Q4. Name few Double data types related classes and interfaces ?
Ans. http://www.buggybread.com/2015/01/java-data-types-double-classes-and.html

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

   Like         Discuss         Correct / Improve     java   data types   double


 Q5. Which of the following data type you will prefer to store price - BigDecimal or Double ?
Ans. BigDecimal if memory and Performance is not critical concern, otherwise double.

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

   Like         Discuss         Correct / Improve     java   data types   double   bigdecimal


 Q6. Why calculations in float or Double sometimes gives unpredictable results ?Core Java
Ans. Because the way float values are stored its not precise.

For example - 0.1 is actually stored as
0.1000000000000000055511151231257827021181583404541015625

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

   Like         Discuss         Correct / Improve     double  float  data type      basic        frequent


 Q7. What is the advantage of BidDecimal over Double ?Core Java
Ans. BigDecimal provides more precision as compared to double.

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

   Like         Discuss         Correct / Improve     BigDecimal  Double  data types


 Q8. Math.round method rounds the decimal to an integer by stripping off the decimal places. How can we use the same method to keep only 2 decimal places

For example -

Math.round(12.3456) will return 12. What should we do to get 12.34 without using any other class or method.
Core Java
Ans. We can multiply the value by 100 and then use Math.round on that and then divide the result by 100

For example -

(Math.round(12.3456 * 100)) / 100

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

   Like         Discuss         Correct / Improve     Math.round  double



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: