Java - Interview Questions and Answers for 'Pointer' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Java Interview Questions


 2137 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Pointer' - 10 question(s) found - Order By Newest

 Q1. Do you think that Java should have had pointers ?Core Java
Admin
info@buggybread.com
Ans. Open ended Questions.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   open questions   pointers   advanced


 Q2. Difference between a Pointer and a Reference ?
Admin
info@buggybread.com
Ans. We can't get the address of a reference like a pointer. Moreover we cannot perform pointer arithmetic with references.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   pointer   reference   at&t


 Q3. Why Java don't use pointers ?
Anonymous
Ans. Pointers are vulnerable and slight carelessness in their use may result in memory problems and hence Java intrinsically manage their use.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   jvm   memory management   pointers      intermediate


 Q4. When does an application throw NullPointerException ?Core Java
admin
info@buggybread.com
Ans. When it tries to access an object element or method using reference which is actually null.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     exceptions   npe   nullpointerexception     EverBank Financial      basic        frequent


 Q5. How can we protect an application from throwing a NullPointerException ?
admin
info@buggybread.com
Ans. By having Null Checks.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     exceptions   npe   nullpointerexception   null checks      basic        frequent


 Q6. Doesn't it make sense to necessarily initialize references to some object to avoid NullPointerExceptions ? Can this be done ?Core Java2017-03-16 09:54:16

Ans. We can declare the reference as final to avoid reassignment but again we can always initialize the final reference to null. Even if there was any such facility available , it would have meant poor use of resources by assigning a new object in memory to each reference that's created. Many a times references are just meant to refer to other objects which already have a reference i.e sharing object by multiple references.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     null  NullPointerException


 Q7. Is it ok to use optional everywhere just to get over nullpointerexception ?Core Java2017-05-23 08:16:28

Ans. Optional is to be used for arguments / atrributes which are indeed optional i.e the request should continue even if they aren't provided. It should not be used for mandatory attributes or arguments as we would like application to shout out ( with error message / exception trace ) to signify a problem.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     optional  nullpointerexception  java8  java 8     Itech


 Q8. In Java, what is the closest thing to pointers?Core Java2017-06-23 13:16:07

Ans. References.

Unlike pointers in C , Java references are strongly typed and we cannot do pointer arithmetics with them.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     pointers  pointers in java  references     Jim Beam Luxury


 Q9. Is it a bad practice to initialize object reference to Null ?Core Java2017-07-23 19:56:17

 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     null  nullpointerexception


 Q10. Which of the following is a valid way to avoid NullPointerException ?Core Java
a. Avoid assigning null to the reference
b. Null Checks before accessing elements of an object
c. Both of the above
d. None of the above

Ans.b. Null Checks before accessing elements of an object



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: