Sail E0 Webinar

MCQs

Total Questions : 10
Question 1. "A mechanism that binds together code and data in manipulates, and keeps both safe from outside interference and misuse.In short it isolates a particular code and data from all other codes and data. A well-defined interface controls the access to that particular code and data.
  1.    Abstraction
  2.    Polymorphism
  3.    Inheritance
  4.    Encapsulation
 Discuss Question
Answer: Option D. -> Encapsulation




Question 2. Select the wrong statement about 'ref' keyword in C#?
  1.    References can be called recursively
  2.    The 'ref' keyword causes arguments to be passed by reference
  3.    When 'ref' are used, any changes made to parameters in method will be reflected in variable when control is passed back to calling method
  4.    All of above mentioned
 Discuss Question
Answer: Option A. -> References can be called recursively




Question 3. How many values does a function return?
  1.    0
  2.    2
  3.    1
  4.    any number of values
 Discuss Question
Answer: Option C. -> 1


a method can return only either single value or no value if no then it's declared as void method();


Question 4. Select correct differences between '=' and '==' in C#.
  1.    '==' operator is used to assign values from one variable to another variable '=' operator is used to compare value between two variables
  2.    '=' operator is used to assign values from one variable to another variable '==' operator is used to compare value between two variables
  3.    No difference between both operators
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> '=' operator is used to assign values from one variable to another variable '==' operator is used to compare value between two variables




Question 5. What is the output for the following set of code :
static void Main(string[] args) {     int i = 10;     double d = 35.78;     fun(i);     fun(d);     Console.ReadLine(); } static void fun(double d) {     Console.WriteLine(d); }
  1.    35.78 10
  2.    10 35.00
  3.    10 35.78
  4.    None of the mentioned
 Discuss Question
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


Question 6. Can the method add() be overloaded in the following ways in C#?public int add() { }public float add(){ }
  1.    True
  2.    False
  3.    None of the mentioned.
  4.    None of the Above
 Discuss Question
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();      }  }
  1.    0 0
  2.    10.5 0
  3.    Compile time error
  4.    10.5 5.5
 Discuss Question
Answer: Option D. -> 10.5 5.5


First constructor 'sample' is called and hence then destructor '~sample' is evaluated.
Output : 10.5, 5.5


Question 8. Select wrong statement about destructor in C#?
  1.    A class can have one destructor only
  2.    Destructors cannot be inherited or overloaded
  3.    Destructors can have modifiers or parameters
  4.    All of above mentioned
 Discuss Question
Answer: Option C. -> Destructors can have modifiers or parameters




Question 9. Which of the following statements is correct about constructors in C#.NET?
  1.    A constructor cannot be declared as private
  2.    A constructor cannot be overloaded
  3.    A constructor can be a static constructor
  4.    None of the mentioned
 Discuss Question
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.


Question 10. Which of following statements about objects in "C# is correct?
  1.    Everything you use in C# is an object, including Windows Forms and controls
  2.    Objects have methods and events that allow them to perform actions
  3.    All objects created from a class will occupy equal number of bytes in memory
  4.    All of the mentioned
 Discuss Question
Answer: Option D. -> All of the mentioned




Latest Videos

Latest Test Papers