7 Flashcards

(29 cards)

1
Q

What is OOP?

A

Object-Oriented Programming (OOP) is a programming model based on the concept of classes and objects.

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

What are the advantages of OOP?

A
  • Clear modular structure for programs
  • Adheres to the DRY principle
  • Easier to maintain, modify, and debug
  • Allows for less code and shorter development time with high reusability
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why implement OOP?

A
  • Good structure of the program
  • Code reusability
  • Faster development
  • Easier to maintain
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the two main aspects of OOP?

A

Classes and objects.

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

Define a class in OOP.

A

A class is a self-contained, independent collection of variables and functions that work together to perform specific tasks.

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

What is an object in OOP?

A

An object is an individual instance of a class.

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

How does a class act in OOP?

A

A class acts as a template or blueprint from which individual objects can be created.

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

What is the relationship between classes and objects?

A

Objects inherit the same generic properties and behaviors from their classes but may have different values for certain properties.

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

True or False: A class can be declared using the class keyword followed by the class name and curly braces.

A

True.

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

What are variables within a class called?

A

Properties.

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

What are functions within a class called?

A

Methods.

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

How are class names conventionally written?

A

In PascalCase, where each concatenated word starts with an uppercase letter.

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

What does the arrow symbol (->) do in OOP?

A

It is used to access contained properties and methods of a given object.

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

What is the purpose of the $this pseudo-variable?

A

It provides a reference to the calling object.

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

What is a constructor in OOP?

A

A constructor allows initializing the object’s properties upon creation.

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

How is a constructor declared in a class?

A

Using the construct() function with double underscores before ‘construct’.

17
Q

What is a destructor in OOP?

A

A destructor is called when the object is destructed or when the script is stopped or exited.

18
Q

How is a destructor declared in a class?

A

Using the destruct() function with double underscores before ‘destruct’.

19
Q

What are access modifiers?

A

Keywords that restrict access to properties and methods for greater control.

20
Q

List the three visibility keywords in OOP.

A
  • public
  • protected
  • private
21
Q

What does the public access modifier do?

A

Allows properties or methods to be accessed anywhere within or outside of the class.

22
Q

What does the protected access modifier do?

A

Allows access only within the class itself or in inherited classes.

23
Q

What does the private access modifier do?

A

Allows access only within the class that defines it.

24
Q

What is inheritance in OOP?

A

Classes can inherit properties and methods from another class using the extends keyword.

25
What distinguishes static variables from constants in OOP?
Static variables can change during runtime, while constants have fixed values known at compile time.
26
How are static variables accessed in OOP?
Using the class name or the self keyword followed by the scope resolution operator :: and the static variable name.
27
What is the relationship between static variables and class instances?
Static variables belong to the class rather than to instances of the class.
28
What is a static method in OOP?
A method that has the same concept as static variables but in a function context.
29
What keyword can be used to access static variables/methods inside a child class?
The parent keyword.