Create a three-level hierarchy: Animal with virtual speak(), Dog that overrides it, and TrainedDog that overrides again. Verify each level prints different output when called through Animal pointers.
Mark Dog's speak() as final. Try to override it in TrainedDog. The compiler should reject this code. Remove the override attempt and confirm the code compiles again. Create a class FinalDog marked as final that inherits from Animal.
Attempt to create a class that inherits from FinalDog. Observe the compile error preventing this inheritance.