Constructors

Q1: 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);

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

ANS:A -

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

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.