Saturday, May 30, 2015

Inheritance

package inhertance;

public class SuperCLass {

public String name;

public static void main(String[] args) {


}
}

---------------------------------------------------------------------------------------------------

package inhertance;

// INHERITANCE: Inheritance is used to inherit the properties and methods from super class to its child class

public class SubClass extends SuperCLass{

public String classes;
public static void main(String[] args) {
SuperCLass sup = new SuperCLass();
sup.name = "binn";
SubClass sub = new SubClass();
sub.name = "This is the inherit properties from parent";
sub.classes = "This is its own property";
System.out.println(sub.name);
System.out.println(sub.classes);
}
}


No comments:

Post a Comment