-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractclasses.java
More file actions
39 lines (33 loc) · 1.18 KB
/
Abstractclasses.java
File metadata and controls
39 lines (33 loc) · 1.18 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
//Method Which takes the value and does not perform Anything......
abstract class Parent2{ //abstract class is the class which contains abstract method...
//Abstract classes can have both concrete and abstract functions
public Parent2(){
System.out.println("I am the constructor of this class Parent2");
}
abstract void greet();//override greet method by itself and put whatever u wanna put
abstract void lunch();
}
//Abstract class is the class via help which create another abstract classes..
class child2 extends Parent2{//Implementing inheritance and data abstraction.......
@Override
public void greet() {
System.out.println("Hi,Good mornig da how are u ,");
}
@Override
public void lunch() {
System.out.println("What do u like to have in lunch ");
}
}
abstract class child3 extends Parent2{//Either make the class abstract or override greed method
public void m() {
System.out.println("Have Some milk");
}
}
public class Abstractclasses {
public static void main(String[] args) {
//we cann't create objects of abstract class(Cannot make object of parent2)
child2 c=new child2();//concrete class
c.greet();
c.lunch();
}
}