Skip to content
This repository has been archived by the owner on Apr 1, 2021. It is now read-only.

Add Java Inheritance wiki #773

Merged
merged 7 commits into from
Apr 22, 2016
Merged

Conversation

koustuvsinha
Copy link
Member

Added Inheritance article as per #534. Please have a look @alayek , @Rafase282, @abhisekp

@@ -0,0 +1,168 @@
# Java Inheritance

Java inheritance refers to the ability of a Java Class to _inherit_ the properties from some other Class. Think of it like a child inheriting properties from its parents, the concept is very similar to that. In Java lingo, it is also called _extend_-ing a class. Some simple things to remember :
Copy link
Member

@alayek alayek Apr 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java Class to inherit inherit

@alayek
Copy link
Member

alayek commented Apr 22, 2016

@theflametrooper might wanna take a look for typos and all. Technically, this article is correct and code snippets work the way they are supposed to, as described in the article.

@koustuvsinha can't thank you enough!

* The Class that extends or inherits is called **subclass**
* The Class that is being extended or inherited is called **superclass**

Thus, inheritance gives Java the cool capability of _re-using_ a code, or share code between classes! Let's describe it with the classic example of a `Vehicle` class and a `Car` class :
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-using a code re-using code

@koustuvsinha
Copy link
Member Author

@alayek @theflametrooper updated the typos & implemented suggestions

}
```

Remember, if the superclass does not have any constructors defined, you dont have to call it explicitely in the subclass. Java handles that internally for you!
Copy link
Member

@abhisekp abhisekp Apr 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@koustuvsinha Also, invocation to super constructor is done in the case when the super class is to be called with any other constructor other than the default constructor.

* The Class that is being extended or inherited is called **superclass**

Thus, inheritance gives Java the cool capability of _re-using_ code, or share code between classes! Let's describe it with the classic example of a `Vehicle` class and a `Car` class :

Copy link
Member

@abhisekp abhisekp Apr 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@koustuvsinha Add a heading 2 break point here for our sweet heart 💟 @camperbot to extract up to this point for gitter chat.

Like this,

## (just add a space after the two ##)

Move the line Let's describe it with the classic example of aVehicleclass and aCarclass : after the heading.


public class Car extends Vehicle {
public Car() {
super();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the extra indentation?

@alayek
Copy link
Member

alayek commented Apr 22, 2016

LGTM 👍


If no other constructors are defined, then Java invokes the default super class constructor (*even if not defined explicitly*).

Congrats, now you know all about Inheritance! Read more about advanced ways to inherit things in [Abstract Classes]() and [Interfaces]()!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these placeholder links? Loos that way, just want to confirm. If they are, you should add the relative link that you think you would be using. When merged it will just try to create the new article but it will help you remember what to name them or give others an idea of what to name it.

@alayek alayek merged commit 8849036 into freeCodeCamp:master Apr 22, 2016
@BerkeleyTrue BerkeleyTrue removed the QA label Apr 22, 2016
waliahimanshu pushed a commit to waliahimanshu/wiki that referenced this pull request May 5, 2016
* Add Java Inheritance wiki

* Update article with suggestions

* Implement suggestions

* Minor edits

* Update with new suggestions

* Updated with new suggestions

* Add relative links
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants