Object Oriented programing Flashcards

1
Q

What is the main principle of object-oriented programming?

A

Encapsulation, inheritance, polymorphism, and abstraction.

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

True or False: In object-oriented programming, a class is a blueprint for creating objects.

A

True.

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

Fill in the blank: The process of creating a new class from an existing class is called __________.

A

inheritance.

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

What is encapsulation in object-oriented programming?

A

The bundling of data and methods that operate on the data within one unit, restricting access to some of the object’s components.

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

Which of the following is NOT a feature of object-oriented programming? A) Inheritance B) Polymorphism C) Compilation D) Encapsulation

A

C) Compilation.

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

What is polymorphism?

A

The ability of different classes to be treated as instances of the same class through a common interface.

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

True or False: Abstraction is the concept of hiding the complex reality while exposing only the necessary parts.

A

True.

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

What keyword is often used to define a class in many object-oriented programming languages?

A

class.

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

Fill in the blank: An object is an instance of a __________.

A

class.

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

What is an interface in object-oriented programming?

A

A contract that defines a set of methods that a class must implement.

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

What does the ‘this’ keyword refer to in object-oriented programming?

A

The current instance of the class.

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

True or False: Constructors are special methods that are called when an object is instantiated.

A

True.

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 in the same class with the same name but different parameters.

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

Which of the following is an example of inheritance? A) A car is a type of vehicle. B) A car has wheels. C) A car can drive.

A

A) A car is a type of vehicle.

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

Fill in the blank: Inheritance allows a class to inherit properties and methods from a __________ class.

A

parent or superclass.

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

What is the purpose of a destructor in object-oriented programming?

A

To clean up resources held by an object before it is destroyed.

17
Q

True or False: In object-oriented programming, a subclass can override methods of its superclass.

18
Q

What is a class variable?

A

A variable that is shared among all instances of a class.

19
Q

What does the term ‘data hiding’ refer to in object-oriented programming?

A

Restricting access to certain details of an object to protect its integrity.

20
Q

What is structured programming?

A

Structured programming is a programming paradigm that emphasizes the use of control structures such as sequences, selections, and iterations to improve the clarity and efficiency of code.

21
Q

True or False: Structured programming encourages the use of goto statements.

22
Q

Which of the following is NOT a control structure used in structured programming: a) Sequence, b) Goto, c) Selection, d) Iteration?

23
Q

Fill in the blank: In structured programming, programs are typically divided into _____ and functions.

24
Q

What are the three main control structures in structured programming?

A

Sequence, Selection, Iteration

25
What is the main advantage of structured programming?
It enhances code readability and maintainability.
26
True or False: Structured programming can lead to less efficient code compared to unstructured programming.
False
27
What is a 'block' in structured programming?
A block is a group of statements that are executed together as a single unit.
28
Name one popular programming language that supports structured programming.
C
29
Which structured programming concept allows for decision-making in code flow?
Selection
30
True or False: Functions in structured programming can help reduce code duplication.
True
31
What does the term 'modularity' refer to in structured programming?
Modularity refers to the practice of breaking down a program into smaller, manageable sections or modules.
32
In structured programming, what is the purpose of a loop?
A loop allows code to be executed repeatedly until a certain condition is met.
33
Fill in the blank: A structured programming approach typically leads to _____ testing and debugging.
easier
34
What is the primary focus of structured programming?
To create clear and logical flow of control in programs.
35
True or False: Structured programming is only applicable to high-level programming languages.
False
36
What is the significance of using comments in structured programming?
Comments help explain code and improve readability for others.
37
Define 'top-down design' in the context of structured programming.
Top-down design is a strategy that starts with the highest level of the program and breaks it down into smaller, more detailed parts.
38
What is the role of algorithms in structured programming?
Algorithms provide a step-by-step procedure for solving a problem, which is essential in structured programming.
39
True or False: Structured programming can be used in both procedural and object-oriented programming.
True