Constructors - General Questions Online Exam Quiz

Constructors - General Questions GK Quiz. Question and Answers related to Constructors - General Questions. MCQ (Multiple Choice Questions with answers about Constructors - General Questions

Which of the following statements is correct?

Options

A : A constructor can be used to set default values and limit instantiation.

B : C# provides a copy constructor.

C : Destructors are used with classes as well as structures.

D : A class can have more than one destructor.

View Answer

Which of the following statements is correct about the C#.NET code snippet given below?

Options

A : func() is a valid overloaded function.

B : Overloading works only in case of subroutines and not in case of functions.

C : func() cannot be considered overloaded because: return value cannot be used to distinguish between two overloaded functions.

D : The call to i = s1.func() will assign 1 to i .

View Answer

Which of the following ways to create an object of the Sample class given below will work correctly?

Options

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

View Answer

Which of the following statements are correct about static functions?

Options

A : 1, 2, 4

B : 2, 3, 5

C : 3, 4

D : 4, 5

View Answer

Which of the following statements is correct about constructors?

Options

A : If we provide a one-argument constructor then the compiler still provides a zero-argument constructor.

B : Static constructors can use optional arguments.

C : Overloaded constructors cannot use optional arguments.

D : If we do not provide a constructor, then the compiler provides a zero-argument constructor.

View Answer

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?

Options

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

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

C : public Sample ( int ii, Single jj) { i = ii; j = jj; }

D : Sample s;

View Answer

In which of the following should the methods of a class differ if they are to be treated as overloaded methods?

Options

A : 2, 4

B : 3, 5

C : 1, 3, 5

D : 3, 4, 5

View Answer

Can static procedures access instance data?

Options

A : Yes

B : No

C : -

D : -

View Answer

Which of the following statements are correct about constructors in C#.NET?

Options

A : 1, 3, 5

B : 2, 3, 4

C : 3, 5

D : 4, 5

View Answer

How many times can a constructor be called during lifetime of the object?

Options

A : As many times as we call it.

B : Only once.

C : Depends upon a Project Setting made in Visual Studio.NET.

D : Any number of times before the object gets garbage collected.

View Answer

Attributes - General Questions more Online Exam Quiz

Attributes - General Questions

Classes and Objects - General Questions

Collection Classes - General Questions

Datatypes - General Questions

Delegates - General Questions

.NET Framework - General Questions

Enumerations - General Questions

Exception Handling - General Questions