Chapter 3 - Object interaction Flashcards

1
Q

The result can never be higher than the right operand

A

what is the maximum value a modulo expression can evaluate to

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

what is a
class type

A

this is a non-primitive data type that is defined by a class

remember
Variables can hold objects. in this case when we declare the variable then its type will be the class of the object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. These will show the classes in the program and the relationship between them.
  2. This view is static since all classes and their relationships are defined in the source code and will be part of the compiled program
A

describe a
class diagram

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

describe
modularization

A

this breaks the problem into its fundamental parts. from here we may look closely at there details and may even perform even further modularization

example
(car can be modularized to wheels, engine, body. the engine may be further modularized into pistons, spark plugs, etc)

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

in two steps how can we
solve a problem domain

A
  1. break the problem down into its components (abstraction)
  2. solve the details of those components (modularization)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. this will show the objects and their relationships.
  2. This is a dynamic view since objects can be created, destroyed and modified during runtime
  3. and so we can only ever catch a snapshot of the view
A

describe an
object diagram

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

describe the meaning of
name overloading

A

this is where we have used the same variable name twice and in such a way that they conflict, In general when this occurs the definition from the closest enclosing block is used

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

what two things does the keyword
new
do

A

this will
1.It creates a new object of the named class
2.It calls the constructor of that class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  1. symbol: &&
  2. function: A && B - if A AND B are true the result is true
A

describe the java boolean operator
AND

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

this can be used in situations where we have a name conflict known as name overload
Example:
Field
String a;

Constructor
Public constructor (string a)
{
a = a
}
// we are setting the formal parameter a to the formal parameter a

This.a = a
// we are setting the field a to the formal parameter a

A

in what situation would the use of the
**this keyword **
be useful

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  1. symbol: %
  2. function: It has two operands and its result is the remainder after the left operand is divided by the right operand
  3. examples

15 % 4 = 3 because 4 goes into 15 3 times with a remainder of 3
4 % 15 = 4 because 4 cannot be divided by 15 and so 4 is the remainder

A

describe the java
modulo
operator

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

describe an
object diagram

A
  1. this will show the objects and their relationships.
  2. This is a dynamic view since objects can be created, destroyed and modified during runtime
  3. and so we can only ever catch a snapshot of the view
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

This is when a method of an object is called from outside the object and will use a qualified name to make the call

A

describe an
external method call

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

used to make external method calls and consists of simple names separated by dots (dot notation)

A

what is a
qualified name

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

desribe the technicality of the java modulo operator

A

Technically the java modulo operator is a remainder operator.

usually this does not matter but in the case of negative numbers it does (this will vary between programming languages)

  1. Remainder operator (java) - the result is negative only if the dividend is negative (the thing being divided I.e the left operand)
  2. Traditional modulo - the result has the same sign as the divisor (thing dividing by I.e the left operand)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

name a situation where use of the
modulo operator
would be desired

A

This is useful to use in situations where we wish to roll over a number that has a limit instead of using conditions

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

describe the java
modulo
operator

A
  1. symbol: %
  2. function: It has two operands and its result is the remainder after the left operand is divided by the right operand
  3. examples

15 % 4 = 3 because 4 goes into 15 3 times with a remainder of 3
4 % 15 = 4 because 4 cannot be divided by 15 and so 4 is the remainder

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

what is the
syntax for the keyword new

A

Syntax
New ClassName(parameters)

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

describe an
“anonymous” object

A

this is an object that we have lost all references to
example:
Var1 = object1 // var1 holds a reference to object 1
Var2 = object2 // var2 holds a reference to object 2

Var1 = var2 // var1 is assigned the value of var2
Var1 = object2 // and so var1 holds a reference to object 2
Var2 = object2 // var2 maintains a reference to object 2

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

describe why
**String.equals() **
should be used over == when comparing strings

A

When comparing two strings this should be used this is because
1.The == operator will compare whether two object references are pointing to the same object
2.The string.equals() checks whether the contents or state of the object match

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

this breaks the problem into its fundamental parts. from here we may look closely at there details and may even perform even further modularization

example
(car can be modularized to wheels, engine, body. the engine may be further modularized into pistons, spark plugs, etc)

A

describe
modularization

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

what is a
simple name

A

used to make internal method calls and consists of a unique identifier

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

the syntax for this type of call is
methodName(parameters)

A

what is the
syntax for an internal method call

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

This is useful so that an object can be initialised in different ways or perhaps a method can carry out the same task but on different data types.

A

describe why
overloading is useful

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
describe the keyword **this**
a keyword that is used as a self reference to the object it is being used in
26
describe **abstraction**
this is the idea of ignoring the details of parts of the problem and look at them from a higher level example (a car engine is made up of thousands of parts but with abstraction we can ignore the details and say that we have an engine the details are not important for the higher level view)
27
describe the java boolean operator **OR**
1. symbol: || 2. function: A || B - if A OR B is true then the result is true
28
describe the java boolean operator **AND**
1. symbol: && 2. function: A && B - if A AND B are true the result is true
29
this is where we have used the same variable name twice and in such a way that they conflict, In general when this occurs the definition from the closest enclosing block is used
describe the meaning of **name overloading**
30
describe the java boolean operator **NOT**
1. symbol: ! 2. function: !A - will flip the boolean A to its opposite
31
Syntax New *ClassName*(*parameters*)
what is the **syntax for the keyword new**
32
if this case occurs the compiler will match the signature of the call with the signature of the method or constructor when the match is found it is then used
how does a compiler tell which overloaded constructor or method should be used
33
how does a compiler tell which overloaded constructor or method should be used
if this case occurs the compiler will match the signature of the call with the signature of the method or constructor when the match is found it is then used
34
in what situation would the use of the **this keyword ** be useful
this can be used in situations where we have a name conflict known as name overload Example: **Field** String a; **Constructor** Public constructor (string a) { a = a } // we are setting the formal parameter a to the formal parameter a This.a = a // we are setting the field a to the formal parameter a
35
describe the java keyword **new**
this is a keyword that is used to explicitly create objects
36
what is a **qualified name**
used to make external method calls and consists of simple names separated by dots (dot notation)
37
this will 1.It creates a new object of the named class 2.It calls the constructor of that class
what two things does the keyword **new** do
38
When comparing two strings this should be used this is because 1.The == operator will compare whether two object references are pointing to the same object 2.The string.equals() checks whether the contents or state of the object match
describe why **String.equals() ** should be used over == when comparing strings
39
what is the **syntax for an internal method call**
the syntax for this type of call is **methodName(parameters)**
40
describe **overloading**
this is where a class contains a constructor or method name that is used more than once.
41
Technically the java modulo operator is a remainder operator. usually this does not matter but in the case of negative numbers it does (this will vary between programming languages) 1. Remainder operator (java) - the result is negative only if the dividend is negative (the thing being divided I.e the left operand) 2. Traditional modulo - the result has the same sign as the divisor (thing dividing by I.e the left operand)
desribe the technicality of the java modulo operator
42
this is a non-primitive data type that is defined by a class remember Variables can hold objects. in this case when we declare the variable then its type will be the class of the object
what is a **class type**
43
what is the maximum value a modulo expression can evaluate to
The result can never be higher than the right operand
44
this is an operator that works with boolean values and will produce a new boolean value depending upon the conditions
what is a **logical operator**
45
the syntax for this type of call is: **Object.methodName(parameters)**
describe the **synatx for an external method call**
46
ignore
[Glossary quiz](https://learn2.open.ac.uk/mod/quiz/view.php?id=2014894)
47
describe an **internal method call**
This is when an object calls its own methods and will use a **simple name** to make the call
48
describe why **overloading is useful**
This is useful so that an object can be initialised in different ways or perhaps a method can carry out the same task but on different data types.
49
This is useful to use in situations where we wish to roll over a number that has a limit instead of using conditions
name a situation where use of the **modulo operator** would be desired
50
1. break the problem down into its components (abstraction) 2. solve the details of those components (modularization)
in two steps how can we **solve a problem domain**
51
what is a **logical operator**
this is an operator that works with boolean values and will produce a new boolean value depending upon the conditions
52
describe the difference between **variables that hold primitive data types** VS **variables that hold class types**
the difference here is that: 1. A variable that holds a primitive data type will always hold that actual value 2. A variable that holds a class type only ever holds a reference to the object. Not the actual object.
53
[Glossary quiz](https://learn2.open.ac.uk/mod/quiz/view.php?id=2014894)
ignore
54
This is when an object calls its own methods and will use a **simple name** to make the call
describe an **internal method call**
55
1. symbol: || 2. function: A || B - if A OR B is true then the result is true
describe the java boolean operator **OR**
56
describe an **external method call**
This is when a method of an object is called from outside the object and will use a **qualified name** to make the call
57
this is where a class contains a constructor or method name that is used more than once.
describe **overloading**
58
used to make internal method calls and consists of a unique identifier
what is a **simple name**
59
describe a **class diagram**
1. These will show the classes in the program and the relationship between them. 2. This view is static since all classes and their relationships are defined in the source code and will be part of the compiled program
60
describe the **synatx for an external method call**
the syntax for this type of call is: **Object.methodName(parameters)**
61
this is an object that we have lost all references to example: Var1 = object1 // var1 holds a reference to object 1 Var2 = object2 // var2 holds a reference to object 2 Var1 = var2 // var1 is assigned the value of var2 Var1 = object2 // and so var1 holds a reference to object 2 Var2 = object2 // var2 maintains a reference to object 2
describe an **"anonymous" object**
62
the difference here is that: 1. A variable that holds a primitive data type will always hold that actual value 2. A variable that holds a class type only ever holds a reference to the object. Not the actual object.
describe the difference between **variables that hold primitive data types** VS **variables that hold class types**
63
a keyword that is used as a self reference to the object it is being used in
describe the keyword **this**
64
1. symbol: ! 2. function: !A - will flip the boolean A to its opposite
describe the java boolean operator **NOT**
65
this is the idea of ignoring the details of parts of the problem and look at them from a higher level example (a car engine is made up of thousands of parts but with abstraction we can ignore the details and say that we have an engine the details are not important for the higher level view)
describe **abstraction**
66
this is a keyword that is used to explicitly create objects
describe the java keyword **new**