FAQ: Inheritance and Polymorphism - Inheritance in Practice

This community-built FAQ covers the “Inheritance in Practice” exercise from the lesson “Inheritance and Polymorphism”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Java

FAQs on the exercise Inheritance in Practice

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in #get-help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to #get-help and #community:tips-and-resources. If you are wanting feedback or inspiration for a project, check out #project.

Looking for motivation to keep learning? Join our wider discussions in #community

Learn more about how to use this guide.

Found a bug? Report it online, or post in #community:Codecademy-Bug-Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

This is regarding the question in the 2nd exercise, where the parent class is ‘Noodle’ and the child class is ‘Spaghetti’.
How were we able to create an object (spaghettiPomodoro) without defining its constructor in the spaghetti class? All we did was define a class. No constructor was defined.
I searched on google and confirmed that we cannot create an object without a constructor. Is it a mistake in the IDE or am I missing something?

1 Like

Java provides a default constructor in the case if do not explicitly add one. And yes you are right about object cannot be created without constructor but the java itself defines default constructor without any parameters


What is the code this.texture means and perform in the second exercise in line 9?

“this.” refers to the class instance in question. You may have several types of spaghetti in your program, but want the texture of a specific instance.

If you’re familiar with Python, this. is analogous to self.


I’m stuck on step 3. How do I print the String, “texture,” if it’s already stated.

You are asked to create an instance of Spaghetti class in Noodle class’s main method.

Spaghetti yourNewInstance = new Spaghetti();

Each new instance of a class is an object which receives states defined in its class and its class’s parent class (inheritance). All those states become properties of each instance object. You can access them like properties.


So if Spaghetti class inherits all states and methods of its parent class (Noodle), your new instance object should have a property called ‘texture’. You can access it like this…


To print it wrap it in System.out.println().

1 Like

Can anyone help me? I’m confused. How can I call a child class from a parent one? Shouldn’t it be the other way around? (I’m talking about Step 3)