Results 1 to 5 of 5

Thread: Constructors in Java help

  1. #1
    Join Date
    Jan 2012
    Posts
    12

    Constructors in Java help

    Please I really need to know what is a constructor? How do you differentiate between a constructor and a default constructor? Can someone please explain in detail, because I can't seem to find any info on the web. Thank you.

  2. #2
    Join Date
    Jan 2006
    Posts
    605

    Re: Constructors in Java help

    Normally, constructor in java is a special method that is used to initialize a newly created object and is called just after the memory is allocated for the object. It can be used to initialize the objects ,to required ,or default values at the time of object creation.

  3. #3
    Join Date
    Dec 2009
    Posts
    7

    Post Re: Constructors in Java help

    Constructor is similar to a function which u have declared in the class except it does not have return type and it cannot be static in java. Constructor is used to initialize an object becoz

    * Constructor is automatically invoked when ever object is created..
    * Calling constructor will initialize a default values to a non static member variables in the class..


    Default constructor is one type of constructor which does not have parameters(arguments)..

    EG:
    class first
    {
    // Default Constructor
    first()
    {

    }
    }

  4. #4
    Join Date
    Aug 2011
    Posts
    2,180

    Re: Constructors in Java help

    Constructors are used to initiate the object parameter. Some default values will be given to the parameters whenever that class is called. So it is very important to use deconstructor, every time you make use of Constructors .

  5. #5
    Join Date
    Jul 2011
    Posts
    1,795

    Re: Constructors in Java help

    Normally the constructor is the block of statements, that get executes as soon as the instance of class is created. it normally used for initializing the variables.
    Some of the useful property of constructor are as follow:
    • The constructor can be non-parametrized (//Also known as default constructor) and parametrized constructor.
    • The constructor don't have any return type.
    • The Class name and the constructor name should always be same.
    • We can also execute the super class constructor with the help of super keywords.
    • The constructor can't be execute with the help of object.

Similar Threads

  1. what are constructors in C++?
    By Asis in forum Software Development
    Replies: 4
    Last Post: 29-12-2010, 08:38 AM
  2. Constructors and Destructors in PHP
    By garfield1 in forum Software Development
    Replies: 4
    Last Post: 02-03-2010, 11:01 PM
  3. Does anyone know about virtual constructors and destructors?
    By Ram Bharose in forum Software Development
    Replies: 5
    Last Post: 08-02-2010, 01:57 PM
  4. What are the Constructors and Destructors?
    By RupaliP in forum Software Development
    Replies: 4
    Last Post: 27-02-2009, 07:03 PM
  5. Overloading Constructors in Core Java
    By Cool_Rahul in forum Software Development
    Replies: 1
    Last Post: 23-12-2008, 07:17 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,649,944.44612 seconds with 17 queries