Object-Oriented Concepts, Classes, Inheritance, Polymorphism

0.0(0)
studied byStudied by 11 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/40

flashcard set

Earn XP

Description and Tags

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

41 Terms

1
New cards
What is Object-Oriented Programming (OOP)?
OOP is a programming paradigm that focuses on objects and their interactions.
2
New cards
What are the four main concepts of OOP?
Encapsulation, abstraction, inheritance, and polymorphism.
3
New cards
What is a class?
A class is a blueprint for creating objects.
4
New cards
What is an object?
An object is an instance of a class.
5
New cards
What are the properties of a class?
The properties of a class are the variables that define the object's state.
6
New cards
What are the methods of a class?
The methods of a class are the functions that define the object's behavior.
7
New cards
What is encapsulation?
Encapsulation is the practice of hiding the internal details of an object from the outside world.
8
New cards
How is encapsulation achieved?
Encapsulation is achieved through access modifiers such as public, private, and protected.
9
New cards
What is abstraction?
Abstraction is the practice of simplifying complex systems by breaking them down into smaller, more manageable parts.
10
New cards
How is abstraction achieved?
Abstraction is achieved through abstract classes and interfaces.
11
New cards
What is inheritance?
Inheritance is the process by which one class inherits the properties and methods of another class.
12
New cards
What is a base class?
A base class is the class that is being inherited from.
13
New cards
What is a derived class?
A derived class is the class that is inheriting.
14
New cards
What are the types of inheritance?
Single inheritance, multiple inheritance, and hierarchical inheritance.
15
New cards
What is polymorphism?
Polymorphism is the ability of an object to take on many forms.
16
New cards
How is polymorphism achieved?
Polymorphism is achieved through method overriding and method overloading.
17
New cards
What is method overriding?
Method overriding is the process of replacing a method in the base class with a new implementation in the derived class.
18
New cards
What is method overloading?
Method overloading is the process of creating multiple methods with the same name but different parameters.
19
New cards
What are virtual functions?
Virtual functions are functions that are declared in a base class and can be overridden in a derived class.
20
New cards
What are abstract classes?
Abstract classes are classes that cannot be instantiated and contain one or more abstract methods.
21
New cards
What are interfaces?
Interfaces are similar to abstract classes but they only contain abstract methods and no implementation.
22
New cards
What is a constructor?
A constructor is a special method that is called when an object is created.
23
New cards
What is the purpose of a constructor?
The purpose of a constructor is to initialize the object's state.
24
New cards
What is a destructor?
A destructor is a special method that is called when an object is destroyed.
25
New cards
What is the purpose of a destructor?
The purpose of a destructor is to free up any resources that the object was using.
26
New cards
What is a static method?
A static method is a method that belongs to the class and not to any instance of the class.
27
New cards
What is the purpose of a static method?
The purpose of a static method is to perform a task that is not dependent on any particular instance of the class.
28
New cards
What is a static variable?
A static variable is a variable that belongs to the class and not to any instance of the class.
29
New cards
What is the purpose of a static variable?
The purpose of a static variable is to share data across all instances of the class.
30
New cards
What is a constructor in a class?
A constructor is a special method that is called when an object is created from a class. It is used to initialize the object's properties and set their initial values.
31
New cards
What is an access modifier in a class?
An access modifier is a keyword that determines the level of access to a class member (property or method). There are three types of access modifiers in C\#: public, private, and protected.
32
New cards
What is the difference between a public and a private access modifier?
A public access modifier allows the member to be accessed from anywhere, while a private access modifier restricts the member to be accessed only within the class.
33
New cards
What is a derived class in inheritance?
A derived class is a class that inherits properties and methods from a parent (base) class. It adds its own properties and methods, and may override some of the inherited methods.
34
New cards
What is multiple inheritance?
Multiple inheritance is a feature of some programming languages, such as C++, where a derived class can inherit properties and methods from multiple base classes.
35
New cards
What is method overloading in polymorphism?
Method overloading is when multiple methods with the same name but different parameters are defined in a class. The correct method to use is chosen based on the arguments used when calling the method.
36
New cards
What is method overriding in polymorphism?
Method overriding is when a derived class provides its own implementation of a method that is already defined in the base class. The method in the derived class has the same name, return type, and parameters as the method in the base class.
37
New cards
What is a virtual function in polymorphism?
A virtual function is a method in a base class that can be overridden by a method in a derived class. It allows the correct method to be called at runtime based on the type of the object.
38
New cards
What is an abstract class in OOP?
An abstract class is a class that cannot be instantiated and is used as a base class for other classes. It can define abstract methods, which must be implemented by its derived classes.
39
New cards
What is an interface in OOP?
An interface is a blueprint for a set of methods and properties that a class must implement. It defines the contract that a class must adhere to in order to be used in a certain way.
40
New cards
What is the difference between an abstract class and an interface?
An abstract class can have method implementations, while an interface can only define method signatures. A class can inherit from only one abstract class, but can implement multiple interfaces.
41
New cards
What is a final method?
A final method is a method in a class that cannot be overridden by any subclass. Once a method is marked as final, it cannot be modified by any subclass. This is useful when the behavior of a method is critical and should not be changed, or when a method is intended to be used as is, without modification.