oop test Flashcards

(13 cards)

1
Q

what is encapsulation?

A
  1. all information about each object is in one location (1 class)
  2. variables are private with setter and getter methods to access/change them
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

pros of encapsulation?

A
  • more security/privacy
  • more organized
  • no repeat of code (less redundant)
  • easier to manage project (abstraction)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

definition of inheritence

A

subclasses and superclasses
- classes can inherit attributes and methods from other classes

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

overloading

A

same method name, different parameters

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

overriding

A

same method name & parameters, in subclass/super class

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

polymorphism?

A
  1. static - overloading & overiding
  2. dynamic - assigning subclass instance to superclass reference
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is constructor

A

method that:
1. has same name as class name
2. no return type

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

what are 3 components of object

A
  1. name/identifier
  2. variables/attributes
  3. behaviours/instance methods
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what are 3 components of classes

A
  1. variables / field (data / property / attribute / state)
    a. normal field (aka. instance method)
    b. static field (aka. class variable)
  2. constructor
  3. method/behaviour
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

pros + cons of oop

A

pros:
1. encapsulation
- no repeat of code (less redundant)
- more security
- modularity
- abstraction

  1. polymorphism
    - more code flexibility and reusability
  2. inheritence
    - attributes can be shared among classes

cons:
- not good for small projects
- learning curve

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

abstraction

A

hiding certain details and only showing essential info

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

modularity

A

breaking down program into smaller pieces so that changing one part of code doenst affect entire program

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

types of relationships (+ symbols)

A
  1. association
  2. uses/dependency (arrow ->)
  3. is-a (arrow with not coloured in head)
  4. has-a (aggregation (non-coloured rhombus), composition (shaded rhombus))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly