Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Programmer Certification (OCPJP)
K&B Practise Exams1 Q No-4
Mansi Agarwal
Ranch Hand
Posts: 55
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi All,
Please explain me why it prints 5? As per me it should print 7.
public class Volume { 3. Volume v; 4. int size; 5. public static void main(String[] args) { 6. Volume myV = new Volume(); 7. final Volume v2; 8. v2 = myV.doStuff(myV); 9. v2.v.size = 7; 10. System.out.print(v2.size); 11. } 12. Volume doStuff(Volume v3) { 13. v3.size = 5; 14. v3.v = new Volume(); 15. return v3; 16. } }
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
do you see the difference v2.v.size and v2.size
Mansi Agarwal
Ranch Hand
Posts: 55
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Aww.. My bad.. Such a silly mistake..
Thanks..
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
arrayOutOfIndex
Help with Objects..
private static Test monitor = new Test(); -- Static + Private Object Referenc
Exception in thread "main" java.lang.NullPointerException
Help please
More...