logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Inheritance See What Others Are Saying!
  • Question
  • Which statement will you add in the function fun() of class B, if it is to produce the output "Welcome to CuriousTab.com!"?

    namespace CuriousTabConsoleApplication
    { 
        class A
        {
            public void fun()
            {
                Console.Write("Welcome");
            } 
        } 
        class B: A
        {
            public void fun()
            {
                // [*** Add statement here ***]
                Console.WriteLine(" to CuriousTab.com!");
            } 
        } 
        class MyProgram
        { 
            static void Main (string[ ] args)
            { 
                B b = new B(); 
                b.fun();
            } 
        } 
    }


  • Options
  • A. base.fun();
  • B. A::fun();
  • C. fun();
  • D. mybase.fun();
  • E. A.fun();

  • Correct Answer
  • base.fun(); 


  • More questions

    • 1. What is the size of a Decimal?

    • Options
    • A. 4 byte
    • B. 8 byte
    • C. 16 byte
    • D. 32 byte
    • Discuss
    • 2. Which of the following is the correct way to call subroutine MyFun() of the Sample class given below?

      class Sample
      {
          public void MyFun(int i, Single j)
          {
              Console.WriteLine("Welcome to CuriousTab !");
          }
      }

    • Options
    • A.
      delegate void del(int i);
      Sample s = new Sample();
      del d = new del(ref s.MyFun);
      d(10, 1.1f);
    • B.
      delegate void del(int i, Single j);
      del d;
      Sample s = new Sample();
      d = new del(ref s.MyFun);
      d(10, 1.1f);
    • C.
      Sample s = new Sample();
      delegate void d = new del(ref MyFun);
      d(10, 1.1f);
    • D.
      delegate void del(int i, Single]);
      Sample s = new Sample();
      del = new delegate(ref MyFun);
      del(10, 1.1f);
    • Discuss
    • 3. Suppose a Generic class called SortObjects is to be made capable of sorting objects of any type (Integer, Single, Byte etc.). Which of the following programming constructs should be used to implement the comparision function?

    • Options
    • A. Namespace
    • B. Interface
    • C. Encapsulation
    • D. Delegate
    • E. Attribute
    • Discuss
    • 4. What will be the output of the C#.NET code snippet given below?

      namespace CuriousTabConsoleApplication
      {
          class SampleProgram
          {
              static void Main(string[ ] args)
              {
                  object[] o = new object[] {"1", 4.0, "India", 'B'};
                  fun (o);
              }
              static void fun (params object[] obj)
              {
                  for (int i = 0; i < obj.Length-1; i++)
                  Console.Write(obj[i] + " ");
              }
          }
      }

    • Options
    • A. 1 4.0 India B
    • B. 1 4.0 India
    • C. 1 4 India
    • D. 1 India B
    • Discuss
    • 5. Which of the following is the correct way to obtain the number of elements present in the array given below?

          int[] intMyArr = {25, 30, 45, 15, 60};
      1. intMyArr.GetMax;
      2. intMyArr.Highest(0);
      3. intMyArr.GetUpperBound(0);
      4. intMyArr.Length;
      5. intMyArr.GetMaxElements(0);

    • Options
    • A. 1, 2
    • B. 3, 4
    • C. 3, 5
    • D. 1, 5
    • E. 4, 5
    • Discuss
    • 6. What will be the output of the C#.NET code snippet given below?

      namespace CuriousTabConsoleApplication
      {
          class SampleProgram
          {
              static void Main(string[ ] args)
              {
                  int i;
                  int res = fun(out i);
                  Console.WriteLine(res);
              }
              static int fun (out int i)
              {
                  int s = 1;
                  i = 7;
                  for(int j = 1; j <= i; j++)
                  {
                      s = s * j;
                  }
                  return s;
              } 
          } 
      }

    • Options
    • A. 1
    • B. 7
    • C. 8
    • D. 720
    • E. 5040
    • Discuss
    • 7. Which of the following statements is correct?

    • Options
    • A. Static methods can be a virtual method.
    • B. Abstract methods can be a virtual method.
    • C. It is necessary to override a virtual method.
    • D. When overriding a method, the names and type signatures of the override method must be the same as the virtual method that is being overriden.
    • E. We can override virtual as well as non-virtual methods.
    • Discuss
    • 8. In a HashTable Key cannot be null, but Value can be.

    • Options
    • A. True
    • B. False
    • Discuss
    • 9. An Employee class has a property called age and emp is reference to a Employee object and we want the statement Console.WriteLine(emp.age) to fail. Which of the following options will ensure this functionality?

    • Options
    • A. Declare age property with only get accessor.
    • B. Declare age property with only set accessor.
    • C. Declare age property with both get and set accessors.
    • D. Declare age property with get, set and normal accessors.
    • E. None of the above
    • Discuss
    • 10. Exceptions can be thrown even from a constructor, whereas error codes cannot be returned from a constructor.

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


    Comments

    There are no comments.

Enter a new Comment