logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Inheritance See What Others Are Saying!
  • Question
  • Which of the following statements are correct about the C#.NET code snippet given below?

    namespace CuriousTabConsoleApplication
    { 
        class index
        {
            protected int count;
            public index()
            {
                count = 0;
            }
        }
        class index1: index
        {
            public void increment()
            {
                count = count +1;
            }
        }
        class MyProgram
        {
            static void Main(string[] args)
            {
                index1 i = new index1(); 
                i.increment(); 
            }
        }
    }
    1. count should be declared as public if it is to become available in the inheritance chain.
    2. count should be declared as protected if it is to become available in the inheritance chain.
    3. While constructing an object referred to by i firstly constructor of index class will be called followed by constructor of index1 class.
    4. Constructor of index class does not get inherited in index1 class.
    5. count should be declared as Friend if it is to become available in the inheritance chain.


  • Options
  • A. 1, 2, 5
  • B. 2, 3, 4
  • C. 3, 5
  • D. 4, 5
  • E. None of these

  • Correct Answer
  • 2, 3, 4 


  • More questions

    • 1. Which of the following is NOT an Assignment operator in C#.NET?

    • Options
    • A. \=
    • B. /=
    • C. *=
    • D. +=
    • E. %=
    • Discuss
    • 2. How many values is a function capable of returning?

    • Options
    • A. 1
    • B. 0
    • C. Depends upon how many params arguments does it use.
    • D. Any number of values.
    • E. Depends upon how many ref arguments does it use.
    • Discuss
    • 3. Creating empty structures is allowed in C#.NET.

    • Options
    • A. True
    • B. False
    • Discuss
    • 4. It is illegal to make objects of one class as members of another class.

    • Options
    • A. True
    • B. False
    • Discuss
    • 5. All code inside finally block is guaranteed to execute irrespective of whether an exception occurs in the protected block or not.

    • Options
    • A. True
    • B. False
    • Discuss
    • 6. Which of the following ways to create an object of the Sample class given below will work correctly?

      class Sample
      {
          int i;
          Single j;
          double k;
          public Sample (int ii, Single jj, double kk)
          {
              i = ii;
              j = jj;
              k = kk;
          } 
      }

    • Options
    • A. Sample s1 = new Sample();
    • B. Sample s1 = new Sample(10);
    • C. Sample s2 = new Sample(10, 1.2f);
    • D. Sample s3 = new Sample(10, 1.2f, 2.4);
    • E. Sample s1 = new Sample(, , 2.5);
    • Discuss
    • 7. Which of the following will be the correct output for the C#.NET program given below?

      namespace CuriousTabConsoleApplication
      { 
          class SampleProgram
          {
              static void Main(string[] args)
              { 
                  int num = 1;
                  funcv(num); 
                  Console.Write(num + ", "); 
                  funcr(ref num); 
                  Console.Write(num + ", ");
              }
              static void funcv(int num)
              { 
                  num = num + 10; Console.Write(num + ", ");
              }
              static void funcr (ref int num)
              { 
                  num = num + 10; Console.Write(num + ", ");
              } 
          } 
      }

    • Options
    • A. 1, 1, 1, 1,
    • B. 11, 1, 11, 11,
    • C. 11, 11, 11, 11,
    • D. 11, 11, 21, 11,
    • E. 11, 11, 21, 21,
    • Discuss
    • 8. Which of the following operators cannot be overloaded?

      1. true
      2. false
      3. new
      4. ~
      5. sizeof

    • Options
    • A. 1, 3
    • B. 2, 4
    • C. 3, 5
    • D. All of the above
    • Discuss
    • 9. Which of the following is the correct output for the C#.NET program given below?

      int i = 20 ;
      for( ; ; )
      {
          Console.Write(i + " "); 
          if (i >= -10)
              i -= 4; 
          else 
              break;
      }

    • Options
    • A. 20 16 12 84 0 -4 -8
    • B. 20 16 12 8 4 0
    • C. 20 16 12 8 4 0 -4 -8 -12
    • D. 16 12 8 4 0
    • E. 16 8 0 -8
    • Discuss
    • 10. In an inheritance chain which of the following members of base class are accessible to the derived class members?

      1. static
      2. protected
      3. private
      4. shared
      5. public

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


    Comments

    There are no comments.

Enter a new Comment