gs gs108 Classes - Constructors in Class - Quiz No.1
gs gs108 CSharp Quiz
This quiz belongs to book/course code gs gs108 CSharp of gs organization. We have 110 quizzes available related to the book/course CSharp. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Classes. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
Question 1: Number of constructors a class can define is?
1
2
Any number
None of the mentioned
Question 2: The correct way of defining constructor of the given class as and when objects of classes are created is:
maths s1 = new maths(); maths s2 = new maths(5, 5.4f);
public maths(int pp, single tt) { p = pp; t = tt; }
sample s;
public sample() { p = 0; t = 0.0f; } public sample(int pp, single tt) { p = pp; t = tt; }
s = new sample();
Question 3: Correct way to define object of sample class in which C# code will work correctly is:
class abc { int i; float k; public abc(int ii, float kk) { i = ii; k = kk; } }
abc s1 = new abc(1);
abc s1 = new abc();
abc s2 = new abc(1.4f);
abc s2 = new abc(1, 1.4f);
Question 4: Correct statement about constructors in C#.NET is?
Constructors can be overloaded
Constructors are never called explicitly
Constructors have same name as name of the class
All of the mentioned
Question 5: Which among the following is the correct statement: Constructors are used to?
initialize the objects
construct the data members
initialize the objects & construct the data members
none of the mentioned
Question 7: Which of the following statements is correct about constructors in C#.NET?
A constructor cannot be declared as private
A constructor cannot be overloaded
A constructor can be a static constructor
None of the mentioned
Question 8: What will be the output of the following C# code?
class abc { public static void a() { console.writeline("first method"); } public void b() { a(); console.writeline("second method"); } public void b(int i) { console.writeline(i); b(); } } class program { static void main() { abc k = new abc(); abc.a(); k.b(20); } }
second method 20 second method first method
first method 20 first method second method
first method 20
second method 20 first method
Question 9: What is the return type of constructors?
int
float
void
none of the mentioned
Question 10: Which method has the same name as that of its class?
delete
class
constructor
none of the mentioned