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

Search Interview Questions


 2679 questions in repository.
 There are more than 200 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?
Admin
info@buggybread.com
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


Rarely asked as it was introduced with Java 8.
 Q2. Difference between DoubleSummaryStatistics , IntSummaryStatistics and LongSummaryStatistics ?Core Java
Admin
info@buggybread.com
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


 Q3. Name few Double data types related classes and interfaces ?
Admin
info@buggybread.com
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


 Q4. Which of the following data type you will prefer to store price - BigDecimal or Double ?
Admin
info@buggybread.com
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


 Q5. Why calculations in float or Double sometimes gives unpredictable results ?Core Java2016-11-21 11:26:07

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


 Q6. What is the advantage of BidDecimal over Double ?Core Java2018-04-10 15:04:39

 This question is still unanswered. Can you please provide an answer.


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

   Like      Discuss      Correct / Improve     BigDecimal  Double  data types


 Q7. 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 Java2018-05-19 07:48:35

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


 Q8. Have you ever faced problems with rounding decimal places and what were the reasons ? Core Java2018-05-19 07:52:17

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




Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

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:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: