-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritancemid.java
More file actions
50 lines (47 loc) · 1.14 KB
/
Copy pathinheritancemid.java
File metadata and controls
50 lines (47 loc) · 1.14 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
40
41
42
43
44
45
46
47
48
49
50
//Demonstrate the inheritance concept by individual program
import java.util.*;
class abhi
{
void riya()
{
System.out.println("the cutest girl of class");
}
}
class area extends abhi
{
Scanner a=new Scanner(System.in);
void square()
{
System.out.println("enter the sides of square:");
int s=a.nextInt();
int b=s*s;
System.out.println("the area of square is:"+b);
}
void rectangle()
{
System.out.println("enter the length and breadth of square:");
int l=a.nextInt();
int b=a.nextInt();
int c=l*b;
System.out.println("the area of square is:"+c);
}
}
public class inheritancemid
{
public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
System.out.println("User Menu:");
System.out.println("1.Area");
System.out.println("2.Rectangle");
int ch=s.nextInt();
switch(ch)
{
case 1:
area abh=new area();
abh.riya();
abh.square();
abh.rectangle();
}
}
}