package overriding;
/**
*
* @author Aravind Sankaran
*/
public class SubClass extends SuperClass{
public static void main(String args[]){
SubClass subClass=new SubClass();
subClass.display();
subClass.display(10);
}
int x;
void display(){
System.out.println("inside display() of SubClass");
}
void display(int x){
this.x=x;;
System.out.println("inside display("+x+") of SubClass");
}
}
class SuperClass{
int x;
void display(){
System.out.println("inside display() of SuperClass");
}
void display(int x){
this.x=x;;
System.out.println("inside display("+x+") of SuperClass");
}
}
Output:
inside display() of SubClass
inside display(10) of SubClass
/**
*
* @author Aravind Sankaran
*/
public class SubClass extends SuperClass{
public static void main(String args[]){
SubClass subClass=new SubClass();
subClass.display();
subClass.display(10);
}
int x;
void display(){
System.out.println("inside display() of SubClass");
}
void display(int x){
this.x=x;;
System.out.println("inside display("+x+") of SubClass");
}
}
class SuperClass{
int x;
void display(){
System.out.println("inside display() of SuperClass");
}
void display(int x){
this.x=x;;
System.out.println("inside display("+x+") of SuperClass");
}
}
Output:
inside display() of SubClass
inside display(10) of SubClass
No comments:
Post a Comment