logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Constructors See What Others Are Saying!
  • Question
  • Which of the following is the correct way to define the constructor(s) of the Sample class if we are to create objects as per the C#.NET code snippet given below?

    Sample s1 = new Sample(); 
    Sample s2 = new Sample(9, 5.6f);


  • Options
  • A.
    public Sample()
    {
        i = 0; 
        j = 0.0f;
    }
    public Sample (int ii, Single jj)
    {
        i = ii;
        j = jj;
    }
  • B.
    public Sample (Optional int ii = 0, Optional Single jj = 0.0f)
    {
        i = ii;
        j = jj;
    }
  • C.
    public Sample (int ii, Single jj)
    {
        i = ii;
        j = jj;
    }
  • D.
    Sample s;
  • E.
    s = new Sample();

  • Correct Answer
  • public Sample()
    {
        i = 0; 
        j = 0.0f;
    }
    public Sample (int ii, Single jj)
    {
        i = ii;
        j = jj;
    }
     


  • More questions

    • 1. Which of the following keyword is used to overload user-defined types by defining static member functions?

    • Options
    • A. op
    • B. opoverload
    • C. operator
    • D. operatoroverload
    • E. udoperator
    • Discuss
    • 2. Which of the following is the correct way of setting values into the structure variable e defined below?

      struct Emp
      {
          public String name;
          public int age;
          public Single sal; 
      }
      Emp e = new Emp();

    • Options
    • A.
      e.name = "Amol"; 
      e.age = 25; 
      e.sal = 5500;
    • B.
      With e
      {
          .name = "Amol";
          .age = 25;
          .sal = 5500; 
      }
    • C.
      With emp e
      {
          .name = "Amol";
          .age = 25;
          .sal = 5500; 
      }
    • D.
      e -> name = "Amol"; 
      e -> age = 25;
      e -> sal = 5500;
    • E.
      name = "Amol"; 
      age = 25;
      sal = 5500;
    • Discuss
    • 3. Which of the following should be used to implement a 'Has a' relationship between two entities?

    • Options
    • A. Polymorphism
    • B. Templates
    • C. Containership
    • D. Encapsulation
    • E. Inheritance
    • Discuss
    • 4. Which of the following statements are correct about the C#.NET code snippet given below?

      int[ , ] intMyArr = {{7, 1, 3}, {2, 9, 6}};
      1. intMyArr represents rectangular array of 2 rows and 3 columns.
      2. intMyArr.GetUpperBound(1) will yield 2.
      3. intMyArr.Length will yield 24.
      4. intMyArr represents 1-D array of 5 integers.
      5. intMyArr.GetUpperBound(0) will yield 2.

    • Options
    • A. 1, 2
    • B. 2, 3
    • C. 2, 5
    • D. 1, 4
    • E. 3, 4
    • Discuss
    • 5. Which of the following will be the correct output for the C#.NET program given below?

      namespace CuriousTabConsoleApplication
      { 
          class Sample
          { 
              int i; 
              Single j; 
              public void SetData(int i, Single j)
              { 
                  this.i = i; 
                  this.j = j;
              }
              public void Display()
              { 
                  Console.WriteLine(i + " " + j);
              } 
          } 
          class MyProgram
          { 
              static void Main(string[ ] args)
              {
                  Sample s1 = new Sample(); 
                  s1.SetData(36, 5.4f); 
                  s1.Display(); 
              } 
          } 
      }

    • Options
    • A. 0 0.0
    • B. 36 5.4
    • C. 36 5.400000
    • D. 36 5
    • E. None of the above
    • Discuss
    • 6. Which of the following is absolutely neccessary to use a class Point present in namespace Graph stored in library?

    • Options
    • A. Use fully qualified name of the Point class.
    • B. Use using statement before using the Point class.
    • C. Add Reference of the library before using the Point class.
    • D. Use using statement before using the Point class.
    • E. Copy the library into the current project directory before using the Point class.
    • Discuss
    • 7. Which of the following statements are correct about subroutines used in C#.NET?

      1. If we do not return a value from a subroutine then a value -1 gets returned.
      2. Subroutine definitions cannot be nested.
      3. Subroutine can be called recursively.
      4. To return the control from middle of a subroutine exit subroutine should be used.
      5. Subroutine calls can be nested.

    • Options
    • A. 1, 2, 3
    • B. 2, 3, 5
    • C. 3, 5
    • D. 3, 4
    • E. None of these
    • Discuss
    • 8. How many enumerators will exist if four threads are simultaneously working on an ArrayList object?

    • Options
    • A. 1
    • B. 3
    • C. 2
    • D. 4
    • E. Depends upon the Project Setting made in Visual Studio.NET.
    • Discuss
    • 9. Suppose on pushing a button an object is to be notified, but it is not known until runtime which object should be notified. Which of the following programming constructs should be used to implement this idea?

    • Options
    • A. Attribute
    • B. Delegate
    • C. Namespace
    • D. Interface
    • E. Encapsulation
    • Discuss
    • 10. When would a structure variable get destroyed?

    • Options
    • A. When no reference refers to it, it will get garbage collected.
    • B. Depends upon whether it is created using new or without using new.
    • C. When it goes out of scope.
    • D. Depends upon the Project Settings made in Visual Studio.NET.
    • E. Depends upon whether we free it's memory using free() or delete().
    • Discuss


    Comments

    There are no comments.

Enter a new Comment