-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractEx.java
More file actions
36 lines (35 loc) · 987 Bytes
/
AbstractEx.java
File metadata and controls
36 lines (35 loc) · 987 Bytes
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package oops;
/**
*
* @author Sunilshetty
*/
/*abstraction: process of hiding certain details and showing only essential information to the user
1.Abstract class: restricted class cannot used to create objects
2.Abstract method: can only be used in abstract class and it does not have body. The body is provided by sub class
*/
abstract class AbstractEx {
public abstract void animalsound();
public void sleep()
{
System.out.println("Zzzz......");
}
}
class Cat extends AbstractEx{
public void animalsound()
{
System.out.println("The Cat says meow meow...");
}
}
class MainClass1{
public static void main(String[]args)
{
Cat myCat=new Cat();
myCat.animalsound();
myCat.sleep();
}
}