OOP studying Flashcards

1
Q

What is OOP?

A

Programming paradigm that relies on the concept of classes and objects. It is used to structure a software program into simple, reusable pieces of code.

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

What is a class?

A

Blueprint of an object. User defined data type and can also encapsulate functions. Stored in heap memory/dynamic memory.

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

What is an object?

A

Instance of a class. An attribute or characteristic.

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

What is Encapsulation?

A

Methods/functions and variables in a class. Makes code look cleaner. Example – Element ID associated to buttons on the android app. Swipe functionality.

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

What is Inheritance

A

Allows classes to inherit features of other classes. Supports reusability. We inherit certain properties from the class ‘Human’ such as the ability to speak, breathe, eat, drink, etc

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

What is Abstraction?

A

Hiding the implantation details. Example – Header files. ATM.

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

What is Polymorphism?

A

Same function or object behaves differently in different scenarios. Example – Dogs are used to herd sheep but not all dogs herd sheep.

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

What is Function/Method overloading?

A

Two or more functions with same name but different parameters

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

What is Function/Method overriding?

A

Creating a new version of an old function in the child class

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

What is Data hiding?

A

Put data in a class and declare it as private. Prevents honest mistakes.

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

What are pointers?

A

Is a variable that stores a memory address

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

What is a reference variable?

A

Is an address that indicates where an object’s variables and methods are stored

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

What is a linked list?

A

is a linear collection of data elements. Each element points to the next

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

What are access specifiers?

A
Public – accessible from outside the class
Private – accessible from other members of the same class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is an inline function?

A

Actual code is in the function

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

“this” pointer

A

refers to the current object of a class

17
Q

What is a structure?

A

Also a user defined data type. Stored in stack memory.

18
Q

What is a constructor?

A

A special construct that creates objects. no return type. same name as class.

19
Q

What is a default constructor?

A

A constructor with no parameters.

20
Q

What is a Parameterized constructor?

A

Constructor with parameters

21
Q

What is a copy constructor?

A

Creates a new object as a copy of an existing object

22
Q

What is a destructor?

A

Happens automatically when an object is removed. Same name as the class. “~” tilde

23
Q

Memory allocation

A

“New” is used for memory allocation

“delete” is used for memory deallocation

24
Q

What is Multi-threading?

A

Multiple threads are executed simultaneously. Each thread starts its own stack based on the flow (or) priority of the threads.

25
Q

What is a Thread?

A

the flow of execution is called Thread. Every java program has at least one thread called the main thread

26
Q

How is Java different from C++?

A

C++ allows users to use pointers in the program.

27
Q

What is the main objective of garbage collection?

A

is to free up the memory space occupied by the unnecessary and unreachable objects during the Java program execution by deleting those unreachable objects.

28
Q

Disadvantages of a Multithreaded Application

A

Difficulty of debugging

It is much harder to replicate an error in a multithreaded application than it is to do so in a single-threaded