MCQs
Total Questions : 10
Answer: Option D. -> Encapsulation
Answer: Option A. -> References can be called recursively
Answer: Option C. -> 1
a method can return only either single value or no value if no then it's declared as void method();
Answer: Option B. -> '=' operator is used to assign values from one variable to another variable
'==' operator is used to compare value between two variables
Answer: Option C. -> 10
35.78
'int' datatype is sub datatype of 'double'.Hence, when first part of func() is executed it is integer part and hence when second part is executed it is double.
Output:10
35.78
Answer: Option B. -> False
C# provides feature of method overloading which means methods with same name but different types and arguments.
Question 7. 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(); } }
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(); } }
Answer: Option D. -> 10.5 5.5
First constructor 'sample' is called and hence then destructor '~sample' is evaluated.
Output : 10.5, 5.5
Answer: Option C. -> Destructors can have modifiers or parameters
Answer: Option C. -> A constructor can be a static constructor
Static constructor is a constructor which can be called before any object of class is created or any static method is invoked.Static constructor is implicitly called by .net CLR.
Answer: Option D. -> All of the mentioned