adplus-dvertising
frame-decoration

Question

Output from following set of 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();
      }
  }

a.

0 0

b.

10.5 0

c.

Compile time error

d.

10.5 5.5

Posted under C# programming

Answer: (d).10.5 5.5

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Output from following set of code ?

Similar Questions

Discover Related MCQs

Q. Select wrong statement about destructor in C#?

Q. Operator used to free the memory when memory is allocated ?

Q. Name 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.

Q. The method called by clients of a class to explicitly release any resources like network,connection,open files etc.When the object is no longer required?

Q. Which operator among the following signifies the destructor operator?

Q. Which method has the same name as that of its class?

Q. What is the return type of constructors?

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

Q. Can the method add() be overloaded in the following ways in C#?

public int add() { }
public float add(){ }

Q. Which among the following is the correct statement :
Constructors are used to

Q. Correct statement about constructors in C#.NET is ?

Q. Number of constructors a class can define is ?

Q. Which return statement correctly returns the output:

Q. How many values does a function return?

Q. When a function fun() is to receive an int, a single & a double and it is to return a decimal, then the correct way of defining this function is?

Q. Which of following statements are correct about functions?

Q. What is output for the following set of expression?

int a+= (float) b/= (long)c

Q. Select correct differences between ‘=’ and ‘==’ in C#.

Q. Select the wrong statement about ‘ref’ keyword in C#?

Q. Which refrence modifier is used to define reference variable?