Introduction to Classes Flashcards

1
Q

In order to create an object, we need a

A

constructor method

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

How do you create an instance?

A

Call the constructor within the main()
Example: Car ferrari = new Car();

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

For Car ferrari = new Car();, what type of data type is Car

A

A reference data type

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

How to add data to an object

A

Introduce instance variables

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

How to asign an instance variable something

A

Add a constructor and pass a parameter through

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

Formal Parameter

A

Specifices the type and name of data that can be passed into the method

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

Argument

A

The values passed in through method calls
Example: Car ferrari = new Car(“red”);
red is the argument

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

How to access a field

A

Using the dot operator
Ex: ferrari.color

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

How to use objects as parameters

A

public Bakery (Cupcake cupcakeType, double priceOf)

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

If you modify an object in another method, it will

A

change that object outside the method

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

What is a copy constuctor?

A

Will copy a reference object:
public Cupcake(Cupcake copy) {
flavor = copy.flavor;
sprinkles = copy.sprinkles;
}

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