Home / C# Programming / Constructors :: Discussion

Discussion :: Constructors

  1. 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);

     

  2. 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();

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    No answer description available for this question.


Be The First To Comment