adplus-dvertising

Welcome to the Data Types,Variables and Operators MCQs Page

Dive deep into the fascinating world of Data Types,Variables and Operators with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Data Types,Variables and Operators, a crucial aspect of C# programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Data Types,Variables and Operators, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C# programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Data Types,Variables and Operators. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C# programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Data Types,Variables and Operators. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Data Types,Variables and Operators MCQs | Page 7 of 14

Q61.
Select the output choice for the following set of code:
 public static void Main(string[] args)
 {
     double ZERO = 0;
     Console.WriteLine("RESULT OF DIVISION BY ZERO IS :{0}",  (0 / ZERO));
     Console.ReadLine();
 }
Discuss
Answer: (c).NaN
Discuss
Answer: (c).No ease of doing it. C# don’t provides specifier like %x or %O to be used with ReadLine() OR WriteLine().We have to write our
Q63.
What is the Size of ‘Char’ datatype?
Discuss
Answer: (c).16 bit
Q64.
Choose the output for the following set of code.
static void Main(string[] args)
 {
     char c = 'g';
     string s = c.ToString();
     string s1 = "I am a human bein" + c;
     Console.WriteLine(s1);
     Console.ReadLine();
 }
Discuss
Answer: (b).I am a human being
Q65.
Given is the code of days(example:”MTWTFSS”) which i need to split and hence create a list of days of week in strings(example:”Monday”,”Tuesday”,”Wednesday”,”Thursday”,”Friday”,”Saturday”,”Sunday”). A set of code is given for this purpose but there is error ocuring in that set of code related to conversion of char to strings.Hence,Select a code to solve the given error.
static void Main(string[] args)
{
    var days = "MTWTFSS";
    var daysArray = days.ToCharArray().Cast<string>().ToArray();
    for (var i = 0; i < daysArray.Length; i++)
    {
        switch (daysArray[i])
        {
        case "M":
            daysArray[i] = "Monday";
            break;
        case "T":
            daysArray[i] = "Tuesday";
            break;
        case "W":
            daysArray[i] = "Wednesday";
            break;
        case "R":
            daysArray[i] = "Thursday";
            break;
        case "F":
            daysArray[i] = "Friday";
            break;
        case "S":
            daysArray[i] = "Saturday";
            break;
        case "U":
            daysArray[i] = "Sunday";
            break;
        }
    }
    daysArray[daysArray.Length - 1] = "and " + daysArray[daysArray.Length - 1];
    Console.WriteLine(string.Join(", ", daysArray));
}
Discuss
Answer: (c).var daysArray = days.ToCharArray().Select(c =>c.Tostring()).ToArray();
Q66.
Output for the following set of code is ?
static void Main(string[] args)
{
    { 
        var dayCode = "MTWFS";
        var daysArray = new List<string>();
        var list = new Dictionary<string, string>
        { {"M", "Monday"}, {"T", "Tuesday"}, {"W", "Wednesday"},
          {"R", "Thursday"}, {"F", "Friday"}, {"S", "Saturday"},
          {"U", "Sunday"}
        };
       for (int i = 0,max = dayCode.Length; i < max; i++)
       {
           var tmp = dayCode[i].ToString();
           if (list.ContainsKey(tmp))
           {
               daysArray.Add(list[tmp]);
            }
       }
       Console.WriteLine(string.Join("\n ", daysArray)); 
 }
Discuss
Answer: (c).Monday
Tuesday
Wednesday
Friday
Saturday
Q67.
Select the correct differences between char and varchar datatypes?

1. varchar is non unicode and char is unicode character datatype
2. char is ‘n’ bytes whereas varchar is actual length in bytes of data entered in terms of storage size
3. varchar is variable in length and char is the fixed length string
4. For varchar, if a string is less than the maximum length then it is stored in verbatim without any extra characters while for char if a string is less than the set length it is padded with extra characters to equalize its length to given length
Discuss
Answer: (d).3, 4
Q68.
Which is the String method used to compare two strings with each other ?
Discuss
Answer: (b).Compare()
Q69.
Correct output for the given C#.NET code is ?
static void Main(string[] args)
{
    string s1 = "Delhi";
    string s2;
    s2 = s1.Insert (6, "Jaipur");
    Console.WriteLine(s2);
}
Discuss
Answer: (d).DelhiJaipur
Q70.
For two strings s1 and s2 to be equal, which is the correct way to find if the contents of two strings are equal ?
Discuss
Answer: (b).int c;
c = s1.CompareTo(s2);

Suggested Topics

Are you eager to expand your knowledge beyond C# programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!