logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Structures See What Others Are Saying!
  • Question
  • Which of the following statements are correct?

    1. A struct can contain properties.
    2. A struct can contain constructors.
    3. A struct can contain protected data members.
    4. A struct cannot contain methods.
    5. A struct cannot contain constants.


  • Options
  • A. 1, 2
  • B. 3, 4
  • C. 1, 2, 4
  • D. 3, 5

  • Correct Answer
  • 1, 2 


  • More questions

    • 1. Suppose value of the Capacity property of ArrayList Collection is set to 4. What will be the capacity of the Collection on adding fifth element to it?

    • Options
    • A. 4
    • B. 8
    • C. 16
    • D. 32
    • Discuss
    • 2. Which of the following is the correct output for the C#.NET code snippet given below?

      Console.WriteLine(13 / 2 + " " + 13 % 2); 

    • Options
    • A. 6.5 1
    • B. 6.5 0
    • C. 6 0
    • D. 6 1
    • E. 6.5 6.5
    • Discuss
    • 3. Which of the following statements are correct about the C#.NET code snippet given below?

         int[][]intMyArr = new int[2][]; 
         intMyArr[0] = new int[4]{6, 1, 4, 3}; 
         intMyArr[1] = new int[3]{9, 2, 7};

    • Options
    • A. intMyArr is a reference to a 2-D jagged array.
    • B. The two rows of the jagged array intMyArr are stored in adjacent memory locations.
    • C. intMyArr[0] refers to the zeroth 1-D array and intMyArr[1] refers to the first 1-D array.
    • D. intMyArr refers to intMyArr[0] and intMyArr[1].
    • E. intMyArr refers to intMyArr[1] and intMyArr[2].
    • Discuss
    • 4. Which of the following is an 8-byte Integer?

    • Options
    • A. Char
    • B. Long
    • C. Short
    • D. Byte
    • E. Integer
    • Discuss
    • 5. Which of the following statements is valid about generic procedures in C#.NET?

    • Options
    • A. All procedures in a Generic class are generic.
    • B. Only those procedures labeled as Generic are generic.
    • C. Generic procedures can take at the most one generic parameter.
    • D. Generic procedures must take at least one type parameter.
    • E. None of the above.
    • Discuss
    • 6. The size of a derived class object is equal to the sum of sizes of data members in base class and the derived class.

    • Options
    • A. True
    • B. False
    • Discuss
    • 7. 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
    • Discuss
    • 8. Which of the following statements is correct about namespaces in C#.NET?

    • Options
    • A. Namespaces can be nested only up to level 5.
    • B. A namespace cannot be nested.
    • C. There is no limit on the number of levels while nesting namespaces.
    • D. If namespaces are nested, then it is necessary to use using statement while using the elements of the inner namespace.
    • E. Nesting of namespaces is permitted, provided all the inner namespaces are declared in the same file.
    • Discuss
    • 9. If Sample class has a Length property with get and set accessors then which of the following statements will work correctly?

      1. Sample.Length = 20;
      2. Sample m = new Sample(); 
        m.Length = 10;
      3. Console.WriteLine(Sample.Length);
      4. Sample m = new Sample(); 
        int len;
        len = m.Length;
      5. Sample m = new Sample(); 
        m.Length = m.Length + 20;

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

      1. try blocks cannot be nested.
      2. In one function, there can be only one try block.
      3. An exception must be caught in the same function in which it is thrown.
      4. All values set up in the exception object are available in the catch block.
      5. While throwing a user-defined exception multiple values can be set in the exception, object.

    • Options
    • A. 1 only
    • B. 1 and 2 only
    • C. 3 only
    • D. 4 and 5 only
    • E. All of the above
    • Discuss


    Comments

    There are no comments.

Enter a new Comment