Mastering the static block

  • 8
  • Locked
Let's create Plane and Helicopter classes that implement the CanFly interface. Then in the Solution class's static method, we need to read a String from the console. If it's equal to "helicopter" ("plane"), we'll assign a Helicopter (Plane) object to the static CanFly field result. In the static block, initialize the CanFly field result by calling the reset method.
You can't complete this task, because you're not signed in.
Comments (1)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Adam Odoj
Level 22 , Poland
25 July 2022, 23:00
I wrote it with switch statement instead of "if-else" as suggested. Looks cleaner then the suggested version and just passed a test!