-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q_47.java
92 lines (86 loc) · 1.64 KB
/
Q_47.java
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
interface Vehicle
{
public String getColor();
public int getNumbers();
public double getConsumption();
}
class TwoWheeler implements Vehicle
{
String name;
String color;
int number;
double fuelcon;
void setData(String name,String color,int number,double fuelcon)
{
this.name=name;
this.color=color;
this.number=number;
this.fuelcon=fuelcon;
}
public String getName()
{
return name;
}
public String getColor()
{
return color;
}
public int getNumbers()
{
return number;
}
public double getConsumption()
{
return fuelcon;
}
}
class FourWheeler implements Vehicle
{
String name;
String color;
int number;
double fuelcon;
void setData(String name,String color,int number,double fuelcon)
{
this.name=name;
this.color=color;
this.number=number;
this.fuelcon=fuelcon;
}
public String getName()
{
return name;
}
public String getColor()
{
return color;
}
public int getNumbers()
{
return number;
}
public double getConsumption()
{
return fuelcon;
}
}
class Q_47
{
public static void main(String args[])
{
TwoWheeler ob=new TwoWheeler();
ob.setData("Splendour","Black Blue",1490,500.12);
String name=ob.getName();
String color=ob.getColor();
int num=ob.getNumbers();
double cons=ob.getConsumption();
System.out.println("\n Name : "+name+"\n Color : "+color+"\n Number : "+num+"\n Consumption : "+cons);
FourWheeler ob1=new FourWheeler();
ob1.setData("Buggatti","Vibrant Red",9900,80000);
name=ob1.getName();
color=ob1.getColor();
num=ob1.getNumbers();
cons=ob1.getConsumption();
System.out.println("\n Name : "+name+"\n Color : "+color+"\n Number : "+num+"\n Consumption : "+cons);
}
}