logo

CuriousTab

CuriousTab

Discussion


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

    struct Book
    {
        private String name; 
        protected int totalpages; 
        public Single price; 
        public void Showdata()
        {
            Console.WriteLine(name + " " + totalpages + " " + price);
        } 
        Book()
        {
            name = " "; 
            totalpages = 0;
            price = 0.0f; 
        } 
    } 
    Book b = new Book();
    1. We cannot declare the access modifier of totalpages as protected.
    2. We cannot declare the access modifier of name as private.
    3. We cannot define a zero-argument constructor inside a structure.
    4. We cannot declare the access modifier of price as public.
    5. We can define a Showdata() method inside a structure.


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

  • Correct Answer
  • 1, 3, 5 


  • More questions

    • 1. What will be the size of the object created by the following C#.NET code snippet?

      namespace CuriousTabConsoleApplication
      { 
          class Baseclass
          {
              private int i; 
              protected int j; 
              public int k;
          }
          class Derived: Baseclass
          {
              private int x; 
              protected int y; 
              public int z;
          }
          class MyProgram
          { 
              static void Main (string[ ] args)
              { 
                  Derived d = new Derived();
              } 
          } 
      }

    • Options
    • A. 24 bytes
    • B. 12 bytes
    • C. 20 bytes
    • D. 10 bytes
    • E. 16 bytes
    • Discuss
    • 2. Which of the following is the correct way to find out the number of elements currently present in an ArrayList Collection called arr?

    • Options
    • A. arr.Count
    • B. arr.GrowSize
    • C. arr.MaxIndex
    • D. arr.Capacity
    • E. arr.UpperBound
    • Discuss
    • 3. Which of the following statements is correct about the C#.NET code snippet given below?

      enum per
      {
          married, 
          unmarried, 
          divorced, 
          spinster
      }
      per.married = 10; 
      Console.WriteLine(per.unmarried);

    • Options
    • A. The program will output a value 11.
    • B. The program will output a value 1.
    • C. The program will output a value 2.
    • D. The program will report an error since an enum element cannot be assigned a value outside the enum declaration.
    • E. The enum elements must be declared private.
    • Discuss
    • 4. A function can be used in an expression, whereas a subroutine cannot be.

    • Options
    • A. True
    • B. False
    • Discuss
    • 5. Which of the following statements are correct about static functions?

      1. Static functions can access only static data.
      2. Static functions cannot call instance functions.
      3. It is necessary to initialize static data.
      4. Instance functions can call static functions and access static data.
      5. this reference is passed to static functions.

    • Options
    • A. 1, 2, 4
    • B. 2, 3, 5
    • C. 3, 4
    • D. 4, 5
    • E. None of these
    • Discuss
    • 6. Which of the following security features can .NET applications avail?

      1. PIN Security
      2. Code Access Security
      3. Role Based Security
      4. Authentication Security
      5. Biorhythm Security

    • Options
    • A. 1, 4, 5
    • B. 2, 5
    • C. 2, 3
    • D. 3, 4
    • Discuss
    • 7. Which of the following is an ordered collection class?

      1. Map
      2. Stack
      3. Queue
      4. BitArray
      5. HashTable

    • Options
    • A. 1 only
    • B. 2 and 3 only
    • C. 4 and 5 only
    • D. All of the above
    • E. None of the above
    • Discuss
    • 8. Which of the following components of the .NET framework provide an extensible set of classes that can be used by any .NET compliant programming language?

    • Options
    • A. .NET class libraries
    • B. Common Language Runtime
    • C. Common Language Infrastructure
    • D. Component Object Model
    • E. Common Type System
    • Discuss
    • 9. What will be the output of the C#.NET code snippet given below?

      int i = 2, j = i;
      if (Convert.ToBoolean((i | j & 5) & (j - 25 * 1)))
          Console.WriteLine(1); 
      else
          Console.WriteLine(0);

    • Options
    • A. 0
    • B. 1
    • C. Compile Error
    • D. Run time Error
    • Discuss
    • 10. The string built using the String class are immutable (unchangeable), whereas, the ones built- using the StringBuilder class are mutable.

    • Options
    • A. True
    • B. False
    • Discuss


    Comments

    There are no comments.

Enter a new Comment