- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethod_overinding.java
More file actions
Latest commit
43 lines (35 loc) · 1.15 KB
/
Copy pathmethod_overinding.java
File metadata and controls
43 lines (35 loc) · 1.15 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
//method overriding me same method 2 class me hti hain
//methd overloading me same methdd same class me hoti hai arguments unke alag alag hoti hai
/// IF CHILD CLASS IMPLIMENT THE SAME METHOD PRESENT IN THE PARENTS CLASS THEN IT IS METHOD OVERRINDING
//static method , final method kom override mahi kar sakte ]
classa
{
publicintmeth1()
{
return4;
}
publicvoidmeth2()
{
System.out.println(" i am a meth 2 of class a");
}
}
classbextendsa{
@Override//override ho rahi hai isiliye @override likh sakte hai ,, nahi likhenge tab bbhi chalega
publicvoidmeth2() //same method hai but 2 class me
{
System.out.println(" i am a meth 2 of class b");
}
publicvoidmeth3()
{
System.out.println(" i am a meth 3 of class b");
}
}
publicclassmethod_overinding {
publicstaticvoidmain(String[] args) {
aa1 = newa();
a1.meth2();
bb1 = newb(); // meth 2 ko b se bhi call karte hai;;;
// b1.meth2();
b1.meth2();
}
}