Method Overriding in java -
- यदि हम यह चाहते है की कोई object अपने response से अलग behaviour show करे तब इस method को method overriding कहा जाता है।
- हम इसके द्वारा superclass में define किये गये method को override कर सकते है ।
Examlpe -
class A
{
A (int x)
{
this .x = x;
}
void display ( ) // method define
{
System.out.println("First value is ="+x);
}
}
class B extends A
{
int y;
B(int x, int y);
{
super (x);
this y = y;
}
void display( ) // method defined
{
System.out.println ( "first value is ="+ x);
System.out.println("second value is "+y);
}
}
class C
public static void main (String args [])
{
BP = new B(10, 20);
P.display( );
}
https://Erhsmathur.blogspot.com
आपको यह post पसंद आयी हो तो
अपने दोस्तों के साथ share करे।
Thank you
NYC sir
ReplyDeletePlease support me my Blogspot is www. vishalnagar03448.Blogspot.com
ReplyDelete