How to use EXTENDS Keyword in Java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

How to use EXTENDS Keyword in Java?

Hello guys, If I have these classes: Student class, Undergraduate class, Postgraduate class, Address class, Course class, and Faculty class What are the categories that I should inherit from the others? With the keyword extends, I wish you could write it for me as: Student extends Course like this...

2nd Apr 2021, 11:18 AM
Lisa John
Lisa John - avatar
12 Answers
+ 6
Lisa John , this is explained in the java tutorial in the oop section. so please be patient until you have a bit more experience. and please remember, that we are NOT writing a code for you. but if you put your attempt in playground and link it here, you will get help from the community thanks for your understanding!
2nd Apr 2021, 11:24 AM
Lothar
Lothar - avatar
+ 2
I can't arrange it if you can arrange it for me please. Zainul Khan
2nd Apr 2021, 11:24 AM
Lisa John
Lisa John - avatar
+ 2
Thx Lily Mea 💜💜
2nd Apr 2021, 11:37 AM
Lisa John
Lisa John - avatar
+ 1
Lothar I am learning programming at the university and I downloaded this application to get help from the community members who understand more than me so I just hope you can help me by giving me simple hints and I am now working on my project and I don’t want to mistake it or spend more time writing it please understand me I just need pencil tips to get I understand it because I know what the relationship is between them, please help me and thank you
2nd Apr 2021, 11:29 AM
Lisa John
Lisa John - avatar
+ 1
just hint ,cause i dont know how these classes work for ur code extends keyword expects a base-derived class relationship, which mean one class(derived) extends other class'(base) functionalities and properties..you can find out by asking yourself if the derived class is also same as it's base class but with additional functionalities or properties..if yes, then you can inherit from that base class
2nd Apr 2021, 11:32 AM
durian
durian - avatar
+ 1
3rd Apr 2021, 9:01 PM
Lisa John
Lisa John - avatar
+ 1
Undergraduate extends Student. Postgraduate extends Students. Student extends Course. Student extends Address.
4th Apr 2021, 6:50 AM
Java Developer
Java Developer - avatar
+ 1
Java Developer Student shouldn't extend Course or Address because it is a (has) relationship, a Student has Address and Course in this case you should composition instead, not inheritance. Have a good day :)
4th Apr 2021, 6:57 AM
Abdulrahman Alniema
Abdulrahman Alniema - avatar
0
Start inheriting from the lowest level to the uppermost level
2nd Apr 2021, 11:22 AM
Zainul Khan
Zainul Khan - avatar
0
You inherit a class A from another B if it has an is relationship with B => (A is B), like a Cat is an Animal and so ..
3rd Apr 2021, 7:54 PM
Abdulrahman Alniema
Abdulrahman Alniema - avatar
0
Lisa John u r welcome
3rd Apr 2021, 9:35 PM
Abdulrahman Alniema
Abdulrahman Alniema - avatar
0
Your wellcome
4th Apr 2021, 12:10 AM
Claire Nielo
Claire Nielo - avatar