logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Operators See What Others Are Saying!
  • Question
  • Suppose n is a variable of the type Byte and we wish to put OFF its fourth bit (from right) without disturbing any other bits. Which of the following statements will do this correctly?


  • Options
  • A. n = n && HF7
  • B. n = n & 16
  • C. n = n & 0xF7
  • D. n = n & HexF7
  • E. n = n & 8

  • Correct Answer
  • n = n & 0xF7 


  • More questions

    • 1. If a base class and a derived class each include a member function with the same name, the member function of the derived class will be called by an object of the derived class

    • Options
    • A. True
    • B. False
    • Discuss
    • 2. Which of the following statements are valid about generics in .NET Framework?

      1. Generics is a language feature.
      2. We can create a generic class, however, we cannot create a generic interface in C#.NET.
      3. Generics delegates are not allowed in C#.NET.
      4. Generics are useful in collection classes in .NET framework.
      5. None of the above

    • Options
    • A. 1 and 2 Only
    • B. 1, 2 and 3 Only
    • C. 1 and 4 Only
    • D. All of the above
    • E. None of the above
    • Discuss
    • 3. What will be the output of the C#.NET code snippet given below?

      namespace CuriousTabConsoleApplication
      {
          class SampleProgram
          {
              static void Main(string[ ] args)
              {
                  int i = 5;
                  int j;
                  fun1(ref i);
                  fun2(out j);
                  Console.WriteLine(i + ", " + j);
              }
              static void funl(ref int x)
              {
                  x = x * x;
              }
              static void fun2(out int x)
              {
                  x = 6; 
                  x = x * x; 
              }
          }
      }

    • Options
    • A. 5, 6
    • B. 5, 36
    • C. 25, 36
    • D. 25, 0
    • E. 5, 0
    • Discuss
    • 4. Which of the following statements is correct about Interfaces used in C#.NET?

    • Options
    • A. All interfaces are derived from an Object class.
    • B. Interfaces can be inherited.
    • C. All interfaces are derived from an Object interface.
    • D. Interfaces can contain only method declaration.
    • E. Interfaces can contain static data and methods.
    • Discuss
    • 5. Which of the following statements is valid about advantages of generics?

    • Options
    • A. Generics shift the burden of type safety to the programmer rather than compiler.
    • B. Generics require use of explicit type casting.
    • C. Generics provide type safety without the overhead of multiple implementations.
    • D. Generics eliminate the possibility of run-time errors.
    • E. None of the above.
    • Discuss
    • 6. Which of the following is the correct way to implement a read only property Length in a Sample class?

    • Options
    • A.
      class Sample
      {
          int len;
          public int Length
          {
              get
              {
                  return len;
              } 
          } 
      }
    • B.
      class Sample
      {
          public int Length
          {
              get
              {
                  return Length;
              } 
          } 
      }
    • C.
      class Sample
      {
          int len;
          public int Length
          {
              get
              {
                  return len;
              } 
              set
              {
                  len = value;
              } 
          } 
      }
    • D.
      class Sample
      {
          int len;
          public int Length
          {
              Readonly get
              {
                  return len;
              } 
          } 
      }
    • Discuss
    • 7. Which of the following are necessary for Run-time Polymorphism?

      1. The overridden base method must be virtual, abstract or override.
      2. Both the override method and the virtual method must have the same access level modifier.
      3. An override declaration can change the accessibility of the virtual method.
      4. An abstract inherited property cannot be overridden in a derived class.
      5. An abstract method is implicitly a virtual method.

    • Options
    • A. 1, 3
    • B. 1, 2, 5
    • C. 2, 3, 4
    • D. 4 only
    • Discuss
    • 8. If s1 and s2 are references to two strings then which of the following are the correct ways to find whether the contents of the two strings are equal?

      1. if(s1 = s2)
      2. if(s1 == s2)
      3. int c;
        c = s1.CompareTo(s2);
      4. if( strcmp(s1, s2) )
      5. if (s1 is s2)

    • Options
    • A. 1, 2
    • B. 2, 3
    • C. 4, 5
    • D. 3, 5
    • Discuss
    • 9. Which of the following statements are correct about exception handling in C#.NET?

      1. If our program does not catch an exception then the .NET CLR catches it.
      2. It is possible to create user-defined exceptions.
      3. All types of exceptions can be caught using the Exception class.
      4. CLRExceptions is the base class for all exception classes.
      5. For every try block there must be a corresponding finally block.

    • Options
    • A. 1 and 2 only
    • B. 1, 2 and 3 only
    • C. 4 and 5 only
    • D. All of the above
    • E. None of the above
    • Discuss
    • 10. Which of the following statements is correct about the C#.NET code snippet given below?

          int[] intMyArr = {11, 3, 5, 9, 4}; 

    • Options
    • A. intMyArr is a reference to an object of System.Array Class.
    • B. intMyArr is a reference to an object of a class that the compiler derives from System.Array Class.
    • C. intMyArr is a reference to an array of integers.
    • D. intMyArr is a reference to an object created on the stack.
    • E. intMyArr is a reference to the array created on the stack.
    • Discuss


    Comments

    There are no comments.

Enter a new Comment