From b04cc579a6a323dfdb1b4364f416b09cc1778eaa Mon Sep 17 00:00:00 2001 From: Harsh Nayak <35399306+harshnayak97@users.noreply.github.com> Date: Sat, 24 Nov 2018 07:21:32 +0530 Subject: [PATCH] add syntax of inheritance to article (#23396) * add syntax of inheritance to article add the simple syntax of inheritance before the actual example . * Fixed formatting --- guide/english/java/inheritance/index.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/guide/english/java/inheritance/index.md b/guide/english/java/inheritance/index.md index 9bb92e7805..672c0586a1 100644 --- a/guide/english/java/inheritance/index.md +++ b/guide/english/java/inheritance/index.md @@ -20,6 +20,19 @@ Java inheritance refers to the ability of a Java Class to `inherit` the properti Thus, inheritance gives Java the cool capability of _re-using_ code, or sharing code between classes! +## Syntax +```java +class Subclass-name extends Superclass-name +{ + //methods and fields +} +``` + +The extends keyword indicates that you are making a new class that derives from an existing class. The meaning of "extends" is to increase the functionality. + +In the terminology of Java, a class which is inherited is called a parent or superclass, and the new class is called child or subclass. + + Let's describe it with the classic example of a `Vehicle` class and a `Car` class : ```java