oop Flashcards

(8 cards)

1
Q

what is an object

A

An object is
* Something tangible (person, pen, mug

An object has state, behavior, identity

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

What is a class

A

A class is a blueprint or template for creating objects (instances). It
defines the structure and behaviour that its instances (objects) will
have.

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

Constructors

A

The constructor MUST have the same name as
the class name
* A class can have more than one constructor

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

instance variable

A

An instance variable can hold a single value
 e.g. private double balance

Instance variables are typically defined as private
 this facilitates information hiding between classes
 more on access modifiers (e.g. private) later
 information hiding essential in industry

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

instance Methods

A
  • Instance methods represent the behavior and alter
    the state of an object, they manipulate an object
  • Instance methods also provide the interface of
    classes
     different objects can communicate with each other via
    their instance methods
  • To achieve this, instance methods are typically
    defined as public
     can be accessed by members of other classes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Method overloading

A

Instance methods can be overloaded, i.e. more than one
method can have the same name inside the same class
* For this to work, overloaded methods must have different
number of parameters, or parameters of different types

public void deposit(double amount)
public void deposit(double money)
2) public void deposit(double amount)
public void deposit(double amount, double interest

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

Access modifier

A

The declaration of an instance variable, a constructor, an
instance method (even of a class) begins with an access
modifier (public or private)
 Public: the entity can be accessed by other classes
 Private: the entity is only accessible from within the class
itself

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