Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Daniel Lawson
- 9.1 evens
- 2. Overloading is when you have two methods with the same name in a class but wih different parameters.
- Overiding is creating a method that already has the same name in the parent class.
- 4.
- a, b, c, d are legal
- 9.2
- 6.
- It can call the set age method but the age and name fields are private so it cannot directly refer to it.
- 8.
- public void setAge(int age){
- super.setAge(age);
- year++;
- }
- 10.
- outputs:
- vroomvroom
- truck 1
- car 1
- 9.3
- 12.
- flute
- shoe 1
- flute 2
- flute
- blue 1
- flute 2
- moo
- moo 1
- moo 2
- moo
- blue 1
- boo m2
- 14.
- squid
- creature 1
- tentacles
- BIG!
- spout
- create 2
- ocean-dwelling
- create 1
- create 2
- ocean-dwelling
- warm-blooded
- creature 2
- 16.
- Bay 1 Pond 2
- Ocean 2
- Lake 3 Ocean 2
- Pond 1
- Pond 2
- Pond 3
- Pond 1
- Pond 2
- Pond 3 Pond 2
- Bay 1 Pond 2
- Bay 2
- Lake 3 Bay 2
- 18.
- In a "is-a" relationship one class extends another, in a "has-a" relationship one class uses another class as a field.
- You declare the object like you would a normal field.
- 20.
- It is a bad design because you have to create so many different classes. Instead you could make one class for a generic card
- and then possibly have another class called deck with stores large amounts of cards.
- 9.5
- 22.
- Implementing an interface allows for a class to be manipulated in the client class similar to if it was extending a client,
- except it does not inherent methods and fields.
- 24.
- interfaecs can't have fields or have actual methods
- correct interface:
- public interface Colored{
- public Color getColor();
- }
- 26.
- // in shape
- public int getSideCount();
- //in triangle
- public int getSideCount(){
- return 3;
- }
- // in rectangle
- public int getSideCount(){
- return 4;
- }
- //in circle
- public int getSideCount(){
- return 0;
- }
- 9.6
- 28.
- The OrdereredByLength class has the GetElement method which it inherented and it also must have a arrange method because it was abstracted in the inherited class
Advertisement
Add Comment
Please, Sign In to add comment