Object Oriented Programming Flashcards
(28 cards)
What is the main principle of Object-Oriented Programming (OOP)?
Encapsulation, inheritance, and polymorphism.
In C#, what keyword is used to define a class?
class
True or False: Inheritance allows a class to inherit properties and methods from another class.
True
Fill in the blank: In C#, a method that is declared as ‘virtual’ can be overridden in a derived class using the keyword ______.
override
What is polymorphism in OOP?
The ability to present the same interface for different underlying data types.
Which access modifier in C# allows members to be accessible only within the same class?
private
What is the purpose of a constructor in a class?
To initialize an object of that class.
What is the difference between ‘abstract class’ and ‘interface’ in C#?
An abstract class can provide some implementation while an interface cannot.
What does the ‘new’ keyword do in C#?
It is used to create an instance of a class.
True or False: A class can inherit from multiple classes in C#.
False
What is encapsulation in OOP?
The bundling of data and methods that operate on that data within one unit, or class.
Fill in the blank: In C#, the keyword ______ is used to indicate that a class is derived from another class.
inherits
What is method overloading?
Defining multiple methods with the same name but different parameters.
True or False: A derived class can access private members of its base class.
False
What is the main purpose of an interface in C#?
To define a contract that implementing classes must follow.
What keyword is used to implement an interface in C#?
implements
True or False: Constructors can be overloaded in C#.
True
What is the purpose of the ‘this’ keyword in C#?
To refer to the current instance of the class.
In pseudocode, how would you represent a loop?
WHILE condition DO
What is a property in C#?
A member that provides a flexible mechanism to read, write, or compute the value of a private field.
Fill in the blank: In C#, to indicate that a class is abstract, you use the keyword ______.
abstract
What is the difference between ‘public’ and ‘protected’ access modifiers?
‘Public’ allows access from anywhere; ‘protected’ allows access only within the class and derived classes.
True or False: A static member belongs to the class rather than to any specific object.
True
What is a delegate in C#?
A type that represents references to methods with a specific parameter list and return type.