CHAPTER 2 - OBJECT ORIENTED PROGRAMMING (OOP) Flashcards

1
Q

OOP stands for

A

OBJECT PROGRAMMING PROGRAMMING

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

__________ ___________ __________ creating objects that contain both data and functions.

A

OOP

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

__________ ____________writing procedures or functions that perform operations on the data

A

PROCEDURAL PROGRAMMING

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

Advantages of OOP

A
  • OOP is faster and easier to execute
  • OOP provides a clear structure for the programs
  • OOP helps to keep the PHP code DRY “Don’t Repeat Yourself”, and makes the code easier to maintain, modify and debug
  • OOP makes it possible to create full reusable applications with less code and shorter development time.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

“DRY” stands for

A

Don’t Repeat Yourself

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

It is a principle about reducing the repetition of code. You should extract out the codes that are common for the application, and place them at a single place and reuse them instead of repeating it.

A

DRY - don’t repeat yourself

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

two main aspects of object-oriented programming.

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

_________ is a template for objects

A

CLASS

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

_______ Instance of a class

A

OBJECT

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

Define a class

A

<?php
class fruit{
//properties
//methods
}

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

define public properties (note: we can also use private and protected)

A

public $name;
public $age;

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

define set and get method with property name

(public $name;)

A

public function setname($n){
$this->name = $n;
}

public function getname(){
return $this->name;
}

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

instantiate the class Fruit:

A

$banana = new Fruit();

($banana is the instance/object of a class fruit)

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

set the name mango as the value of the instance $banana, and echo $banana.

A

$banana->setname(‘mango’);

echo $banana->getname();

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

What is “$this” keyword?

A

it refers to the current object and is only available inside methods.

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

change value of property $name outside the class:

A

$banana->name = “Orange”;