Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  Cons
Language: JAVA
Code:
class Cons
{
     private int sId;
     private String sname;

     Cons()
     { 
          System.out.println("inside default");
     }

     Cons(int sId,String sname)
     {
          this.sId=sId;
          this.sname=sname;
          this.display1();
     }
     public void display()
     {
               System.out.println("sId: "+sId+" sname: "+sname);
     }
     public void display1()
     {
               System.out.println("sId: "+sId+" sname: "+sname);
     }

     

}
class Constructor1
{
     static public void main(String args[])
     {
          //Cons cObj2=new Cons(1001,"syam");
          //cObj2.display();
          //cObj2.display1();

          Cons cObj=new Cons();
          cObj.display();

          Cons cObj1=new Cons(1002,"prasad");
          cObj1.display();
     }
}     
Comments: