gs gs108 Classes - Destructors 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 4: Which of the following statements are correct?
There is one garbage collector per program running in memory
There is one common garbage collector for all programs
To garbage collect an object set all references to it as null
Both There is one common garbage collector for all programs & To garbage collect an object set all references to it as null
Question 5: Operator used to free the memory when memory is allocated?
new
free
delete
none of the mentioned
Question 6: Select wrong statement about destructor in C#?
A class can have one destructor only
Destructors cannot be inherited or overloaded
Destructors can have modifiers or parameters
All of the mentioned
Question 8: What is the return type of destructor?
int
void
float
none of the mentioned
Question 9: What will be the output of the following C# code?
class box { public int volume; int width; int height; int length; public box ( int w, int h, int l) { width = w; height = h; length = l; } public ~box() { volume = width * length * height; } } class Program { static void Main(string[] args) { box b = new box(4, 5, 9); Console.WriteLine(b.volume); Console.ReadLine(); } }
0
180
Compile time error
None of the mentioned
Question 10: What will be the output of the following C# code?
class box { public int volume; int width; int height; int length; public box ( int w, int h, int l) { this.width = w; this.height = h; this.length = l; } ~ box() { volume = this.width * this.length * this.height; console.writeline(volume); } } class Program { public static void Main(string[] args) { box b = new box(4, 5, 9); Console.ReadLine(); } }
0
Code executes successfully but prints nothing
Compile time error
180