Skip to content

Commit c16723a

Browse files
committed
ClassAndObjects class added
1 parent 60846bb commit c16723a

6 files changed

Lines changed: 81 additions & 8 deletions

File tree

1.08 KB
Binary file not shown.
1.33 KB
Binary file not shown.
0 Bytes
Binary file not shown.
857 Bytes
Binary file not shown.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.concepts._01oops;
2+
3+
public class ClassAndObjects
4+
{
5+
6+
public static void main(String[] args)
7+
{
8+
Parent p = new Parent();
9+
10+
Parent pc = new Child();
11+
12+
Child c = new Child();
13+
14+
p.father = "Karamchand Gandhi";
15+
p.mother = "Putlibai Gandhi";
16+
17+
System.out.println(p.father);
18+
System.out.println(p.mother);
19+
p.payFees();
20+
System.out.println();
21+
22+
pc.father = "Motilal Nehru";
23+
pc.mother = "Swaruprani Thussu";
24+
25+
System.out.println(pc.father);
26+
System.out.println(pc.mother);
27+
pc.payFees();
28+
System.out.println();
29+
30+
c.father = "Rajiv Gandhi";
31+
c.mother = "Sonia Gandhi";
32+
c.daughter = "Priyanka Gandhi Vadra";
33+
c.son = "Rahul Gandhi";
34+
35+
System.out.println(c.father);
36+
System.out.println(c.mother);
37+
System.out.println(c.son);
38+
System.out.println(c.daughter);
39+
c.payFees();
40+
c.payHospitalBillOfParents();
41+
42+
}
43+
44+
}
45+
46+
class Parent
47+
{
48+
String father;
49+
String mother;
50+
51+
public void payFees()
52+
{
53+
System.out.println(father + " will pay the fee of children");
54+
}
55+
}
56+
57+
class Child extends Parent
58+
{
59+
String son;
60+
String daughter;
61+
62+
public void payHospitalBillOfParents()
63+
{
64+
System.out.println(son + " will pay hospital bills of " + father + " and " + mother);
65+
}
66+
67+
public void payFees()
68+
{
69+
System.out.println(father + " will pay the fee of " + son + " and " + daughter);
70+
}
71+
}

src/com/concepts/_01oops/InterfaceHandaling.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
public class InterfaceHandaling implements Digital
44
{
55

6-
76
public static void main(String[] args)
87
{
98
InterfaceHandaling ih = new InterfaceHandaling();
@@ -21,7 +20,7 @@ public static void main(String[] args)
2120
public void diode()
2221
{
2322
System.out.println("diode implemented");
24-
23+
2524
}
2625

2726
@Override
@@ -35,30 +34,33 @@ public String registor()
3534
public void iChip()
3635
{
3736
System.out.println("IChip implemented");
38-
37+
3938
}
4039

4140
@Override
4241
public void dNAComputer()
4342
{
4443
System.out.println("DNAComputer implemented");
45-
44+
4645
}
4746

4847
}
4948

5049
interface Analog
5150
{
52-
String registorCode="47 kΩ";
51+
String registorCode = "47 kΩ";
52+
5353
public void diode();
54+
5455
String registor();
5556
}
5657

5758
interface Digital extends Analog
5859
{
59-
// int mirsoprocessor; can't define a variable only final constant be declared
60+
// int mirsoprocessor; can't define a variable only final constant be declared
6061
void iChip();
61-
// protected void nanoCircuit(); Only public methods can be declared
62+
63+
// protected void nanoCircuit(); Only public methods can be declared
6264
public void dNAComputer();
63-
65+
6466
}

0 commit comments

Comments
 (0)