Commerce

Classes And Objects In C Sharp MCQs

Practice Classes And Objects In C Sharp MCQs for competitive exams.

Classes And Objects In C Sharp MCQs

Practice questions from this topic.

Selecting appropriate method out of number of overloaded methods by matching arguments in terms of number, type and order and binding that selected method to object at compile time is called?

  1. A. Static binding
  2. B. Static Linking
  3. C. Compile time polymorphism
  4. D. All of the mentioned
Report Error

Choose the wrong statement about 'INTERFACE' in C#.NET?

  1. A. An explicitly implemented member could be accessed from an instance of the interface
  2. B. Interfaces are declared public automatically
  3. C. An interface could not contain signature of the indexer
  4. D. None of the mentioned
Report Error

Which of the following keyword is used to change data and behavior of a base class by replacing a member of the base class with a new derived member?

  1. A. Overloads
  2. B. Overrides
  3. C. new
  4. D. base
Report Error

Which of the given modifiers can be used to prevent Method overriding?

  1. A. Static
  2. B. Constant
  3. C. Sealed
  4. D. final
Report Error

What will be the output of the following C# code? class A { public int i; private int j; } class B :A { void display() { base.j = base.i + 1; Console.WriteLine(base.i + " " + base.j); } } class Program { static void Main(string[] args) { B obj = new B(); obj.i = 1; obj.j = 2; obj.display(); Console.ReadLine(); } }

  1. A. 1, 3
  2. B. 2, 3
  3. C. 1, 2
  4. D. compile time error
Report Error

What will be the output of the following C# code snippet? class maths { public int fact(int n) { int result; result = fact(n - 1) * n; return result; } } class Program { static void Main(string[] args) { maths obj = new maths(); Console.WriteLine(obj.fact(4)); Console.ReadLine(); } }

  1. A. 24
  2. B. 30
  3. C. Compile time error
  4. D. Runtime Error
Report Error

What will be the output of the following C# code? { struct abc { int i; } class Program { static void Main(string[] args) { abc x = new abc(); abc z; x.i = 10; z = x; z.i = 15; console.Writeline(x.i + " " + y.i) } } }

  1. A. 10 10
  2. B. 10 15
  3. C. 15 10
  4. D. 15 15
Report Error

Choose the correct statement about enum used in C#.NET?

  1. A. By default the first enumerator has a value equal to the number of elements present in the list
  2. B. Values of the enum elements cannot be populated from database
  3. C. The value of each successive enumerator is decreased by 1
  4. D. An enumerator has a white space in its name
Report Error

What will be the correct statement of the following C# code? enum color:byte { yellow = 500, green = 1000, pink = 1300 }

  1. A. byte value cannot be assigned to enum elements
  2. B. enum elements should always take successive values
  3. C. enum must always be of int type
  4. D. When the valid range of byte exceeds, the compiler will report an error
Report Error

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

  1. A. initialize the objects
  2. B. construct the data members
  3. C. initialize the objects & construct the data members
  4. D. none of the mentioned
Report Error

What will be the output of the following C# code? static void Main(string[] args) { Mul(); m(); Console.ReadLine(); } static void Mul() { Console.WriteLine("4"); } static void m() { Console.WriteLine("3"); Mul(); }

  1. A. 4 3 3
  2. B. 4 4 3
  3. C. 4 3 4
  4. D. 3 4 4
Report Error

What will be the output of the following C# code snippet? class maths { int fact(int n) { int result; if (n == 1) return 1; result = fact(n - 1) * n; return result; } } class Output { static void main(String args[]) { maths obj = new maths() ; Console.WriteLine(obj.fact(4)*obj.fact(2)); } }

  1. A. 64
  2. B. 60
  3. C. 120
  4. D. 48
Report Error