Chapter 4 - In person class notes Flashcards

1
Q

What will we learn in this chapter? (what are the topics in Chapter 4)

A
  • class definitions
  • instance data
  • encapsulation and java modifiers
  • method declaration and parameter passing(movement, multiple files and multiple methods)
  • constructors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Can a class can have data declarations and method declarations?

A

Yes. We’re going to have 1 class per file. Data declarations used throughout, and MULTIPLE METHODS.

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

Does an object have a state and behavior?

A

The state of the clock is hanging on the wall and shows 5 pm. The behavior of the clock is ticking and changes the state of the clock time.

The data and variables are the state. The method are the behaviors.

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

Consider how a six-sided die can be an object?

A

The state is which side is showing up. The behavior is that it can be rolled. Our die class.

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

What is the mother of all objects in java?

A

OBJECT and all classes are descendants of that object.

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

What do descendants do?

A

They INHERIT (get) everything from the Object super class object.

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

What’s good about the toSTRING method?

A

It’s always important to have one. System.Out is always going to call out the toString() method. The return method should always return the STATE of the object which is the return value faceValue of the die.

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

What do you want to include in the tostring() method?

A

Everything that you want to print, any variable.

public String toString()
{
return “Face Value of the Die: “ + faceValue + “ It is color “ + color;
}

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

What does + indicate in the UML (unified model language)?

A

It indicates the method is PUBLIC.

+ main (args : String[]) : void

variable : object
return type for the method is VOID.

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

What’s included in the class box of the UML?

A
class box has a:
1- Class Name
2- Variables (visibility varName : type)
3- Methods (visibility, method name (parameter name type)

+ Die (void) : constructor

+ means it’s Public Name=die, Void = it does not accept parameters, constructor = does not return.

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

What software will you use to accomplish UML Goals?

A

DOWNLOAD violet UML editor files> .jar file

under

https://sourceforge.net/projects/violet/

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

Why do we not use floats that often, and instead use doubles?

A

Because there are syntax issues with floats.

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

Why do we always need to be conscious of narrowing conversions, widening and auto-promotion?

A

Because anything can be made into an object.

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