-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAbstract_class.java
More file actions
19 lines (15 loc) · 1.11 KB
/
Abstract_class.java
File metadata and controls
19 lines (15 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
What is abstract class
When the class is declared with abstract keyword then it is called abstract class.
Syntax
abstract class A{
}
The advantage of the abstract class is that,
1. The object is not created of the abstract class it will give compilation error. To access the abstract class we will extends or inherit the abstract class into normal class so that all the properties of abstract will point by its sub class.
2. The abstract method may or may not contain the method .
3. It can have abstract and non abstract method.
4. To use abstract class we have to inherit it into subclass .
5. If the class contain partial implementation then we should use the abstract class.
6. Abstract class does not contain body of the method declaration is allowed. By making body it doesn't help or get us output thats why .
7. Abstract class is used to shows similar action but it's implementation is different for example dog and tiger both eat but it's eating style or action is different so instead of creating two different eat method we can create abstract class and abstract method in it and can access using inheritance.
*/