OOP Flashcards

1
Q

A programming model that is based on the concept of classes and objects.

A

Object-Oriented Programming (OOP)

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

T or F

OOP has no advantages over conventional or procedural style of programming.

A

F

OOP has several advantages over conventional or procedural style of programming.

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

Advantages of OOP?

A
  • It provides a clear modular structure for the programs.
  • It helps you adhere to the “don’t repeat yourself (DRY) principle, thus make your code much easier to maintain, modify and debug.
  • It makes it possible to create methods with less code and shorter development time with high degree of reusability.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why implement OOP?

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

The two main aspects of OOP are:

A

Classes and Objects

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

A self-contained, independent collection of variables and functions which work together to perform one or more specific tasks.

A

Class

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

Individual instances of a class

A

Object

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

A class acts as _____ or _____from which individual objects can be created.

A

template / blueprint

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

T or F

When individual objects are created, they inherit the same generic properties and behaviors.

A

T

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

T or F

Each object cannot have different values for certain properties.

A

F

Each object may have different values for certain properties.

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

How do you declare a class?

A
  1. the class keyword
  2. the name of the class
  3. a pair of curly braces {}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Variables within a class are called ____, while functions are called ____.

A

properties, methods

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

Class names are also conventionally written in ____ i.e. each concatenated word starts with an uppercase letter (e.g. MyClass).

A

PascalCase

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

An OOP construct that is used to access contained properties and methods of a given object.

A

arrow symbol (->)

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

The pseudo-variable ____ provides a reference to the calling object.

A

$this

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

Allows to initialize the object’s properties upon creation of the object.

A

Constructor

17
Q

We use _____ function to declare constructor inside the class.

A

__construct()

18
Q

T or F

Constructor and destructor functions uses two underscores in declaration

19
Q

Called when the object is destructed or the script is stopped or exited.

A

Destructor

20
Q

T or F

__destruct function will be called at the beginning of the script.

A

F

__destruct function will be called at the end of the script.

21
Q

T or F

Constructor is invoked automatically every time you create an object.

22
Q

T or F

Destructor is invoked automatically every time you create a __destruct() function.

23
Q

When working with classes, you can even restrict access to its properties and methods using the _________ for greater control.

A

visibility keywords (access modifiers)

24
Q

A method can be accessed anywhere within or outside of class. Default in PHP

25
A method that can only be accesses within the class itself or in inherited classes.
protected
26
A method is accessible only within the class that defines it.
private
27
Classes can inherit the properties and methods of another class using the ___keyword.
extends
28
It is probably the most powerful reason behind using the object-oriented programming model.
Inheritance
29
These variables are different but their values are known and fixed in compile time.
Constant and Static variables
30
T or F Unlike static, constant variable values can be changed during runtime
F Unlike constant, static variable values can be changed during runtime.
31
T or F If a static variable is used inside a class it belongs to the instance of the class rather than the class.
F If a static variable is used inside a class it belongs to the class rather than the instance of the class.
32
To access static variable (outside or inside the class), you need to use the ____ or ____. Followed by the _____ and the _______, starting with $.
1. class name or the self keyword (if inside the class) 2. scope resolution operator :: 3. name of the static variable
33
____ methods have the same concept of Static variables but in a function way.
Static
34
We can use the ______ keyword when accessing static variables/methods inside a child class.
parent