Welcome to the C# Dates and Times Quiz! This quiz is designed to test your understanding of how to work with dates and times using the DateTime object in C#. You will encounter questions about creating DateTime objects, manipulating dates and times, and accessing specific components like days, months, and hours. The quiz will also cover methods for adding or subtracting time, retrieving the current system date and time, and formatting outputs.
1.
What is the default time set when only a date is specified in a C# DateTime object?
2.
Which of the following will return the current system date and time?
3.
How do you add five days to a DateTime object in C#?
4.
Which method would you use to subtract 10 months from a DateTime object?
5.
Which property would you use to retrieve the current year from a DateTime object?
6.
How is the time 2:30 PM represented in the 24-hour format within a DateTime object?
7.
Which method adds a specific number of hours to a DateTime object?
8.
What does DateTime.Today return?
9.
How do you create a DateTime object representing April 9, 2024, at 14:30:00?
10.
Which method is used to add milliseconds to a DateTime object?
11.
Which DateTime property is used to retrieve just the time portion of a date and time?
12.
What will be the output of DateTime.Now.ToString()?
13.
Which of the following statements will return the current system time?
14.
How would you subtract 2 days from a DateTime object?
15.
Which method would you use to add 3 years to a DateTime object?