Home / CSE MCQs / C#.Net MCQs :: C# Data Types, Variables and Operators

CSE MCQs :: C#.Net MCQs

  1. Predict the output for the given set of code correctly.

    static void Main(string[] args)
      {
          int b= 11;
          int c = 7;
          int r = 5;
          int e = 2;
          int l;
          int v = 109;
          int k;
          int z,t,p;
          z = b * c;
          t = b * b;
          p = b * r * 2;
          l = (b * c) + (r * e) + 10;
          k = v - 8;
          Console.WriteLine(Convert.ToString(Convert.ToChar(z)) + " " + Convert.ToString(Convert.ToChar(t)) + Convert.ToString(Convert.ToChar(p)) +   Convert.ToString(Convert.ToChar(l)) + Convert.ToString(Convert.ToChar(v)) + Convert.ToString(Convert.ToChar(k)));                
          Console.ReadLine();
      }
  2. A.
    My Name
    B.
    My nAme
    C.
    My name
    D.
    Myname

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Select the relevant code set to fill up the blank for the following program :

    static void Main(string[] args)
      {
          int x = 10, y = 20;
          int res;
          /*_______________*/ 
          Console.WriteLine(res);
      }
  4. A.
    x % y == 0 ? (x == y ? (x += 2):(y = x + y)):y = y*10;
    B.
    x % y == 0 ? y += 10:(x += 10);
    C.
    x % y == 0 ? return(x) : return (y);
    D.
    All of the mentioned.

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Which is the String method used to compare two strings with each other ?
  6. A.
    Compare To()
    B.
    Compare()
    C.
    Copy()
    D.
    ConCat()

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Minimum and Maximum range of values supported by 'float' data type are ?
  8. A.
    1.5 * 10 ^-40 to 3.4 * 10 ^38
    B.
    1.5 * 10 ^-45 to 3.4 * 10 ^30
    C.
    1.5 * 10 ^-45 to 3.4 * 10 ^38
    D.
    1.5 * 10 ^-45 to 3.4 * 10 ^37

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Which datatype should be more preferred for storing a simple number like 35 to improve execution speed of a program?
  10. A.
    sbyte
    B.
    short
    C.
    int
    D.
    long

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What will be output of the following conversion ?

    static void Main(string[] args)
     {
         char a = 'A';
         string b = "a";
         Console.WriteLine(Convert.ToInt32(a));
         Console.WriteLine(Convert.ToInt32(Convert.Tochar(b)));
         Console.ReadLine();
     }
  12. A.
    1, 97
    B.
    65, 97
    C.
    65, 97
    D.
    97, 1

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. Predict the output for the following set of code :

    static void Main(string[] args)
      {
          int a = 3, b = 5, c = 1;
          int z = ++b;
          int y = ++c;
          b = Convert.ToInt32((Convert.ToBoolean(z)) && (Convert.ToBoolean(y)) || Convert.ToBoolean(Convert.ToInt32(!(++a == b))));
          a = Convert.ToInt32(Convert.ToBoolean(c) || Convert.ToBoolean(a--));
          Console.WriteLine(++a);
          Console.WriteLine(++b);
          Console.WriteLine(c);
      }
  14. A.
    2 ,2 ,1
    B.
    2 ,3 ,2
    C.
    2 ,2 ,2
    D.
    2 ,0 ,9

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Scope of variable is related to definition of variable as:

    1. Region of code within which variable value is valid and hence can be accessed.
    2. No, relation with region where variable is declared its value is valid in entire scope.
  16. A.
    a
    B.
    b
    C.
    a, b
    D.
    None of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Type of Conversion in which compiler is unable to convert the datatype implicitly is ?
  18. A.
    ushort to long
    B.
    int to uint
    C.
    ushort to long
    D.
    byte to decimal

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. Select output of the given set of Code :

    static void Main(string[] args)
    {
        String name = "Dr.Gupta";
        Console.WriteLine("Good Morning" + name);
    }
  20. A.
    Dr.Gupta
    B.
    Good Morning
    C.
    Good Morning Dr.Gupta
    D.
    Good Morning name

    View Answer

    Workspace

    Discuss Discuss in Forum