Test 2 Flashcards

1
Q

The main difference between static variables and instance variables are?

A

Static variables are used so that each and every instance of the class will share the same variable, so that if you change it in one instance, the change will reflect in all instances, where instance variables are instance by instance.

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

What is the difference between overriding and overloading methods?

A

Overriding is when inherited methods are overridden with a new method called the same thing but with different functionality. Overloading a method is used when you want to allow a method to be more versatile in what variables and how many variables it can take.

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

how do you check the length of an array?

A

arrayName.length;

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

how do you normally get and set an index of a array of objects?

A

by using that objects getter and setter method. ie. passengers[0].getName()
or
passenger[2].setName(“sally”)

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

How do you create a child class?

A
Public class Owner extends Human{
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How would you create an array of circle objects?

A

Circle[] circles = new Circle[];

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

What is involved in creating a button that executes when clicked?

A
Button b = new Button("Press Me!");
root.getChildren().add(b);
b.setOnAction(this::setBtnHandler);
Private void setBtnHandler (ActionEvent e) { system.out.println("Hello World!")
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

how do you create a new button object with nothing else other than a name on it?

A

Button b = new Button(“Press Me!”);

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

How do you root that button?

A

root.getChildren().add(b);

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

how do you initialize an action to call on the button handler?

A

b.setOnAction(this::setBtnHandler);

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

how do you create the event handler method?

A

Private void setBtnHandler (ActionEvent e) { system.out.println(“Hello World!”)
}

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

how do you adjust the x and y coordinates of objects you have created in your gui?

A
Btn1.setLayoutX(10);
Btn1.setLayoutY(5);
lbl.setLayoutX(100);
lbl.setLayoutY(5);
txtF.setLayoutX(10);
txtF.setLayoutY(25);
Btn2.setLayoutX(100);
Btn2.setLayoutY(25);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

how do you display association arrows and what do they look like?

A

They are open ended arrows, and the class that has created an object or objects points the arrow at the objects class and has the number of objects its created if more than 1. If both have eachother then the arrows go both ways.

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

How do you display arrows to parent classes and what do they look like?

A

They are closed ended arrows, and the child class points the arrow at the parent class.

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

how to static variables work?

A

you can call on those methods without having to create the object rather use the class name.

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