-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstract1.java
More file actions
40 lines (38 loc) · 810 Bytes
/
Copy pathAbstract1.java
File metadata and controls
40 lines (38 loc) · 810 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
37
38
39
40
import java.util.*;
abstract class Roundshape
{
double radius;
final double pi=3.14;
abstract void findarea();
abstract void findvolume();
void display()
{
System.out.println("This is an example of abstract class.");
}
}
class sphere extends Roundshape
{
Scanner sc=new Scanner(System.in);
void findarea()
{
System.out.println("Enter radius:");
radius=sc.nextDouble();
System.out.println("Area of sphere is "+4*pi*radius*radius);
}
void findvolume()
{
System.out.println("Enter radius:");
radius=sc.nextDouble();
System.out.println("Volume of sphere is "+(4/3)*pi*radius*radius*radius);
}
}
public class Abstract1
{
public static void main(String[] args)
{
sphere s=new sphere();
s.display();
s.findarea();
s.findvolume();
}
}