Object Oriented Programming Flashcards

(28 cards)

1
Q

What is the main principle of Object-Oriented Programming (OOP)?

A

Encapsulation, inheritance, and polymorphism.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In C#, what keyword is used to define a class?

A

class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

True or False: Inheritance allows a class to inherit properties and methods from another class.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Fill in the blank: In C#, a method that is declared as ‘virtual’ can be overridden in a derived class using the keyword ______.

A

override

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is polymorphism in OOP?

A

The ability to present the same interface for different underlying data types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which access modifier in C# allows members to be accessible only within the same class?

A

private

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the purpose of a constructor in a class?

A

To initialize an object of that class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the difference between ‘abstract class’ and ‘interface’ in C#?

A

An abstract class can provide some implementation while an interface cannot.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the ‘new’ keyword do in C#?

A

It is used to create an instance of a class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

True or False: A class can inherit from multiple classes in C#.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is encapsulation in OOP?

A

The bundling of data and methods that operate on that data within one unit, or class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Fill in the blank: In C#, the keyword ______ is used to indicate that a class is derived from another class.

A

inherits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is method overloading?

A

Defining multiple methods with the same name but different parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

True or False: A derived class can access private members of its base class.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the main purpose of an interface in C#?

A

To define a contract that implementing classes must follow.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What keyword is used to implement an interface in C#?

17
Q

True or False: Constructors can be overloaded in C#.

18
Q

What is the purpose of the ‘this’ keyword in C#?

A

To refer to the current instance of the class.

19
Q

In pseudocode, how would you represent a loop?

A

WHILE condition DO

20
Q

What is a property in C#?

A

A member that provides a flexible mechanism to read, write, or compute the value of a private field.

21
Q

Fill in the blank: In C#, to indicate that a class is abstract, you use the keyword ______.

22
Q

What is the difference between ‘public’ and ‘protected’ access modifiers?

A

‘Public’ allows access from anywhere; ‘protected’ allows access only within the class and derived classes.

23
Q

True or False: A static member belongs to the class rather than to any specific object.

24
Q

What is a delegate in C#?

A

A type that represents references to methods with a specific parameter list and return type.

25
What is the purpose of the 'base' keyword in C#?
To access members of the base class from a derived class.
26
Fill in the blank: In C#, the ______ keyword is used to define an event.
event
27
What is the primary benefit of using OOP?
Improved code reusability and maintainability.
28
True or False: C# supports multiple inheritance directly.
False