Unit 5.1 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

An object is

A

An object is an abstract data type created by a developer. object id an instance of a class that has states and behavior .

An object is an instance of a class that has two components, data (also called states) and actions (also called behaviors. Data can be variables or data structures such as arrays/lists and . While actions are methods

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

Class

A

A class is Blueprint of an object which shows all the functions and data that are provided by an object of a specific class.

a class is a blueprint for creating objects (a particular data structure), providing initial values for state (member variables or attributes), and implementations of behavior (member functions or methods).

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

Instanation

A

Is the creation of the object, so when you call the consturor

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

Obkect vs class

A

Object vs Class *
*
Object – refers to a particular instance of a class, where the object can be a combination of variables or data structures (called states) and functions, procedures or methods (called behaviours)
Class – an extensible program-code-template for creating objects, providing initial values for states (variables) and implementations of behaviours (functions/procedures/methods

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

intialization Vs Declaration vs Instanation

A

3 steps in creating an obejct from class

First declare, then instnatie then initialize

Declaration: A variable declaration with a variable name with an object type.
– Instantiation: The ‘new’ key word is used to create the object.

Intialization: the new keyword is followed by a call to a constructor

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

UML Diagram

A

First row: Class name
Second row: Variables
Third: Methods

  • sign for Private
    + sign for public
    # Sign for protected

Example class name dog, variables private string name . public GetString () method which is a string

Dog. (ClassName)

-Name : String (Variable is private, and type is string)

+getBreed() : String (Public method has a return type of String)

Now if you have something inside the parameters lets say you have a parameter String Name. so public GetBreed (String name )
in UML it would be

+ GetBreed (Name : String) : String (Second string represents return type)

One last recap:
3 rows for UML: First Class name, second variables, third methods

+ = Public, - Private
+Age: Int, means that this is a public int age variable

Note: Arrays go in variable row: so it would be
example
private String [] sarray;

UML row 2 (variable)
-Sarray : String []

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

Decomposiiton

A

involves breaking down a complex problem or system into smaller parts that are more manageable and easier to understand

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

4 types of realationships between Objects

A

Dependency -Uses
Aggregation - Has a
Inheritance - is a
Association - Uses

Association refers to a relationship between two classes, where one class uses or depends on the other class.

Aggregation is a “has a” realitonship in which two classes assoicate through the use of objects from the other class

Dependency refers to when onw element depends on another element
Example An object from the player class is dependent (Or “Uses”) an object of Ball Class

Association: (2 types, Aggregreation and composition
Refers to when two separate classes which establishes through their objects
Composition is a restricted form of Aggregation in which two entities are highly dependent on each other.

It represents part-of relationship.

In composition, both entities are dependent on each other.
When there is a composition between two entities, the composed object cannot exist without the other entity.

Inherintece is the mechanism by which one class inherits the features (states and behaviors) of another class.
Super class: The class whos features are inherited is known as super class
Sub class: (child class) the class that inherits the other class is known as child class or sub class

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

Dependency , why is it bad?

A

*
It increases maintenance overheads
Maintenance overheads refer to the changes that need to be made to the entire system if you make a change to a component.

For example if you change, B, it affects how C, D and E works, implying that you have to spend time fixing them to work with the “new” B.

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

Four key data types

A

nteger (Java: int), e.g. 3, -4, 999, 23
real (Java: double), e.g. -3.1415, 9.999 String (Java: String) e.g. “strange” Boolean (Java: boolean) e.g. true / false

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

Paramters: Arguments

A

Parameters allow us to pass information or instructions into functions and procedures.
Parameters are the names of the information that we want to use in a function or procedure.
The values passed in are called arguments.

Example of parameter

Public void sum (int x, int y)

Example of argument

b.sum(10,20) (((Using the method we provided values)

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

Paramters: Arguments

A

Parameters allow us to pass information or instructions into functions and procedures.
Parameters are the names of the information that we want to use in a function or procedure.
The values passed in are called arguments.

Example of parameter

Public void sum (int x, int y)

Example of argument

b.sum(10,20) (((Using the method we provided values)

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

Paramters: Arguments

A

Parameters allow us to pass information or instructions into functions and procedures.
Parameters are the names of the information that we want to use in a function or procedure.
The values passed in are called arguments.

Example of parameter

Public void sum (int x, int y)

Example of argument

b.sum(10,20) (((Using the method we provided values)

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