*
The moose likes Beginning Java and the fly likes How many objects it would create Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How many objects it would create" Watch "How many objects it would create" New topic
Author

How many objects it would create

Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 180

After running this following program how many objects it would create on the heap:-
please explain me and thanking you
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

What is your guess on this?


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 180

I think two.but please explain me
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18508
    
  40

Originally posted by Ashok Pradhan:
I think two.but please explain me


Please explain why you think that it is two objects.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 180

Mistakenly i write that Two,but it is one because i create the object of only sub class.before that i think two because when we create an object of subclass it first initialize all the instance variable of the super class.so i think that if all the instance variable of the super class is initialized and object of class hold all its instance variables so that the object of the super class
should be created.But it is not true ,when we create the object of sub class,it hold all the instance variables of super class as well sub class instance variables and it only create the object subclass.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How many objects it would create
 
Similar Threads
Trying to access the instance variable of Class Bar from Class Foo --------- why error ?
Google Guice and factories question
somEthing related to objects
reference variables
static shamatic