Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: OBJECT declaration vs creation

  1. #1
    tomtaila is offline Member
    Join Date
    Jul 2011
    Posts
    21
    Rep Power
    0

    Default OBJECT declaration vs creation

    Hi,

    I'm at university and am about to take an exam on Java programming, one of the questions they said might come up on the exam could be: "Describe the difference between object declaration and creation."

    I'm in the middle of writing my notes in prep for the exam and I know the answer obviously but I can't put it into words. This question could easily be worth up to 10 marks of a 100 mark paper so I was wondering if anyone has a link to some well worded answer I could learn in prep for the exam?

    Thanks

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,309
    Blog Entries
    7
    Rep Power
    20

    Default Re: OBJECT declaration vs creation

    This line declares an object:

    Java Code:
    YourObject obj;
    and this line creates one:

    Java Code:
    obj= new YourObject();
    Note that declaration and creation/initialization could've been done in one line:

    Java Code:
    YourObject obj= new YourObject();
    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: OBJECT declaration vs creation

    Objects aren't declared, so the question is moot.

    db
    Tolls likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: OBJECT declaration vs creation

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Object Creation
    By Everyman in forum New To Java
    Replies: 1
    Last Post: 02-15-2012, 03:36 PM
  2. need help on object creation
    By krishanu in forum New To Java
    Replies: 3
    Last Post: 05-28-2011, 04:56 PM
  3. String Object Creation
    By indranil in forum New To Java
    Replies: 1
    Last Post: 04-13-2010, 11:30 AM
  4. object creation
    By enygma in forum Java Applets
    Replies: 0
    Last Post: 01-05-2010, 10:01 AM
  5. [SOLVED] Location of Object Declaration
    By JT4NK3D in forum New To Java
    Replies: 4
    Last Post: 05-30-2008, 03:45 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
  •