1Sometimes we may come across a situation where we cannot provide
2implementation to all the methods in a class. We want to leave the
3implementation to a class that extends it. In such case we declare a class
4as abstract.To make a class abstract we use key word abstract.
5Any class that contains one or more abstract methods is declared as abstract.
6If we don’t declare class as abstract which contains abstract methods we get
7compile time error.
8
9 1)Abstract classes cannot be instantiated
10 2)An abstarct classes contains abstract method, concrete methods or both.
11 3)Any class which extends abstarct class must override all methods of abstract
12 class
13 4)An abstarct class can contain either 0 or more abstract method.
1
2interface human {
3 void dothings();
4 void eatthings();
5 void sleep();
6}
7abstract class student implements human {
8 public void dothings()
9 {
10 System.out.println("doing something");
11 }
12 public void eatthings()
13 {
14 System.out.println("eating something");
15 }
16}
17class basisstudent extends student {
18 public void sleep()
19 {
20 System.out.println("no");
21 }
22}
23public class Main {
24 public static void main(String[] args)
25 {
26 basisstudent you = new basisstudent();
27 you.dothings();
28 you.eatthings();
29 you.sleep();
30 }
31}
32