• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unreachable Objects

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have come across this question in one of the mock tests(I don not remember the chioces). Could anybody help?
What is a UnReachable Object? What are its charateristics?
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Java the scope is determined by the placement of the curly brackets ({})
Consider the following examples:
FOR PRIMITIVES
{
int i = 10;
/* Only i is available */
{
int j = 100;
/* both i and j are available */
}
/* Only i is avaialble and j is out of scope */
}
/* Both i and j are out of scope */
Thus variable defined within the scope is available only till the end of that scope.
FOR OBJECTS
In the case of Java objects, it hangs out past the end of the scope. Thus if you have:
{
String str = new String ("Javaranch");
} /* end of the scope */
Reference str is invalid at the end of the scope. However, String object whose reference was str is still occupying the memory. Thus when a reference to an object goes past its scope, the object is said to be unreachable.
Regards,
Milind


[This message has been edited by Milind Kulkarni (edited August 30, 2000).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic