Date & Time
- Which of these class allows us to get real time data about private and protected member of a class?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
The ReflectPermission class allows reflection of private or protected members of a class. This was added after java 2.0 .
- What is the output of this program?
import java.text.*;
import java.util.*;
public class DateFormatting_Example
{
public static void main(String args[])
{
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("z");
System.out.print(sdf.format(d));
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
format string “z” is used to print time zone.
- What is the output of this program?
import java.text.*;
import java.util.*;
public class DateFormatting_Example
{
public static void main(String args[])
{
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("E MMM dd yyyy");
System.out.print(sdf.format(d));
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Mon Nov 26 2018
- What is the output of this program?
import java.text.*;
import java.util.*;
public class DateFormatting_Example
{
public static void main(String args[])
{
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm");
System.out.print(sdf.format(d));
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
The code “sdf = new SimpleDateFormat(“hh:mm”);” create a SimpleDataFormat class with format hh:mm where h is hours, m is month.
- What is the output of this program?
import java.text.*;
import java.util.*;
public class DateFormatting_Example
{
public static void main(String args[])
{
Date d = new Date();
SimpleDateFormat sdf;
sdf = new SimpleDateFormat("mm:hh:ss");
System.out.print(sdf.format(d));
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
24:08:18