Lecture 5 - Definining a class, attributes and methods Flashcards

1
Q

What is a class ?

A

A collection of similar
objects.

A class is a template or blueprint of objects of the same kind

Instances of a class are
objects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is object oriented Programming?

A

is a programming paradigm that uses abstraction (in the form of classes and objects) to create models based on the real world environment.

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

What does a object oriented program consist of ?

A

many well encapsulated objects and interacting with each other by sending messages

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

Object oriented features ?

A
  • Encapsulation
  • Inheritance
  • Polymorphism
  • Abstraction
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Procedural-oriented programs:

A

focus on procedures, with function as basic unit.

Are not suitable of high-level abstraction for solving real life problems.

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

Object-oriented programs:

A

focus on components that the user perceives, with objects as basic unit.

Permit higher level of abstraction for solving real-life problems.

Ease in software design, in software maintenance and reusable software.

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

What does a class consist of ?

A

Attributes: (or fields) define the object’s state

Methods: define what can be done to them, i.e., object’s
behaviors

Constructors: create an object

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

Naming conventions for classes:

A

mixed case, each word starting upper case

E.g., BouncingBall, HelloWorld, ParetoArchive

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

Naming conventions for Methods and Attributes:

A

mixed case, lower case first letter

E.g., width, originX, borrowDate

E.g., brake, addValueToArchive, resetButton

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

What type of attributes are there ?

A

Instance attributes: belongs to objects.

Static attributes: belongs to the class. refers the common property of all objects (that is not unique
for each object) e.g. company name of employees. Through static keywords.
static final int NUMBER OF SIDES = 4;

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

What are methods ?

A

Methods are well-defined sets of instructions to perform a specific
task.

In a method you have :
Input data: known as method parameters or arguments

Output data: through return statement.
if the return type is void, no need to return.

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

What can a method access?

A

all of that class’s attributes (static and instance)
local variables

the parameters passed to it
variables declared within the method itself

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

What is method overloading :

A

two/more methods

share the same name, but with different method arguments.

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

What can methods be divided into:

A

Instance methods: belongs to objects.

Static methods: belongs to the class:
The main() method is a static method.
Through static keywords.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly