Date & Time


  1. Which of these class allows us to get real time data about private and protected member of a class?











  1. 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 .


  1. 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));
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    format string “z” is used to print time zone.



  1. 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));
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Mon Nov 26 2018


  1. 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));
    }
    }











  1. 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.



  1. 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));
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    24:08:18