Java Inheritance
Animal Class::
package Inheritance;
public class Animal {
private String eat,sleep;
public String getEat() {
return eat;
}
public void setEat(String eat) {
this.eat = eat;
}
public String getSleep() {
return sleep;
}
public void setSleep(String sleep) {
this.sleep = sleep;
}
}
package Inheritance;
public class Dog extends Animal {
private String bark;
public String getBark() {
return bark;
}
public void setBark(String bark) {
this.bark = bark;
}
}
package Inheritance;
public class Human extends Dog {
private String shout, Study;
public String getShout() {
return shout;
}
public void setShout(String shout) {
this.shout = shout;
}
public String getStudy() {
return Study;
}
public void setStudy(String Study) {
this.Study = Study;
}
void displayinformation(){
System.out.println(getEat());
System.out.println(getSleep());
System.out.println(getBark());
System.out.println(getShout());
System.out.println(getStudy());
}
}
RunInheritence main Class::
package Inheritance;
public class RunAnimalClass {
public static void main(String[] args) {
Human Hm = new Human();
Hm.setEat("Every Animal are Eatting Food");
Hm.setSleep("Eevery Animal get sleep");
Hm.setBark("dog Bark");
Hm.setShout("Human Shout");
Hm.setStudy("Human Study");
Hm.displayinformation();
}
}
Animal Class::
Animal Class::
Animaldddddd Class::
Animal Class::
No comments:
Post a Comment
I am Safiqul Islam Tuhin