What will be the output of the following C# code? class box { ...
View Question
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();
}
}
What will be the output of the following C# code? class box ...
View QuestionWhat is the return type of destructor?
a) int b) void c) float d) none of the mentioned Answer: d Explanation: Destructors do not ...
View Question
What will be the output of the following C# code?
class sample
{
int i;
double k;
public sample (int ii, double kk)
{
i = ii;
k = kk;
double j = (i) + (k);
Console.WriteLine(j);
}
~sample()
{
double j = i – k;
Console.WriteLine(j);
}
}
class Program
{
static void Main(string[] args)
{
sample s = new sample(8, 2.5);
Console.ReadLine();
}
}
What will be the output of the following C# code? class sample { ...
View QuestionSelect wrong statement about destructor in C#?
a) A class can have one destructor only b) Destructors cannot be inherited or overloaded c) Destructors can ...
View QuestionOperator used to free the memory when memory is allocated?
a) new b) free c) delete d) none of the mentioned Answer: c Explanation: ‘New’ is used ...
View QuestionWhich of the following statements are correct?
a) There is one garbage collector per program running in memory b) There is one common garbage collector ...
View QuestionName a method which has the same name as that of class and which is used to destroy objects also called automatically when application is finally on process of being getting terminated.
a) Constructor b) Finalize() c) Destructor d) End Answer: c Explanation: Destructor
View QuestionWhich operator among the following signifies the destructor operator?
a) :: b) : c) ~ d) & Answer: c Explanation: ~ operator
View Question
What will be the output of the following C# code?
public static void Main(string[] args)
{
p();
void p()
{
Console.WriteLine(“hi”);
}
}
What will be the output of the following C# code? public static void Main(string[] args) {
View Question