-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava-Inheritance.java
More file actions
53 lines (43 loc) · 1.16 KB
/
Copy pathJava-Inheritance.java
File metadata and controls
53 lines (43 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*Inheritance: it is the feature of object oriented programming and in inheritance we can create a new class by using exiting class.The exixting class is called base class, super class or parent class and new created class is called sub class or derived class or child class.
The concept of inheritance is also known as reuseability.
E.g*/
/*
Types of Inheritance supported in java:-
1:Single Level Inheritance:-In single inheritance there is only one base class and parent class.
2:Hierarchical Inheritance:There is a single base class and multiple base class.
3:Multi-level-inheritacne:
(hybrid,multiple)
Note;-The private acces modifier dose not participent in inheritance.
*/
class A
{
}
class extends A //extends is a keyword
{
}
*/
class RunDog
{
public void bark()
{
System.out.println("Moti.............");
System.out.println("Bho......Bho........");
}
}
class BullDog extends RunDog
{
public void grawl()
{
System.out.println("Tuffy......................");
System.out.println("Grawl.......");
}
}
class TestDog
{
public static void main(String... args)
{
BullDog dog=new BullDog();
dog.bark();
dog.grawl();
}
}