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)
How Many Objects Are Created?
Gowher Naik
Ranch Hand
Posts: 643
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public class Test14{ static String s ="Instance"; public static void main(String a[]){ Test14 t = new Test14(); s = "New Instance"; String s = "Local"; method(Test14.s); System.out.println(s); System.out.println(Test14.s); } public static void method(String s){ s+="Add"; System.out.println(s); } }
How many objects are created in above piece of code
According to me there are 5 objects created as follows
Ref Objects ------ ---------- "Instance" s--> "New Instance" s--> "Local" //(inside main) "Add" //(inside method named method) s--> "New Instance Add" //(inside method named method)
Thanks
Aum Tao
Ranch Hand
Posts: 210
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
How many objects are created in the above code?
I think, you forgot t in Test14 t = new Test14();
[ July 29, 2006: Message edited by: Aum Tao ]
SCJP 1.4 85%
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Javabeat mock 2, question 14
String variables in static method
Please explain me answer. (static)
code
can anyone explain this
More...