Explore topic-wise MCQs in Java Programming.

This section includes 4 Mcqs, each offering curated multiple-choice questions to sharpen your Java Programming knowledge and support exam preparation. Choose a topic below to get started.

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

A. z
B. UTC
C. Nov
D. Tue
E. None of these
Answer» C. Nov
2.

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

A. 26 2018
B. Nov 26 2018
C. Mon Nov 26 2018
D. Mon
E. Mon 26 2018
Answer» B. Nov 26 2018
3.

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

A. 08:28:25
B. 08
C. Compilation Error
D. 08:28
E. Runtime Error
Answer» E. Runtime Error
4.

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

A. 24:08
B. 24:08:18
C. 24
D. Compilation error
E. Runtime error
Answer» C. 24