OOP Concepts Flashcards

1
Q

What is a primitive data type?

A

Store simple and single values such as a byte, int, float, char, boolean, and char

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

What is the difference between a structure and an object?

A

A structure is a collection of related variables of different data types, whereas an object in object-oriented programming is an instance of a class that encapsulates data and behavior.

The key difference between a structure and an object is that a structure is a passive collection of data, while an object is an active entity that can perform actions and interact with other objects.

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

What is object-oriented programming (OOP)?

A

OOP is a programming paradigm that focuses on organizing code into objects that contain data and methods to interact with that data.

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

What are the four pillars of OOP?

A

The four pillars of OOP are encapsulation, inheritance, polymorphism, and abstraction.

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

What is encapsulation?

A

Encapsulation is the idea of bundling data and methods together within a class and hiding the implementation details from the user.

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

What is inheritance?

A

Inheritance is the idea of creating new classes based on existing classes, allowing the new classes to inherit the properties and methods of the parent class.

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

What is polymorphism?

A

Polymorphism is the idea of having multiple forms of a function or method, allowing the same function to be used with different types of objects.

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

What is abstraction?

A

Abstraction is the idea of focusing on the essential features of an object or system, ignoring the irrelevant details.

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

What is a class?

A

A class is a blueprint for creating objects, defining the properties and methods that the objects will have.

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

What is an object?

A

An object is an instance of a class, created from the blueprint defined by the class.

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

What is a constructor?

A

A constructor is a special method that is used to initialize the properties of an object when it is created.

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

What is a method?

A

A method is a function that is defined within a class and is used to manipulate the properties of an object.

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

What is a property?

A

A property is a variable that is defined within a class and is used to store data related to the object.

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

What is the difference between a class and an object?

A

A class is a blueprint for creating objects, while an object is an instance of a class.

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

What is a static method?

A

A static method is a method that belongs to the class itself rather than to any particular instance of the class.

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

What is inheritance hierarchy?

A

Inheritance hierarchy is the structure that results from creating new classes based on existing classes, with the parent classes at the top and the child classes at the bottom.

17
Q

What is method overriding?

A

Method overriding is the process of redefining a method in a child class that was originally defined in the parent class.

18
Q

What is method overloading?

A

Method overloading is the process of creating multiple methods with the same name but different parameters.

19
Q

What is the difference between composition and inheritance?

A

Composition is the idea of combining different classes to create a new class, while inheritance is the idea of creating new classes based on existing classes.

20
Q

What is an interface?

A

An interface is a set of method signatures that a class can implement, allowing objects of that class to be used in a certain way.

21
Q

What is a package?

A

A package is a way of organizing related classes and interfaces into a single unit.

22
Q

What is a design pattern?

A

A design pattern is a reusable solution to a common programming problem, providing a template for solving similar problems in the future.

23
Q

What are access modifiers? (public, private, protected)

A

Keywords that control the visibility and accessibility of class members.

Public: can be accessed from anywhere, both within and outside of the class in which it is defined. In other words, any code that has access to an instance of the class can read or modify its public variables.

Private: can only be accessed within the class in which it is defined. In other words, only code that is part of the class can read or modify its private variables.

Protected: similar to a private variable, but it can also be accessed by derived classes. In other words, only code that is part of the class or its derived classes can read or modify its protected variables.

24
Q

What is composition?

A

A mechanism that allows objects to contain other objects as part of their state.

25
Q

What is aggregation?

A

A mechanism that allows objects to have a “has-a” relationship with other objects.

26
Q

What is an abstract class?

A

Classes that cannot be instantiated, but can be used as a base class for other classes.

27
Q

What is a static class?

A

Classes that contain only static members and cannot be instantiated.

28
Q

What is a virtual function?

A

Functions that can be overridden in derived classes.

29
Q

What is multiple inheritance?

A

A mechanism that allows a class to inherit properties and methods from multiple base classes.

30
Q

What is the class hierarchy?

A

A tree-like structure that shows the inheritance relationships between classes.

31
Q

What are generics?

A

In programming, a generic is a type or method that is parameterized by one or more type parameters. This allows the same code to be reused with different types, without having to rewrite the code for each specific type.