Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class IndependenceDay {
    public static void main(String[] args) {
        GregorianCalendar gc = new GregorianCalendar(2013, 8, 15, 21, 69, 55);
        p(gc, Calendar.YEAR);
        p(gc, Calendar.MONTH);
        p(gc, Calendar.DATE);
        p(gc, Calendar.DAY_OF_WEEK);
        p(gc, Calendar.DAY_OF_WEEK_IN_MONTH);
        p(gc, Calendar.DAY_OF_YEAR);
        p(gc, Calendar.HOUR);
        p(gc, Calendar.HOUR_OF_DAY);
        p(gc, Calendar.MINUTE);
        p(gc, Calendar.SECOND);
    }
    static void p(Calendar c, int type) {
        System.out.print(c.get(type) + "-");
    }
}


2013-8-15-1-3-3-10-22-9-55-
2013-8-15-1-3-258-10-22-9-55-
2013-8-15-1-3-258-10-21-69-55-
Compilation Error
Runtime Error

Doubts

Problems

Topic: Java GregorianCalendar

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App