rankz_VtujUdhflsoFhdgp Method Overriding in java - All type study material

Java programming

Java programming

About Me

my self - Harvendra Singh

Search This Blog

Wednesday, March 4, 2020

Method Overriding in java

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 

2 comments: