Java Quiz 3 : Data Types By Tejas Chaudhari - August 24, 2021 FacebookTwitterPinterestWhatsApp Welcome to your Java Quiz 3 : Data Types 1. Which of the following is not provided by BigDecimal?a) scale manipulationb) + operatorc) roundingd) hashing 2. BigDecimal is a part of which package?a) java.langb) java.mathc) java.utild) java.io 3. What is BigDecimal.ONE?a) wrong statementb) custom defined statementc) static variable with value 1 on scale 10d) static variable with value 1 on scale 0 4. Which class is a library of functions to perform arithmetic operations of BigInteger and BigDecimal?a) MathContextb) MathLibc) BigLibd) BigContext 5. What will be the output of the following Java code snippet? 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 failureb) Add: 473.66 Add using MathContext: 4.7E+2c) Add 4.7E+2 Add using MathContext: 473.66d) Runtime exception 6. How to format date from one form to another?a) SimpleDateFormatb) DateFormatc) SimpleFormatd) DateConverter 7. How to convert Date object to String?a) SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd"); sdf.parse(new Date());b) SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd"); sdf.format(new Date());c) SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd"); new Date().parse();d) SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd"); new Date().format(); 8. How to convert a String to a Date object?a) SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd"); sdf.parse(new Date());b) SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd"); sdf.format(new Date());c) SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd"); new Date().parse();d) SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd"); new Date().format(); 9. Is SimpleDateFormat thread safe?a) Trueb) False 10. How to identify if a timezone is eligible for DayLight Saving?a) useDaylightTime() of Time classb) useDaylightTime() of Date classc) useDaylightTime() of TimeZone classd) useDaylightTime() of DateTime class 11. What is the replacement of joda time library in java 8?a) java.time (JSR-310)b) java.date (JSR-310)c) java.jodad) java.jodaTime 12. How is Date stored in database?a) java.sql.Dateb) java.util.Datec) java.sql.DateTimed) java.util.DateTime 13. What does LocalTime represent?a) Date without timeb) Time without Datec) Date and Timed) Date and Time with timezone 14. How to get difference between two dates?a) long diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis();b) long diffInMilli = java.time.difference(dateTime1, dateTime2).toMillis();c) Date diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis();d) Time diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis(); 15. How to get UTC time?a) Time.getUTC();b) Date.getUTC();c) Instant.now();d) TimeZone.getUTC(); Time is Up!