OOP Flashcards

1
Q

What is a method?

A

A method is a function which is a property of an object.

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

How can you tell the difference between a method definition and a method call?

A

method definition is writing out the function inside object and The call() method calls a function with a given this value and arguments provided individually

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

Describe method definition syntax (structure).

A

function name, colon, function key word, optional parameter, opening curly brace, code block, closing curly brace, comma.

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

How is a method different from any other function?

A

The difference is that a method is associated with an object, while a function is not

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

What is the defining characteristic of Object-Oriented Programming?

A

Object Oriented programming (OOP) is a programming paradigm that relies on the concept of classes and objects. It is used to structure a software program into simple, reusable pieces of code blueprints (usually called classes), which are used to create individual instances of objects. Encapsulation.

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

What are the four “principles” of Object-Oriented Programming?

A

Abstraction, Encapsulation, Inheritance, Polymorphism

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

What is “abstraction”?

A

Through the process of abstraction, a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency.

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

What does API stand for?

A

Application Programming Interface

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

What is the purpose of an API?

A

software intermediary that allows two applications to talk to each other

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

what is method call syntax?

A

object name.method(arguments)

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

What is this in JavaScript?

A

The JavaScript this keyword refers to the object it belongs to

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

What does it mean to say that this is an “implicit parameter”?

A

it is available in a function’s code block even though it was never included in the function’s parameter list or declared

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

When is the value of this determined in a function; call time or definition time?

A

the value of this is determined at call time.

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

Given the above character object, what is the result of the following code snippet? Why?

A

It’s a me Mario!

because this.firstName = firstName of character object

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

Given the above character object, what is the result of the following code snippet? Why?

A

“It’s-a-me Mario!”

because this.firstName = firstName of character object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
Given the above character object, what is the result of the following code snippet? Why?
var hello = character.greet;
hello();
A

“It’s-a-me, undefined!”

because variable hello is being defined outside of the character object; this no longer points to the character object.

17
Q

How can you tell what the value of this will be for a particular function or method definition?

A

the value of this is determined when the function is called, not when it is defined.

18
Q

What kind of inheritance does the JavaScript programming language use?

A

prototype-based (prototypal) inheritance

19
Q

What is a prototype in JavaScript?

A

The prototype is an object that is associated with every functions and objects by default in JavaScript

20
Q

What is a prototype in JavaScript?

A

The prototype is an object that is associated with every functions and objects by default in JavaScript

21
Q

How is it possible to call methods on strings, arrays, and numbers even though those methods don’t actually exist on objects, arrays, and numbers?

A

methods are defined on a prototype object and arrays, strings and numbers borrow the methods when needed. prototypal inheritance.

22
Q

If an object does not have it’s own property or method by a given key, where does JavaScript look for it?

A

the object’s prototype.

23
Q

What does the new operator do?

A

new operator is used to create an instance of a user-defined object type or one of built in object types which have a constructor function.
The new keyword does the following things:

  1. Creates a blank, plain JavaScript object.
  2. Adds a property to the new object (__proto__) that links to the constructor function’s prototype object
  3. Binds the newly created object instance as the this context (i.e. all references to this in the constructor function now refer to the object created in the first step).
  4. Returns this if the function doesn’t return an object.
24
Q

What property of JavaScript functions can store shared behavior for instances created with new?

A

prototype property