Classes, Methods And Attributes Flashcards

1
Q

What is a “Class”?

A

It is the thing you make in a program that represents a physical thing in the world. Or rather, a category of digitalised versions of specific things in the world.

For example, “Animal” can be a class containing specific reptiles, amphibians, fishes and land mammals in a program.

It’s important to remember that these are digitised versions of our concepts of the world.

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

What is a method?

A

It’s what describes what actions a class or object can do. In computer science, this is a piece of code that does something specific, and usually leads to changing the value of an attribute.

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

What is an attribute?

A

An attribute describes the properties of an object or class. As a rule of thumb, try to make a method for every attribute. The values an attribute has better be changed by methods.

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

What are some elements of an attribute?

A

Visibility modifier, data type, attribute name, default value, semicolon.

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

What are the elements of a method?

A

Visibility modifier, return type, method name, parameter list, method body.

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

What does the visibility modifier private mean for an attribute?

A

For a class Customer with attributes lastName, firstName, sex and birthDate with private as a visibility modifier, this means that the attributes are “visible” or “accessibile” only inside the class.

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