OOP with C#

A visually engaging design featuring a computer programming interface with coding elements and C# symbols, conveying themes of learning and mastery in object-oriented programming.

Mastering OOP with C# Quiz

Test your knowledge and skills in Object-Oriented Programming with our comprehensive C# quiz! Designed for programmers of all levels, this quiz features a variety of questions covering key OOP concepts.

  • Multiple-choice questions
  • Abstract classes and interfaces
  • Method overloading and overriding
  • Polymorphism and encapsulation
16 Questions4 MinutesCreated by CodingWizard341
Name:
Which keyword is used to refer baseclass constructor to subclass constructor?
This
Static
Base
What will be the output for the given set of code?
namespace ConsoleApplication4 {
abstract class A {
public int I;
public abstract void display();
}
class B: A
{ public int j;
public int sum;
public override void display()
{ sum = I + j;
Console.WriteLine(+i + "\n" + +j);
Console.WriteLine("sum is:" +sum); }
}
class Program
{ static void Main(string[] args)
{ A obj = new B();
obj.i = 2;
B obj1 = new B();
obj1.j = 10;
obj.display();
Console.ReadLine(); } } }
2, 10 12
2, 0 2
0, 10 10
0,0 0
Which of the following represents the process of defining two or more methods within the same class having the same name but different parameters list?
A) Method overloading
B) Method overriding
C) Encapsulation
Which of the following are applicable for overloading?
A) Constructors
B) Methods
C) Both a & b
Which of the following keyword should be prefixed to a member of the base class to allow overriding in the derived class?
A) overload
B) override
C) new
D) virtual
E) base
using System;
class BaseClass {
public void Print()
{ System.Console.WriteLine("BaseClass");
}
}
class DerivedClass : BaseClass
{
new public void Print()
{ System.Console.WriteLine("DerivedClass");
}
}
class Program {
public static void Main()
{ BaseClass b;
b = new BaseClass();
b.Print();
b = new DerivedClass();
b.Print();
}
}
A) Compile Time Error
B) BaseClass DerivedClass
C) BaseClass BaseClass
D) DerivedClass BaseClass
using System;
class BaseClass {
public virtual void Print()
{ System.Console.WriteLine("BaseClass");
}
}
class DerivedClass : BaseClass
{ public override void Print()
{
System.Console.WriteLine("DerivedClass");
}
}
class Program {
public static void Main()
{ BaseClass b;
b = new BaseClass();
b.Print();
b = new DerivedClass();
b.Print();
}
}
A) Compile Time Error
B) BaseClass DerivedClass
C) BaseClass BaseClass
D) DerivedClass BaseClass
Abstract class contains _____.
Abstract methods
Non Abstract methods
Both
None
The default scope for the members of an interface is _____.
Private
Public
protected
Which keyword is used to define a class in C#?
Class
Class
System.Class
Which operator is used to access variables/fields inside a class in C#?
Arrow Operator (->)
Dot Operator (.)
Dot and Greater Than (.>)
77. What does the access modifier do in C#?
To maintain the syntax
To define a variable inside the class
To access the variables defined inside the class
To control the visibility of class members
Does C# support multiple inheritance?
Yes
No
81. Which C# concept has the capability of an object to take number of different forms and hence display behaviour as accordingly?
Polymorphism
Encapsulation
Abstraction
{"name":"OOP with C#", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Test your knowledge and skills in Object-Oriented Programming with our comprehensive C# quiz! Designed for programmers of all levels, this quiz features a variety of questions covering key OOP concepts.Multiple-choice questionsAbstract classes and interfacesMethod overloading and overridingPolymorphism and encapsulation","img":"https:/images/course6.png"}
Powered by: Quiz Maker