Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class DaysWeekNumber {
    public static void main(String[] args) {
        GregorianCalendar gc = new GregorianCalendar(2014, 1, 1);
        System.out.print(gc.get(Calendar.DAY_OF_WEEK) + "~");
        for (int i = 0; i < 10; i++) {
            System.out.print(gc.get(Calendar.DAY_OF_WEEK_IN_MONTH) + "~");
            gc.add(Calendar.DATE, 3);
        }
    }
}


1~1~1~2~2~2~3~3~4~4~1~
7~1~1~1~1~1~1~1~2~2~2~
7~1~1~1~2~2~3~3~4~4~4~
Compilation Error or 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