Google+ Followers

Connect

Get Updates Via Email

Enter your email address:

Delivered by FeedBurner

Sunday, 10 November 2013

Java Program : Default and Parameterized Constructor

public class constructorexample {
    public static void main(String[] args)
    {
        personcon kumaran=new personcon();
        kumaran.display();
        personcon jannu=new personcon("Jannu",22);
        jannu.display();
    }
}

class personcon
{
    private String name;
    private int age;
    //default constructor
    personcon()
    {
        name="kumaran";
        age=23;
    }
   //parameterized constructor
    personcon(String n,int a)          
    {
        name=n;
        age=a;
    }
    public void display()
    {
        System.out.println("Name: "+name+"\t Age: "+age);
    }
}

1 comment :

  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Online Training Java EE Online Training Java EE Online Training Java 8 online training Core Java 8 online training

    Java Online Training from India Java Online Training from India Core Java Training Online Core Java Training Online Java Training InstitutesJava Training Institutes

    ReplyDelete

Share this to your friends