Create a class containing three variables and also make constructors for all the available variable?
public class human
{
public int age;
public String name;
public String gender;
public human() {
this.age = 0;
this.name = "";
this.gender = "";
}
public human(int age) {
this.age = age;
this.name = "";
this.gender = "";
}
public human(int age, String name) {
this.age = age;
this.name = name;
this.gender = "";
}
public human(int age, String name, String gender) {
this.age = age;
this.name = name;
this.gender = gender;
}
public static void main(String args[])
{
human obj=new human();
human obj1=new human(3);
human obj2=new human(3,"Ali");
human obj3=new human(3,"Ali","male");
}
}
1 Comments
Thanks A Lord For Publish In Your Blog, This Is A Great Things To Learned Many Information. Keep Posting Many Blogs Like This.
ReplyDeleteWeb portal development company in chennai, Web portal development services in chennai
Your Comment is Submitted