Basic Datatypes
- How to convert a String to a Date object?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
SimpleDateFormat takes a string containing pattern. sdf.parse converts the String to Date object.
- How to convert Date object to String?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
SimpleDateFormat takes a string containing pattern. sdf.format converts the Date object to String.
- How to convert Date object to String?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
SimpleDateFormat takes a string containing pattern. sdf.format converts the Date object to String.
- How to format date from one form to another?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
SimpleDateFormat can be used as:
Date now = new Date();
SimpleDateFormat date = new SimpleDateFormat ("yyyy-mm-dd'T'hh:MM:ss");
String nowStr = date.format(now);
System.out.println("Current Date: " + );
- What is the output of below code snippet?
public class Output
{
public static void main(String args[])
{
BigDecimal z = new BigDecimal("23.43");
BigDecimal br = new BigDecimal("24");
BigDecimal bres = z.add(new BigDecimal("450.23"));
System.out.println("Add: "+bres);
MathContext mc = new MathContext(2, RoundingMode.DOWN);
BigDecimal bdecMath = z.add(new BigDecimal("450.23"), mc);
System.out.println("Add using MathContext: "+bdecMath);
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
add() adds the two numbers, MathContext provides library for carrying out various arithmetic operations.