public class DogMethodConstructor {
String name;
String color;
String leg;
String weightage;
public DogMethodConstructor(){
System.out.println("welocme default constructor in java");
}
public DogMethodConstructor(String name,String color,String leg,String weightage){
this();
this.name=name;
this.color=color;
this.leg=leg;
this.weightage=weightage;
}
public void display(){
System.out.println("Name is:"+name+"\nColor is:"+color+"\nleg is:"+leg+"\nWeightage is:"+weightage);
}
public void bark(){
System.out.println("Puppy is bark");
}
public void run(){
System.out.println("And run fast than people");
}
public void eat(){
System.out.println("And he is eat something");
}
public void rakesh(){
System.out.println("hii rakesh");
}
public static void main(String[] args) {
DogMethodConstructor dg=new DogMethodConstructor("Puppy","brown","four leg","20kg wt");
dg.display();
dg.bark();
dg.eat();
dg.run();
}
}
No comments:
Post a Comment