Object Oriented Programming Flashcards

1
Q

What is a constructor?

A

A constructor is a special method that is called automatically when an object is created with the “new” operator.
It’s purpose is to initialize the attributes of an object when the object is created.

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

What does a constructor look like in java?

A

A constructor has the same name as the class name.

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

What is the scope of variables?

A

Scope refers to the parts of the code in which those variables can be used.

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

What’s the rule of thumb for variables?

A

Instance variables are accessible form within the class. And generally speaking: a variable is only accessible in its block.

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

What is ‘final’ used for?

A

Used to declare a constant (all caps).

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

What is overloading?

A

When we call a method over an existing method in a superclass.

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

What is an array?

A

An array has a particular number of cells when it is created (its capacity).

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

What happens when an array is full and we store to store past the last element in the array?

A

An exception is thrown.

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

What’s the difference between a formal parameter and an actual parameter.

A

Formal parameter comes from the variable in the list in the method definition.

Actual parameter is from invoking a method with an actual parameter.

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

What is modularity?

A

It refers to subdividing a large problem into smaller components, or modules, to make the design of a solution easier.

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

What is information hiding?

A

Information hiding refers to making implementation details inaccessible.

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