CJCoding With Joseph
15free / daySign inCreate account

Thompson Rivers University

Question 1

Lab 2 Polymorphism - SM 2025

If the class Utensil is declared as abstract, with Fork, Knife, and Spoon as its child classes, are the following declarations legal? Why or why not?

1. Utensil myFork;
2. Utensil mySpoon = new Utensil();
3. Knife myKnife = new Utensil();
4. Spoon mySpork = new Fork();

You're told that Utensil is an abstract class, and that Fork, Knife, and Spoon are classes that extend Utensil.

Members only

Keep reading this lesson

You've reached the end of the free preview. Unlock the rest of this lesson plus 54 more lessons in Thompson Rivers University.

  • Unlimited coding questions
  • Unlimited access to all classroom material
  • Weekly live call for questions and guidance
  • 3,000 AI tutor tokens / month
  • Personal SQL database (3 MB)
  • Progress tracking

Cancel any time.