Question: Extending Classes With Final Variables Create a new class called PhoenixShip that extends Spaceship. Try to set the alliance class variable to Blue as follows:


Extending Classes With Final Variables Create a new class called PhoenixShip that extends Spaceship. Try to set the alliance class variable to "Blue" as follows: public static String alliance = "Blue"; That works! Why is that the case? Technically, this variable is PhoenixShip.alliance. The Spaceship.alliance variable has not changed. To demonstrate this, try adding this method. public static void changeSpaceshipAlliance() \{ Spaceship. alliance = "Blue"; Java will complain. So, when you are adding an alliance constant in the PhoenixShip class, the variable you are defining is: PhoenixShip.alliance. It's a different variable
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
