Test 2 Flashcards
The main difference between static variables and instance variables are?
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.
What is the difference between overriding and overloading methods?
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 do you check the length of an array?
arrayName.length;
how do you normally get and set an index of a array of objects?
by using that objects getter and setter method. ie. passengers[0].getName()
or
passenger[2].setName(“sally”)
How do you create a child class?
Public class Owner extends Human{ }
How would you create an array of circle objects?
Circle[] circles = new Circle[];
What is involved in creating a button that executes when clicked?
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 do you create a new button object with nothing else other than a name on it?
Button b = new Button(“Press Me!”);
How do you root that button?
root.getChildren().add(b);
how do you initialize an action to call on the button handler?
b.setOnAction(this::setBtnHandler);
how do you create the event handler method?
Private void setBtnHandler (ActionEvent e) { system.out.println(“Hello World!”)
}
how do you adjust the x and y coordinates of objects you have created in your gui?
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 do you display association arrows and what do they look like?
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 do you display arrows to parent classes and what do they look like?
They are closed ended arrows, and the child class points the arrow at the parent class.
how to static variables work?
you can call on those methods without having to create the object rather use the class name.