Help coderanch get a
new server
by contributing to the fundraiser

Ikpefua Jacob-Obinyan

Ranch Hand
+ Follow
since Aug 31, 2010
Ikpefua likes ...
Eclipse IDE Oracle Java
Merit badge: grant badges
I am a 28yr old african-spaniard, I have lived (is till living) since the last 11yrs  in Madrid Spain. I got interested in computer programming since ever, I'm 20months old in Java(& computer programming)Im currently preparing to take the OCPJP exams. I hope to become a professional developer someday.
For More
Madrid Spain
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ikpefua Jacob-Obinyan

Larsen Raja wrote:Hi,

Where would variables initialized in initialization blocks be used? Since the scope would be resolved to the block only, these variables cannot be used outside I believe.


Hello Larsen, I recommend you write a test program and do some 'trial-and-error' coding it is a good way to resolve such doubts.



Sean Keane wrote:...Unless my Servlet implements the SingleThreadModel interface - in which case I am guaranteed that only one thread will be executing a method from my Servlet class at any particular moment in time. Sounds good?

Hello Sean... I am afraid it does NOT sound good because the session and context states will be completely vulnerable!... Its like saying oh well I want to synchronize the service method.
A good solution would be;
-synchronyze sessions
-do NOT use instance variables in your Servlet (if you must, then make them 'final')



naveen yadav wrote:

Ikpefua Jacob-Obinyan wrote:

........... objects are referenced from outside the method where they where created "

suppose i have a code in which object do not referenced from outside.It is created inside the method and used inside the method.No reference to the outside

at a look

and yes i can access the nav directly but for the sake of explanation of my point using ob to i access nav .

should not it be ob stored on stack ?

Remember that 'local' variables live on the stack, while 'objects' live on the heap;
'ob' = lives on the stack
'new Jivvy()' = lives on the heap
as soon as the 'fun()' method completes, 'ob' no longer exists, hence 'new Jivvy()' becomes eligible for garbage collection.
setting 'ob' to null in this scenario is rather redundant.

naveen yadav wrote:
what about the object created inside a method shouldn't it be stored on stack ?

@Naveen to the best of my knowledge objects live on the heap. You can imagine Objects living on the stack and the objects are referenced from outside the method where they where created "we know that once a method completes execution its properties disappear from the stack... together with the objects"?... Its a simple logic that requires a minute of brain flexing...

mrs nair wrote:hi there ,
i was wondering what the output should be for the following code ,
public static void main(String[] args) {
// TODO Auto-generated method stub
int age =18;

assert(age < 18);
System.out.println("hello here......................");
surely an assertion error and the "hello here" shouldn't be displayed ..i am sorry but this dosent happen when i run it on eclipse indigo and i use jdk 1.6.0_27.can anyone figure out where's the bug?

Hello Mrs Nair... Assertions are disabled by default, if you intend to enable assertions in other for the above code to throw an assertion error, you can simply use the command lines and navigate to the .class file
or the packge directory and run the class with the -ea (enable assertions) flag, i.e 'java -ea'...



Billy Tsai wrote:so if a object that represents some data structure is created within a static method as a local variable then after the method finishes the space that object occupies should be cleared(i.e. available again) and that object is destroyed?

Hello Billy, I think Stephan has said it all, in my honest opinion it doesn't really matter if the Object represents the white house
That said if the reference to that Object is returned from the method and assigned to another reference variable, located outside
the method, then it will NOT be garbage collected (or NOT be destroyed).



Mini Sanjay wrote:Can anyone please tell, how long will it take to receive the certificate? Do I need to submit any documents in online?

I recieved mine today EXACTLY one month after I took my exams, it takes a maximum of 45 days to recieve it. To the best of my knowledge you dont need to submit any documents...I already explained in this forum... Click on the follwing link: Candidate Certification Information


Please allow 48 hours for your exam records to be transferred from Person VUE into the CertView Database



Hmmm Boris has said it all... What else can I say?... Dont go for the exams or else you are well prepared!... The removal of the drag-&-drop made the exams a little easier because it was really time consuming. You should be through in approximately 120mins if you are well prepared.


13 years ago
IMHO I agree with Seetharaman...You should make some effort first, make some research either in google or in this forum by using the search dialog box, place the codes here and tell us what you dont understand. Asking for help 'from-the-scratch' is NOT the best way to learn.

With reference to threads you should at LEAST tell us which one you think is better and why, then we will analyse together.



Deepak Bala wrote:The Math class is not part of the SCJP.

Hello Deepak...I didnt know that..Thank you for the information.



shuba gopal wrote:"Watch for Math class being an option for immutable classes"

Hello Shuba, the API indicates that Math class is a final class, meaning you have to abide by the regulations...The Dos and Donts of a final class, for example they CANNOT be subclassed, the exam creators will NOT set a "Trip-Trap" for you on wrapper classes or Strings because its easy for you to notice the "Trap"...


Hello Piyush... Your analysis is perfect and the Java Language Specification explains it like that. Here is a caption: "The cast is always legal at compile time (because even if S does not implement T, a subclass of S might)."



P.S If you click on the link, you need to scroll down the page to a sub-title called; 'CASTING CONVERSION'