Created
June 7, 2017 08:35
-
-
Save supreettare/d74d352706f1a21abf9fd16f8b04081d to your computer and use it in GitHub Desktop.
What is the output of the short program below? Explain your answer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Program { | |
| static String location; | |
| static DateTime time; | |
| static void Main() { | |
| Console.WriteLine(location == null ? "location is null" : location); | |
| Console.WriteLine(time == null ? "time is null" : time.ToString()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
null is the default value of reference types so the statement "location == null" evaluates to true.
time will be set to a default value.