Overriding: if at all a
function is existing in the parent class and the same function with same
arguments we write in child class that concept is known as overriding.
public class mod1 {
          public void call() {
                   System.out.println("logic for mod1
call");       
                   }
          public void reject() {
                   System.out.println("logic for mod1
reject");
                   }
          public void dict() {
                   System.out.println("logic for dist ");
                   }
public class mod2 {
          public void call() {
                   System.out.println("logic for mod1
call");       
                   }
          public void reject() {
                   System.out.println("logic for mod1
reject");
                   }
          public void dict() {
                   System.out.println("logic for dist ");
                   }
}
TAKE NEW CLASS
mod1 m1=new mod1();
m1.call();
m1.reject();
m1.dict();
mod2 m2=new mod2();
m2.call();
m2.reject();
m2.dict();
No comments:
Post a Comment