OOP Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

OOP stands for?

A

Object Oriented Programming.

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

What is OOP?

A

Programming paradigm based on the concept of objects, which can contain data in the form of fields and code in the form of methods.

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

What are the key principles of OOP?

A

Encapsulation
Inheritance
Polymorphism
Abstraction

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

What is Encapsulation?

A

Bundling of data and methods that operate on that data into a single unit or class. It restricts direct access to some of the object’s components, which is a way to enforce data hiding.

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

What is Inheritance?

A

Mechanism where a new class inherits the properties and behavior of another class. This helps in code reusability.

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

What is Polymorphism?

A

Ability of different classes to respond to the same function or method call in their own way. It can be achieved via method overloading or overriding.

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

What is Abstraction?

A

Hiding the complex implementation details and showing only the essential features of the object. It simplifies interaction with objects.

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

What is a class?

A

A class is a blueprint for creating objects. It defines a datatype by bundling data and methods that work on the data into one single unit.

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

What is an object?

A

An object is an instance of a class. When a class is defined, no memory is allocated until an object is created from the class.

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

What is the difference between a class and an object?

A

A class is a blueprint that defines the attributes and methods of an object whereas an object is an instance of a class. It holds the actual data and can use the methods defined in the class.

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

What are the two types of Polymorphism?

A

Method Overloading (runtime polymorphism) and Method Overriding (compile-time polymorphism).

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

What is method overloading?

A

Method overloading refers to the ability to define multiple methods in the same class with the same name but different parameter lists.

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

What is method overriding?

A

Method overriding allows a subclass to provide a specific implementation of a method that is already defined in its superclass.

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

What’s the difference between Abstraction and Encapsulation?

A

Abstraction focuses on hiding complexity by only exposing relevant information whereas Encapsulation focuses on controlling access to the data by using access modifiers.

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

What is an abstract class?

A

An abstract class is a class that cannot be instantiated and is meant to be inherited by other classes. It typically contains one or more abstract methods that must be implemented by its subclasses.

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

What are access specifiers?

A

Access specifiers define the visibility of class members. Common access specifiers are:

Public: Accessible from anywhere.
Private: Accessible only within the class.
Protected: Accessible within the class and by derived classes.

17
Q

What is a constructor?

A

A constructor is a special method that is automatically called when an object is instantiated. Its main purpose is to initialise the object’s attributes.