Question
public class AddDemo
{
public static void main(String args[])
{
BigDecimal b = new BigDecimal("23.43");
BigDecimal br = new BigDecimal("24");
BigDecimal bres = b.add(new BigDecimal("450.23"));
System.out.println("Add: "+bres);
MathContext mc = new MathContext(2, RoundingMode.DOWN);
BigDecimal bdecMath = b.add(new BigDecimal("450.23"), mc);
System.out.println("Add using MathContext: "+bdecMath);
}
}
a.
Compilation failure
b.
Add: 684.66
Add using MathContext: 6.8E+2
c.
Runtime exception
d.
Add 6.8E+2
Add using MathContext: 684.66
Posted under Java Programming
Add using MathContext: 6.8E+2
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What is the output of below code snippet?
Similar Questions
Discover Related MCQs
Q. Which of these is long data type literal?
View solution
Q. Which of these can be returned by the operator &?
View solution
Q. Literals in java must be appended by which of these?
View solution
Q. Literal can be of which of these data types?
View solution
Q. Which of these can not be used for a variable name in Java?
View solution
Q. Which of these is necessary condition for automatic type conversion in Java?
View solution
Q. What is the prototype of the default constructor of this class?
public class prototype { }
View solution
Q. If an expression contains double, int, float, long, then the whole expression will be promoted into which of these data types?
View solution
Q. What is Truncation is Java?
View solution
Q. Which of these operators is used to allocate memory to array variable in Java?
View solution
Q. Which of these is an incorrect array declaration?
View solution
Q. Which of these is an incorrect Statement?
View solution
Q. Which of these is necessary to specify at time of array initialization?
View solution
Q. Generics does not work with?
View solution
Q. How to sort an array?
View solution
Q. How to copy contents of array?
View solution
Q. Can you make an array volatile?
View solution
Q. Where is array stored in memory?
View solution
Q. An array elements are always stored in ________ memory locations?
View solution
Q. What is the range of short data type in Java?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Java Programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!