Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Inheritance in Java Inheritance in Java Everything Inherits from Object

I don't understand how my solution is incorrect

how do I equate two objects?

Can you post your solution (and the question)?

1 Answer

Fatemah Tavakoli
Fatemah Tavakoli
13,797 Points

This task is trying to demonstrates class and inheritance in OOP. Meaning one class is allow to inherit the features(fields and methods) of another class.

class Toaster {
  void makeToast() {
    System.out.println("Toasted!");
  }
} 
class Duck extends Toaster {
  void quack() {
    System.out.println("Quack!");
  }
} 

The super class in our case is the Toaster. and Duck inherits from the Toaster class. (Since Duck extends Toaster) We are reusing the attributes and methods of the existing class(Toaster) when we are creating the new class(Duck). meaning the Toaster is the parent class of the Duck class. so it is true: "A Duck is a Toaster".

Check this link for more detailed explanation: https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html

Hope it helps! :)