Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is Inheritance

 
Fred Man
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is Inheritance in respect of classes. Can you give an example of code or give me an article Thank you

Just wanana say you people are excellent and this time in the subject I stated the subject I am going to discus about
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inheritance involves creating new class definitions by absorbing the characteristics of existing classes and adding additional functionality. Inheritance is a very useful tool since we build on class definitions that are presumably well-defined and tested and don't have to rewrite code.
 
Fred Man
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK Good, now I know what is it one of the keyword is used for inheritance is extend what does this mean
 
Dani Atrei
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You define which is the subclass and which is the super class.

class Car extends Vehicle

Car = subclass
Vehicle = superclass
[ December 26, 2005: Message edited by: Dani Atrei ]
 
u johansson
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you extend a class you inherit both a type and an implementation.

If you implement an interface you inherit a type only.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic