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 8 of 14

Q71.
Select the output for given string ?
Enter a String:BOMBAY.
static void Main(string[] args)
{
    string Str,  Revstr = " "; 
    int Length;
    Console.Write("Enter A String : ");
    Str = Console.ReadLine();
    Length = Str.Length - 1;
    while (Length >= 0)
    {
        Revstr = Revstr + Str[Length];
        Length --;
    }
    Console.WriteLine("Reverse  String  Is  {0}",  Revstr);
    Console.ReadLine();
}
Discuss
Answer: (b).YABMOB
Q72.
Select the appropriate set of code for conversion of string to hexa form.
static void Main(string[] args)
 {
     string teststring = "MIKA@?&";
     string hex = ConvertstringToHex(teststring, system.Text.Encoding.Unicode);
     Console.WriteLine(hex);
 }


a)

static string ConvertstringToHex(string input, system.Text.Encoding encoding)
{
    string Bytes = encoding.GetBytes(input);
    string Builder sbBytes = new Builder sbBytes();
    for each (byte 'b' in StringBytes)
    {
        sBytes.AppendFormat("{0:x2}", b);
    }
    return sbBytes.Tostring();
}

b)

static string ConvertstringToHex(string input, system.Text.Encoding encoding)
{
    char[]string Bytes = encoding.GetBytes(input);
    string Builder sbBytes = new Builder sbBytes(StringBytes.Length*2);
    for each (byte 'b' in StringBytes)
    {
        sBytes.AppendFormat("{0:X2}", b);
    }
    return sbBytes.Tostring();
}

c)

public static string ConvertStringToHex(String input,  System.Text.Encoding encoding)
{
    {
       Byte[] stringBytes = encoding.GetBytes(input);
       StringBuilder sbBytes = new StringBuilder(stringBytes.Length * 2);
       foreach (byte b in stringBytes)
       {
           sbBytes.AppendFormat("{0:X2}",  b);
       }
   Console.WriteLine(sbBytes.ToString());//sbBytes.ToString());
   return sbBytes.ToString();
    }
}
Discuss
Answer: (c).c
Q73.
Which of the following code is used for conversion of hex to string form ?
static void Main(string[] args)
{
    string testString = "MIKA@?&^";
    string normal = ConvertHexToString (hex,  System.Text.Encoding.Unicode);
    Console.WriteLine(normal);
    Console.ReadLine();
}


a)

public static string ConvertHexToString(String hexInput,  System.Text.Encoding encoding)
{
    char[] numberChars = hexInput.Length;
    byte[] bytes = new byte[numberChars / 2];
    for (int i = 0; i < numberChars; i += 2)
    {
        bytes[i / 2] = Convert.ToByte(hexInput.Substring(i,  0),  16);
    }
    return encoding.GetString(bytes);
}

b)

public static string ConvertHexToString(String hexInput,  System.Text.Encoding encoding)
{
    int numberChars = hexInput.Length;
    byte[] bytes = new byte[numberChars / 2];
    for (int i = 0; i < numberChars; i += 2)
    {
        bytes[i / 2] = Convert.ToByte(hexInput.Substring(i,  2),  16);
    }
    return encoding.GetString(bytes);
}

c)

public static string ConvertHexToString(String hexInput,  System.Text.Encoding encoding)
{
    string numberChars = hexInput.Length;
    byte[] bytes = new byte[numberChars];
    for (int i = 0; i &lt; numberChars; i += 2)
    {
        bytes[i / 2] = Convert.ToByte(hexInput.Substring(i,  2),  16);
    }
    return encoding.GetString(bytes);
}
Discuss
Answer: (b).b
Q74.
Correct output for the C#.NET code given below is :
string s1 = " I AM BEST ";
   string s2;
   s2 = s1.substring (5, 4);
   Console.WriteLine (s2);
Discuss
Answer: (c).BEST
Discuss
Answer: (c).a string created on heap
Discuss
Answer: (d).All of the mentioned
Discuss
Answer: (b).To reduce size of string
Q78.
Select output for the following set of code.
static void Main(string[] args)
 {
     int a = 5;
     int b = 10;
     int c;
     Console.WriteLine(c = ++ a + b ++);
     Console.WriteLine(b);
     Console.ReadLine();
 }
Discuss
Answer: (c).16, 11
Q79.
Storage location used by computer memory to store data for usage by an application is ?
Discuss
Answer: (c).Variable
Discuss
Answer: (d).All of the mentioned

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!