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 PhoenixShipthat extends Spaceship. Try to set the alliance class variable to "Blue"

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!