ujjawal rohra

Ranch Hand
+ Follow
since Mar 20, 2010
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 ujjawal rohra

Ohh yes I missed that the object on which wait is called should be the same on which the block is synchronized.

Thanks Matthew .
In the code below, in the main method I am synchronizing on the String array parameter of the main method. The code gives an IllegalMonitorStateException when trying to call wait on commented line.

I know that a thread has to be owner of the object on which it is synchronizing but in this case I am unable to figure out the reason of this exception as to how main thread is not the owner of the array.
Probably I could not understand the conditions as to when a thread owns an object's lock. Please clarify.

Please be clear about what you are asking and understand others' replies before blaming anyone.

In you original post your question was

Does the exam include creation of generic methods and interfaces also?

and now you say

I posted this question to check whether any person attempted a question on this topic in the exam


Further, I think you did not read the exam objectives carefully before "exhausting your resources" which states

Develop code that makes proper use of type parameters in class/interface declarations, instance variables, method arguments, and return types; and write generic methods or methods that make use of wildcard types and understand the similarities and differences between these two approaches.

which clearly means that they are included in exam and I clearly answered your question

whether any person attempted a question on this topic in the exam


I did not get any questions on these topics

When it is stated in the objectives then it is included in the exam.
I did not get any questions on these topics.
But you should be prepared.

The string "abc" will be eligible for garbage collection but you can't tell after how much time or when it will be available because Garbage Collection is done automatically by JVM. You can't force it and you can't tell when it will be done.

Hi Rasul,

First of all, I will answer your last question. If you want to opt Java as your career then you should go for this certification as its definitely an advantage, both to your knowledge and career.

Now for your first question, its not mandatory to buy a training kit from Oracle or to join any coaching classes. If you can study on your own, then you can clear the exam. I did not purchase any training material. A good book, practice tests, online help and java ranch will suffice.

Regarding the type of questions, first start your study from a book(suggestions given below). The questions given at the end of each chapter will give you an idea of the pattern and practice tests after your preparation will fairly prepare you for the exam.

Suggested Books:

SCJP Sun Certified Programmer for Java 6 Study Guide by Katherine Sierra and Bert Bates (K&B)
A Programmer's Guide to Java SCJP Certification: A Comprehensive Primer by Khalid A. Mughal and Rolf W. Rasmussen

Dont forget to make as many programs as possible.

Hope this helps
When you pass a value of a primitive to a method and manipulate it inside the called method, the change is not reflected inside the calling method. This is because Java uses pass by value method.
If you want the incremented value in the calling mehod then you shound return the incremented value from the method called and store it in a variable inside the calling method(main, in your case) as below:

y will have a value 6.

and your method definition becomes:

Hope this helps..

Also, adding to the above suggestions, after you think that you are prepared to take the exam take some practice tests. These tests(simulators) not only expose you to the real test environment but also make you learn some new things. Besides, practical knowledge is always necessary. So make as many programs as possible. For even a small doubt make a program to clear it.

And visit java ranch frequently to read and answer others' queries. This will boost up your confidence and also an open discussion clears many other doubts as well.

Hope this helps.


8 years ago
Hi Aravind

Having a certification does not guarantee you a job but its an advantage definitely.
Also, having a certification raises the expectation level of the interviewer and hence the difficulty level of the questions asked also increases a bit.

But, on the brighter side, if you have the knowledge then definitely it will help and besides, it also boosts up your confidence.

Hi Keerthi

First of all Welcome to java ranch. Second the salutation is not "Runchers" but it is "Ranchers". Please be careful afterwards

Now to your questions. In my view one hour is sufficient daily but it will increase the time span for the preparation. Its an easy calculation that if you prepare say, five hours daily for something then you can clear it in say, 1 month but if you prepare for 2 hours daily then the time will increase to three months.
As far as clearing in Feb is concerned it depends on where you stand conceptually at present. Working on java and OCJP are very different things.

All the best..
Hi Palak

According to me, for understanding Collection and Generics go ahead in parts since they are two separate topics although they are related. Generics follows Collections. Do not try to read in a single shot.
More importantly, understand practically as much as possible. Make programs and learn by experimenting with them and it will definitely help you.

All The Best... Cheers!!!
Simply saying, any variable which is declared inside a method(including body or definition) or any block(loop, if-else block, constructor) is a local variable. Local variables can be accessed only within the block in which they are declared and not outside it.
Instance variables are those which are declared outside any block but directly within the class.They can be accessed anywhere within the class and even outside the class. See below

In the above code, variables var and var1 are declared outside any block but within the class hence they are instance variables. While variables local1, local2, local3, local4 are declared inside constructor, a method and an if block respectively, hence they are local variables.

Further, the modifiers public, private, protected apply only to instance variables and not to local variables.

Conceptually, whenever you create an object of a class then each object has a copy of instance variables. This means that you can access instance variables of a class when you make an object of this class by using a dot operator(For ex. obj.var1) but you cannot access local variables directly.

Hope this helps.
Fred is absolutely right.
A topic may seem to be threatening to one person and same topic may appear to be a piece of cake to some other.

But in my opinion Threads and Collections are very wide(again, I would not say challenging or tough) topics. Though not much is asked on Threads in the exam but they are in syllabus and you never know about the exam, so you have to be prepared.
Hi Soujanya

The code snippet does an if check. The left hand condition replaces the 'g' character in "String" with 'G'. The right hand side of this check also does the same resulting into the condition

But the "==" check returns false hence "Not Equal" is printed since the "==" operator checks references(that is another topic ).
PS: If you use .equals then it will print "Equal".

Hope that helped.

if after the following code you use the value of z then it will be definitely 7 because after Line 1 z is incremented to 7.

But if you place return statement at Line 1 like this:

then the value of z returned will be 6 because the post increment operator will increment it after using it in the return statement.

Hope that helps.