Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By eRaaaa

Thread: Default constructor by compiler.

  1. #1
    manishdivs is offline Member
    Join Date
    Sep 2011
    Rep Power

    Default Default constructor by compiler.

    Hi All,

    I know when we do not create any constructor then compiler creates a default constructor by its own.

    But when we create a parameterized constructor and not created a default one then compiler gives an error, why is it so??

    I mean, why default constructor is not created by compiler if we create a parameterized constructor.

    Many thanks in advance.

    Thank you-Manish

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Default constructor by compiler.

  3. #3
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Rep Power

    Default Re: Default constructor by compiler.

    That the compiler does not create a default constructor has a good reason, otherwise you can create an object and maybe important variables are not initialized.
    Example: You have a Person.class and you want that an object of this class is only legal if it has a first name and a last name....
    Last edited by eRaaaa; 09-19-2011 at 06:28 PM.
    Tolls likes this.

Similar Threads

  1. Copy Default table model to another default table model?
    By greatmajestics in forum AWT / Swing
    Replies: 2
    Last Post: 04-28-2010, 04:08 PM
  2. Replies: 1
    Last Post: 03-10-2009, 02:12 PM
  3. compiler,JIT compiler & interpreter
    By gamilah in forum New To Java
    Replies: 4
    Last Post: 11-04-2008, 01:32 AM
  4. Replies: 0
    Last Post: 12-19-2007, 10:10 AM
  5. Replies: 0
    Last Post: 12-19-2007, 10:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts