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
Q

describe the keyword
this

A

a keyword that is used as a self reference to the object it is being used in

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

describe
abstraction

A

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)

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

describe the java boolean operator
OR

A
  1. symbol: ||
  2. function: A || B - if A OR B is true then the result is true
28
Q

describe the java boolean operator
AND

A
  1. symbol: &&
  2. function: A && B - if A AND B are true the result is true
29
Q

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

A

describe the meaning of
name overloading

30
Q

describe the java boolean operator
NOT

A
  1. symbol: !
  2. function: !A - will flip the boolean A to its opposite
31
Q

Syntax
New ClassName(parameters)

A

what is the
syntax for the keyword new

32
Q

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

A

how does a compiler tell which overloaded constructor or method should be used

33
Q

how does a compiler tell which overloaded constructor or method should be used

A

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
Q

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

A

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
Q

describe the java keyword
new

A

this is a keyword that is used to explicitly create objects

36
Q

what is a
qualified name

A

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

37
Q

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

A

what two things does the keyword
new
do

38
Q

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

A

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

39
Q

what is the
syntax for an internal method call

A

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

40
Q

describe
overloading

A

this is where a class contains a constructor or method name that is used more than once.

41
Q

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)
A

desribe the technicality of the java modulo operator

42
Q

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

A

what is a
class type

43
Q

what is the maximum value a modulo expression can evaluate to

A

The result can never be higher than the right operand

44
Q

this is an operator that works with boolean values and will produce a new boolean value depending upon the conditions

A

what is a
logical operator

45
Q

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

A

describe the
synatx for an external method call

46
Q

ignore

47
Q

describe an
internal method call

A

This is when an object calls its own methods and will use a simple name to make the call

48
Q

describe why
overloading is useful

A

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
Q

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

A

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

50
Q
  1. break the problem down into its components (abstraction)
  2. solve the details of those components (modularization)
A

in two steps how can we
solve a problem domain

51
Q

what is a
logical operator

A

this is an operator that works with boolean values and will produce a new boolean value depending upon the conditions

52
Q

describe the difference between
variables that hold primitive data types
VS
variables that hold class types

A

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
A

ignore

54
Q

This is when an object calls its own methods and will use a simple name to make the call

A

describe an
internal method call

55
Q
  1. symbol: ||
  2. function: A || B - if A OR B is true then the result is true
A

describe the java boolean operator
OR

56
Q

describe an
external method call

A

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
Q

this is where a class contains a constructor or method name that is used more than once.

A

describe
overloading

58
Q

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

A

what is a
simple name

59
Q

describe a
class diagram

A
  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
Q

describe the
synatx for an external method call

A

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

61
Q

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

A

describe an
“anonymous” object

62
Q

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.

A

describe the difference between
variables that hold primitive data types
VS
variables that hold class types

63
Q

a keyword that is used as a self reference to the object it is being used in

A

describe the keyword
this

64
Q
  1. symbol: !
  2. function: !A - will flip the boolean A to its opposite
A

describe the java boolean operator
NOT

65
Q

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)

A

describe
abstraction

66
Q

this is a keyword that is used to explicitly create objects

A

describe the java keyword
new