Saturday, 8 June 2013

In our last post there was concept of overloading
in this one i"ll be showing what is overriding
now what does it do
when you  inherit features of other class u inherit its functions and what so ever it contains
we can use the functions of the class from which we have inherited and change them (not their name but the task they perform) yeah just pick the function and copy it in other class and make changes in its code
just look at my code it explains what i mean
1----
this is just a simple one to show overriding
if u still dont get any thing comment below


class food
{
void eat()
{
System.out.println("thies is eat");
}
}
class duper extends food
{
void eat()
{
System.out.println("this is meat");
}
}
class fuper extends food
{
void eat()
{
System.out.println("this is veg");
}
}
class Simpleoverride{
public static void main(String arg[]){

food object=new food();
duper objec=new duper();
fuper obje=new fuper();
object.eat();
objec.eat();
obje.eat();


}
}

No comments:

Post a Comment