Kiran Gavate

+ Follow
since Jan 18, 2007
Merit badge: grant badges
For More
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 Kiran Gavate

Thank you all for your wishes. Thanks Raghavan, Rupika, Amit for letting me know that my story is useful

16 years ago
Dear all,

Yesterday I cleared the SCJP 5.0 exam with 93%.

I was relatively new to Java having almost no hands on experience. I have a very good programming and design experience in database technologies. It took me almost 6 months to prepare for the exam besides my other responsibilities e.g. full time, demanding work, and family with a 1.5 yrs. kid I must thank my wife first for her unconditional support.

I studied with the K&B book, which I feel is sufficient for the exam and is really an excellent book. I think no SCJP 5 success story can be complete without the mention of K&B. The two minute drills are excellent for revisions and last min. preparations. I had a difficulty initially to understand collections and generics and I referred to some material on the internet to enhance my understanding. This is not to say that the K&B book does not explain them well, in fact it does explain those topics in the most easy to understand way, but I was simply not catching the basics and reading something different gave me a good start.

I wrote a 100s of small programs to improve my understanding and burn the concepts in. I verified every new concept and every important point by writing code wherever possible. Whenever I answered a mock question wrongly, I actually coded and ran the program to see the output. This really helped me a lot.

Thanks to all the ranchers who helped me directly and indirectly. Although I did not post many questions, reading other's questions and responses helped me a lot.

Many questions in the exam were easier than the mocks I had taken. d&d were some of the toughest questions. Many questions were based on the fundamentals, but overall I feel I got a good mix, from basic to more difficult questions. Time was not a problem as 175 min. are really sufficient to answer the 72 questions and also review them. It gave me a warning when I wanted to review the d&d questions that the answers will be reset.

Studying for SCJP was a great learning experience for me and I am happy to get a start in Java technology.
The next step is obviously the SCWCD and I have already purchased the HFSJ book. I wish all the best to everybody who are studying for the Sun certification exams.

16 years ago
Moved the readObject() method to Worked like a charm!

Thank you so much.

From the example in the k&b book it was not clear to me that both the readObject() and writeObject() overrides should be in the same class (it looks so obvious now as I am writing it!)

Here is the complete listing if somebody wants to try it out.



Hello ranchers,

I am trying to understand the overriding of writeObject() and readObject() to manually serialize non-serializable members of a class.

I am writing the class instance into a file in one java program and then reading it using a different java program. I have overridden the writeObject() and readObject(). Overridden writeObject() works fine, but when I try to read the saved object, the overridden readObject() is not called at all. I am unable to see why it is not working. Could you please identify where is the problem in the following code?

1. - serializes the object. I am overriding wireObject() to manually serialize a static variable in the class.

2. - de-serialize the object. The problem is here - overridden readObject() is not being called at all.

I can not see the output "Reading static variable manually...", it means it is not going to the overridden readobject() method.
Hi Lee,

I believe that the SCJP certification itself is a motivation for studying Java. In fact, that's how it is in my case. I was not having a enough motivation and there was no direction when I started to learn Java. Since Java is so vast, you can easily get lost as to where to start and what to learn. SCJP gave a very good direction and a goal. Plus when you are working and have a family it's easy to forget/ ignore to study with your busy schedule.

But since the time I decided to do SCJP, I am finding that I am studying every single day without fail.

Then when I came to Javaranch forums, it's inspiration everywhere This place is filled with energy. And the stories in the results forum also motivates you a lot.

When you get into the flow, I think you will get your motivation, the important thing is to just start it and not keep thinking that I will do it when I have more time or when I finish my current activity etc. etc.
Wishing you all the best!
Hi Deepti,

I don't think it's a faulty statement because it says except in the special cases.......the finally block is guaranteed to be called.

But I have another question about this sentence, it says "A finally block is not required, but if there is one it must follow the catch."

But what I understand from k&b SCJP 5 book is that either catch or finally block is required. So there could be a finally block that may follow a try block and not necessarily a catch block.

Or is this a change in Java 5 from Java 1.4? Sorry I have not seen the k&b SCJP 1.4 book.

Could somebody pls clarify?
Thanks very much for taking time to go through my code an answer the query.

My point is when you throw TestException2 in method1, it jumps to catch (TestException2 e) line in method callMe. So even if the throw e; line is not there in this catch block, it is anyway going to ignore the other two catch blocks, isn't it?

So why the book says that all other catch caluses associated with the same try are ignored when you throw the same exception in a catch block?
Hi folks,

This is from K&B 1.5 p365
Rethrowing the Same Exception

Just as you can throw a new exception from a catch clause, you can also throw the
same exception you just caught. Here's a catch clause that does this:

catch(IOException e) {
// Do things, then if you decide you can't handle it�
throw e;

All other catch clauses associated with the same try are ignored, if a finally block exists, it runs, and the exception is thrown back to the calling method (the next method down the call stack).

What exactly does it mean by All other catch clauses associated with the same try are ignored and how can I verify it?

Even when there are different catch caluses associated with a try block, they will be for handling different exceptions. I tried to verify the above by writing the following code, but I think it is not really relevant.

What I thought is that by throwing the same exception TestException1 in the catch (TestException1 e) block, I can simulate the condition. But when I say throw new TestException1() in method method1, anyway it is going to ignore other catch clauses in method callMe.

I am really stuck on how to write the correct code to verify the sentence from K&B.

Could somebody pls explain this and give relevant example if possible?
[ February 13, 2007: Message edited by: Kiran Gavate ]
Thanks for the quick explanation, but sorry I still do not understand which two objects will be eligible for GC. Could you please explain?

Could somebody pls explain in more details? I am not able to get it. Isn't it that when the value is between -128 and 127, the wrapper object will be created in the object pool? Which two objects are eligible for GC?
Thanks for the clarification. I was thinking that it would be a runtime error. good to learn that it will not compile at all.
[ February 09, 2007: Message edited by: Kiran Gavate ]
Hi Madhavi,

When you replace the Derived() {} by Derived (String s) { } constructor, it still compiles because you are not calling the default (no-args) constructor of the derived class in your code.
Hi Amit,

Thanks for your reply. Do you mean in chap 3 in the k&b book or somewhere else? I am only till chap 3 at this time. Pls let me know if this is explained in more details somewhere further.
Thanks a lot for the answer.

What is the result?

The answer is compilation fails because int 7 cannot be implicitly converted to short.

My question is why doesn't the implicit cast works here even where 7 is a hardcoded value.
e.g. in the following code

line 1 and 2 work whereas line 3 is compile error, which is ok because the compiler doews not know what is the value of ii. The implicit cast works in line 2 because 7 is hardcoded and it can fir into short.
Why doesn't the same principle work when an hardcoded int value is passed to a method taking short?
[ February 06, 2007: Message edited by: Kiran Gavate ]