Menu
Topics Index
...
`

Calendar2559


If you need explanation Read this topic

If you need Answer Take test on this topic

Calendar2559
What will be the output of the following program?
import java.util.*;
public class CalendarDemo {
    public static void main(String[] args) {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR, 73);
        cal.set(Calendar.MINUTE, 158);
        cal.set(Calendar.SECOND, 60);
        System.out.print(cal.get(Calendar.HOUR) + ":");
        System.out.print(cal.get(Calendar.MINUTE) + ":");
        System.out.print(cal.get(Calendar.SECOND));
    }
}

A. 1:38:0
B. 1:39:0
C. 3:39:0
D. Some other output
E. Output can not be determined
F. Compilation Error or Runtime Error
Topic: Calendar In Java - java.util.Calendar Class

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

73%12= 1
158%60=38
60%60=1
ans : b
bcz 60 sec consider as one minute

Posted by Sree Priya    2014-04-22 09:05:30


Answer is c... 3:39:0...HOUR indicates the hour with in the day...MINUTE is the variable that indictaes the minute with in the hour..Second indicates the second within the minute...so the answer is C...

Posted by Sneha Rapool    2014-04-22 09:51:50


Ans is B as Calendar is default class in util package cal is object of calendar class and set the time values hours minutes and sec as 73 158 and 60 and prints the hour minute and seconds as 73%12=1 and 158%60=38 and 60%60 is 1 and addede to minute and displays

Posted by Bharath Yelchuri    2014-04-22 12:42:08


Congratulations Sneha Rapool. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-04-23 04:25:26


© meritcampus 2019

All Rights Reserved.

Open In App