how to extend classes
i want to extend a class, but i am unable to do this........here is my code.......plz check it n tell if there are any errors
public class MyExercise{
int e;
public void mul(int c, int d){
e = c*d;
}
public int getMul(){
return e;
}
public class ChildClass extends MyExercise{
public void childMethod(){
System.out.println("Inside Child Class");
}
}
public static void main(String args[]){
MyExercise myObj = new MyExercise();
myObj.mul(10,20);
int get = myObj.getMul();
System.out.println(get);
ChildClass obj = new ChildClass();
obj.childMethod();
}
}
|