Need help with a this statement question | beginner
Hey guys Im a beginner in Java and I have a question regarding constructors and inheritance. If I have a constructor in a subclass am I able to use a this statement in a constructor and a super() in the next constructor?
22 Replies
β
This post has been reserved for your question.
Hey @v! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
Yes
You can do this
This message has been formatted automatically. You can disable this using
/preferences
.The age variable is only accessible through the any object of the child class (subclass) only and not in any object of the parent class
Say I have two constructors, and the first constructor does not have super() defined, but it has a this statement defined, will it run the next Constructor?
If you have multiple methods in the same class with the same name, which method will run depends on which order of parameters you gave so lets say this:
This message has been formatted automatically. You can disable this using
/preferences
.Now if i did this:
Child myChild = new Child("NAME");
the first constructor will work
How ever if i did this:
Child otherChild = new Child(8);
The second constructor will run
Sorry typing is not the best and im slown im just on phone
Dw you're good
So if u have multiple methods with the same name which one will run depends on you order the arguments in the constructor call or method call
I recommend learning through codecademy's learn java course
I am
86% done
Great job
Thank you, it's been fun
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Also i recommend watching code with john on youtube for oop
I am watching
Kevin something
I forgot his name
let me see
Lol
Alex Lee
Im watching Alex Lee, and Bro Code lol
Bro code is amazing but takes long to explain sometimes
Best of them all specificly for java is coding with john
He explains ssoooo simply and clearly and in 3-12 minute videos
If you have any other questions DM meπ
bet π
π€
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Hack ?
Pay 10 dollars for unban hack
π€
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.