OOP Basics I Flashcards

Learn OOP basics.

1
Q

What are constants?

A

Constants are unchangeable public properties in a class.

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

$this is available when…

A

…a method is called from within an object context.

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

In the class context, it is possible to create a new object with…

A

new self and new parent.

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

What’s the difference between passing by value and passing by reference?

A

When you pass by value, you are making a copy. Passing by reference makes a new pointer to the original value.

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

A class can inherit from how many classes?

A

1

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

How can you override inherited methods and properties?

A

By redeclaring them with the same name defined in the parent class.

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

What does the ‘final’ keyword do?

A

It prevents child classes from overriding a method.

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

How do you access a parent’s overridden methods or properties in a child class?

A

By referencing them with parent::

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

When overriding methods, the parameter signature should…

A

…stay the same (unless it is the constructor).

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

What is the difference between $this and self?

A

Inside a class definition, $this refers to the current object, while self refers to the current class.

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

What is a property?

A

A class member variable.

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

How do you autoload classes?

A

Define an __autoload function.

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

Where can public class members be accessed?

A

Everywhere.

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

Where can protected class members be accessed?

A

Within the class itself, and by inherited and parent classes.

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

Where can private class members be accessed?

A

Only by the class that defines the member.

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

$this is a reference to…

A

…the calling object.

17
Q

When is $this not a reference to the calling object?

A

When the method is called statically from the context of a secondary object.

18
Q

When is the __autoload function called?

A

When you are trying to use a class/interface which hasn’t been defined yet.

19
Q

If a class itself is declared as final, it cannot be…

A

…extended.