Constructors

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

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

ANS:D - Sample s3 = new Sample(10, 1.2f, 2.4);

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.