Showing posts with label .NET Console Output. Show all posts
Showing posts with label .NET Console Output. Show all posts

Monday, May 12, 2014

Console Output

Question: What would be the output of the following block of code: 
     DECLARE @TEMP varchar(100)
     SET @TEMP = NULL

            IF @TEMP = ''
                PRINT('A')
            IF LTRIM(RTRIM(@TEMP )) = ''
                PRINT('B')
            IF @TEMP IS NULL
                PRINT('C')
            IF @TEMP = NULL
                PRINT('D')
            IF ISNULL(@TEMP,'') = ''
                PRINT('E')
        
Answer:
The code will not compile and will generate an errors. Error in first line.

Console Output

Question: Write out the output (what would be written to the console), when this following block of code is run:
            public class ZipData
                {
                    string ZipCode { get; set; }
                    string CityName { get; set; }
                    string StateName { get; set; }
                }

                public static class ZipHelper
                {
                    public static string WhatsMyCity(string Zip)
                    {
                        //Returns a string representing the City for the Zip provided
                        //Returns null if string is not a zip or not found in database
                    }
                    public static string WhatsMyState(string Zip)
                    {
                        //Returns a string representing the State for the Zip provided
                        //Returns null if string is not a zip or not found in database
                    }
                } 
            
Answer:
WhatsMyCity and WhatsMyState are not returning anything so the program will not compile.