GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE
Go To First  |  Previous Question  |  Next Question 
 J2EE  |  Question 56 of 104    Print  
why pointer concept not use in java?

  
Total Answers and Comments: 15 Last Update: January 26, 2009     Asked by: sunima dila 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Steve
 

A lot of this content is not accurate, so let me set the record straight here.

The Java language does _not_ provide pointers.  Instead, all objects are handled by references, not to be confused with pointers or C++ references.  The difference is that Java references do not refer directly to the memory location, but rather contain the pointer to the actual memory location, which the programmer cannot get direct access to.  This extra level of indirection is required for GC to work.  When GC kicks in and frees objects, that are no longer in use, it then does heap compaction to defragment the heap.  To do this, some objects must be moved around in memory.  This is possible because there is only one place where this pointer is located, in the reference, and thus the memory can be relocated, old location freed, and pointer changed.  In C++ this is not possible because pointers are copied all over the code.

It is also true that pointers are dangerous and lead to memory leaks, memory corruption, invalid memory access, e.g. from uninitialized and improperly initialized variables, indexing out of bounds, and many bugs due to pointer arithmetic.  References, and other features related to these, avoid all these problems.



Above answer was rated as good by the following members:
iitd.mayank
  Sorting Options  
  Page 1 of 2   « First    1    2    >     Last »  
July 29, 2006 10:19:02   #1  
nitesh yetta        

RE: why pointer concept not use in java?
memmory allocation is done automaticaly it is managed by Jvm
 
Is this answer useful? Yes | No
July 31, 2006 10:57:35   #2  
HabazalCoonya Member Since: July 2006   Contribution: 20    

RE: why pointer concept not use in java?
point is used in Teh Jav just point math is not.when u do[code]Object ob new Object();[/code]ob is a pointer to the object not the object itself.
 
Is this answer useful? Yes | No
August 02, 2006 09:25:50   #3  
santi Member Since: August 2006   Contribution: 3    

RE: why pointer concept not use in java?

Because pointers are unsafe. Java uses reference types to hide pointers and programmers feel easier to deal with reference types without pointers. This is why Java and C# shine.


 
Is this answer useful? Yes | No
August 08, 2006 05:58:37   #4  
R.seethala saravanan        

RE: why pointer concept not use in java?
because the cursor implementation concept is used in the java language.The pointer drawback is to identify and scratch the address very easily........
 
Is this answer useful? Yes | No
August 08, 2006 11:58:07   #5  
srinivasaraobora Member Since: May 2006   Contribution: 31    

RE: why pointer concept not use in java?

hi

pointers are unsafe. pointers are complecated and difficult to use.if we use these concepts that the some of the features are not correct.so java soft designed like this.

ok bye.......keep in touch

do reply

keeps smiling and mailing

bora_srinivasarao@yahoo.co.in

HELP EVER HURT NEVER & IMPOSSIBLE AS POSSIBLE

Note:If any one want java materials like e-books faq's send a mail to my id.if any doubts regarding java send a mail to my id if possible i will send answers.if any one want how to install java softwares tomcat weblogic eclipse jbuilder etc and how to use plz send amil or ask online also i will definitly tell.
see my profile by clickon below link:http://in.geocities.com/bora_srinivasarao/MyHomepage.html


 
Is this answer useful? Yes | No
August 10, 2006 10:39:59   #6  
devi        

RE: why pointer concept not use in java?
java is created for simple use.But by adding pointer it is too complex for a programmer.So only for simplicity basis pointer is not included in java.
 
Is this answer useful? Yes | No
August 13, 2006 06:53:09   #7  
pankaj        

RE: why pointer concept not use in java?
t's a common misconception that Java has no pointers. It's not exactly true. Java has pointers they're just not explicit. Every object is a reference to a location making it a pointer... you just can't manipulate the pointers directly.in Java pointers are used by passing refference not by passing address directly ..
 
Is this answer useful? Yes | No
August 31, 2006 08:55:27   #8  
hariprasad dasari        

RE: why pointer concept not use in java?

hi this is well for the student who are preparing for the interview.


 
Is this answer useful? Yes | No
September 22, 2006 00:55:15   #9  
Steve        

RE: why pointer concept not use in java?

A lot of this content is not accurate so let me set the record straight here.

The Java language does _not_ provide pointers. Instead all objects are handled by references not to be confused with pointers or C++ references. The difference is that Java references do not refer directly to the memory location but rather contain the pointer to the actual memory location which the programmer cannot get direct access to. This extra level of indirection is required for GC to work. When GC kicks in and frees objects that are no longer in use it then does heap compaction to defragment the heap. To do this some objects must be moved around in memory. This is possible because there is only one place where this pointer is located in the reference and thus the memory can be relocated old location freed and pointer changed. In C++ this is not possible because pointers are copied all over the code.

It is also true that pointers are dangerous and lead to memory leaks memory corruption invalid memory access e.g. from uninitialized and improperly initialized variables indexing out of bounds and many bugs due to pointer arithmetic. References and other features related to these avoid all these problems.


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
October 18, 2006 05:27:55   #10  
Puneet        

RE: why pointer concept not use in java?
Java Language does not use pointer for the reason that it works on Internet. Applets are used on the internet. and Pointers are used to identify the address of variables methods and therefore even big programmer can find out the secrets of other user on the internet using pointer. so if there could be pointer in java it could be harmful for leakage of the important information.
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
  Page 1 of 2   « First    1    2    >     Last »  


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape