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. 

 
Core Java  Interview Questions and Answers for 'Double'  8 question(s) found  Order By Newest  
 
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 questionCorrectionDuplicate of Another QuestionCompany where this question was AskedSuggestion}  
_{}
 
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 decimalCorrectionDuplicate of Another QuestionCompany where this question was AskedSuggestion}  
Rarely asked as it was introduced with Java 8.  
_{}
 
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 summarystatisticsCorrectionDuplicate of Another QuestionCompany where this question was AskedSuggestion}  
 
Ans. http://www.buggybread.com/2015/01/javadatatypesdoubleclassesand.html  
Help us improve. Please let us know the company, where you were asked this question :  
_{ Like Discuss Correct / Improve java data types doubleCorrectionDuplicate of Another QuestionCompany where this question was AskedSuggestion}  
 
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 bigdecimalCorrectionDuplicate of Another QuestionCompany where this question was AskedSuggestion}  
_{}
 
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 frequentCorrectionDuplicate of Another QuestionCompany where this question was AskedSuggestion}  
_{}
 
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 typesCorrectionDuplicate of Another QuestionCompany where this question was AskedSuggestion}  
_{}
 
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 doubleCorrectionDuplicate of Another QuestionCompany where this question was AskedSuggestion}  