Quiz 2 Flashcards

1
Q

Function definition

A

A set of instructions that perform a task

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

Method Definition

A

A set of instructions that are associated with a task

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

Two components to a method?

A

Method heading (access modifiers, return types, name and parameters)
The block (pair of curly brackets containing the code that fulfils the methods responsibility)

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

Java constructor?

A

A special method that enables an object to initialise itself when it is created

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

Why use access modifiers

A

A public interface
Private details
That way many people can work on a project with no problem provided they have agreed on public interfaces

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

Encapsulation?

A

Hiding implementation details of an object from its clients

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

The encapsulation principle?

A

An object should be an encapsulated entity, providing an API. The user of an object should not be aware of the internal representation of state or details of algorithms.

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

Java encapsulation?

A

Binding of data and methods together into a single unit such that they are kept both safe from outside interference and misuse

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

How to achieve encapsulation in Java

A

By declaring the member variables of a class as private

Providing a public setter/getter methods to modify and view the variable values

Private member variables are only accessibly within the class

Only by using the getter methods the private members can be accessed outside the class

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

Benefits of encapsulation?

A

o Data hiding
o Code reusability
o Getter & setter methods
o Total control
o Flexibility & maintainability
o Ease of testing

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