Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!

Pete Knecht

Ranch Hand
+ Follow
since Mar 30, 2005
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 Pete Knecht

I recently took and passed the 1.4 exam after several months preparation (thanks for the help, everybody). I primarily used the K&B book, and in the last month or so, I started doing Dan's mock exams(primarily Study Guide 1 questions). I would say that Dan's questions are considerably harder than the real exam questions, but that makes them very valuable for study purposes. The first time I worked some of Dan's questions, I felt a bit dumb, but they exercise you so much on so many details that when you get comfortable with them, you should have no problem passing the real test.

Also, working through Chisholm's questions from the Study Guides revealed what seems to me to be some holes in the K&B book. I studied Dan's answers and wrote little programs to work out my own confusions and get some experience in topics that I found I didn't understand. But it was his questions that revealed those misunderstandings. So, in short, his questions will seriously exercise you, and imho, if you can comfortably do them, you will be ready for the real thing.
Thanks for the responses, everybody. I appreciate the detailed answers.
Thanks for the response. I will look at that page. I wasn't questioning the proviso against assertions in public methods, just wondering about the rationale for their use in private methods. Anyway, I'll see what this doc says.

In the K&B book (p.264) the following rule for assertions and private methods is given:
"Do use assertions to validate arguments to a private method."

This rule comes after the one saying don't use assertions to validate arguments to *public* methods, basically because you can't be guaranteed that assertions will be enabled in a deployed application.

Now, why doesn't this same rationale against using assertions to validate in a public method hold for private methods? For private methods, they give the reason that "you almost certainly wrote (or control) any code that calls it", and so, presumably, you can know or control whether assertions are enabled. But I guess I don't see this; can't a public class with public methods also have private methods that perhaps perform some utility work? And in such a class you might not have any more control over whether assertions are enabled/disabled than in a class w/ purely public methods.

In short, I don't see their rationale for allowing assertions to validate arguments to a private method either. But, it's likely I'm missing something in their account (or perhaps there is another rationale that they don't give that would clear this up). Any thoughts?
I am about to take the SCJP 1.4 test. After that I will immediately start studying for the SCWCD test. Does anyone know if there are plans in the coming months for a SCWCD 1.5 test?

Further, if there is such a new test in the making, will SCJP 1.4 people be able to take it (assuming they've assimilated new 1.5 material)? Historically, it seems that should be the case (just like SCJP 1.3 can take the 1.4 SCWCD).

Or, is 1.5 so significantly different that one will be required to first upgrade their 1.4 SCJP to 1.5 (say through a 1.5 SCJP upgrade exam) before taking any new SCWCD?

I hope what I'm thinking about is clear enough. I'm just worried about my SCWCD options after freshly completing the 1.4 SCJP. Thanks.

Originally posted by Kay Liew:
You never know the true facts of how much time he has studied before even taking the training. The fact is, after a person passed it s/he can say anything. No experience and passed with 2 weeks of studying? Do some calculation of time of each chapter and materials a person required to understand and memorized. How much time required to do the mock tests ? How about writting some java snippet just to test out the code? Well, is that a full time or a part time thing?

It's really rare people can do things like I did.
Actually, I passed my scpj with couple days of preparation from javadoc and scjp tutorial from SUN web site and I have only wrote a Hello World that looped 3 times. I think the exam is so easy even my 3 years old can do it with. I think Sun should raised the score to 85% so that my 3 years cannot do it without writting a Hello World to loop 4 times.

Wow, talk about belittling those studying for the 1.5 test (or the 1.4)! Your two paragraphs contradict each other, and what you say about 3-year olds is absurd. Some of the people here obviously forgot, after they had passed a certain cert, what it's like to go from little or zero experience to having enough knowledge to pass an exam. Not to mention the fact that clearly the people at Sun aren't fools, and will have set the bar such that their own cert means something.

Originally posted by Marcus Green:

Employers are not that clued up or fussy about which version you take, but four years down the track it would be nice to have 1.5 instead of 1.4. Your choice.

Thanks for the info. I asked a question concerning 1.4 and the new exam and employers/employment a couple days ago in the thread 'SCJP 310-035 Test Validity' but didn't get a specific answer. Your answer here was what I suspected.

Thanks for your thoughts. Yes, good prep materials are a consideration...esp. for those of us who are very close to taking 1.4 now and don't want to wait too long. It's hard enough w/ good books (like K&B).

Just curious, what materials did you use to study for the beta version, then?
I have a concern related to Rachel's post.
For those of us about to take the 1.4 test very soon, would it be better to wait, study yet more, and take the new test?

Will there (eventually) be an upgrade test from 1.4 to 5?

I would like some practical advice on this, as I am virtually ready to take the 1.4 test, and will be seeking employment this summer using that cert (plus some ms certs), and I don't want to be rendered moot in Java as soon as I get certified. Another way to ask this, I suppose, would be to ask: will there be a significant lag time from an employment perspective before the new SE 5 exam becomes mandatory(or strongly preferred) as opposed to having passed 1.4? Some of you may well know of this from previous versions/exams.

I feel a bit of a conundrum: on the one hand I've put months into prepping for 1.4 and really want to get on with it, but on the other hand I don't want to submit a resume come July/August and have the majority of the responses be: oops, we need SCJP 5. Thoughts?
[ April 17, 2005: Message edited by: Pete Knecht ]
I interpret this to sort of refer to the labeled-break syntax as a whole, where the actual *label* can be outside the loop, but the 'break:label;' part will still be inside some loop or other. I don't think 'break' can appear outside any loop (or switch).

Originally posted by mav:
If anyone can tell me how come that technique works seemingly all the time until you hit a negative value and how to appropriately deal with converting negatives by hand (binary to base 10 and base 10 to binary) i'd appreciate it. I would love to know what -38 looks like in binary and what rule i'm missing so i can get past this section cause continuing to look at it is driving me nuts .

thanks for your help

I think I can answer at least some of your questions. It is possible to extrapolate from things said in the K&B book that you're using to get a clear procedure for figuring negative numbers by hand. For example, suppose you have the following *int* bits:
(A) 1111...1101 1010
where there's 32 bits, and the '...' all represent 1111's. You know it's a negative number b/c the leftmost bit is 1. (Right, you with me?).

Now, procedure to calculate what negative number it is:
Flip all the bits(1's to 0's, and 0's to 1's), and then add 1. Whatever number that is, just consider it negative, and your done.

So, in (A) above, flip it to get:
0000....0010 0101
What binary number is that? 37. Now add the 1 to get 38. Now add negative sign, -38. And your done. So (A) above represents -38, like you wanted to see.

Now, take the 'reverse' of the above procedure to figure out how to represent some number as a negative (rather than having negative bits from the start). (Remember you wanted to see this all manually.)

Suppose you want to know how to represent -17. Well, you know that you need some bit arrangement such that *when it's flipped, it will equal 16* (the 1 added to that will then make 17). The following will do that:
(B) 1111...1110 1111.
This bit number represents your -17. As a check, run the first procedure to calculate its value. (Again, it's a negative, so flip bits, then add one, then take the negative.)
Flipping (B) gives you:
0000...0001 0000, which is 16. Add 1 to get 17. Take negative, -17.

Remember, during this operation, the number being worked on is 'promoted' to an int, so there are some extra steps if, say, you're shifting a byte.
byte b = -13;
b = (byte)(b >> 2);

To work this through with no shortcuts, it goes:
1. Promote -13 to an int and represent it:
(C) 1111...0011 (where the '...'s are all 1's. As an exercise satisfy yourself that this represents -13 using the above procedure).

2. Perform the shift, two to the right:

3. Now since in the example you must *cast* this back to a byte, you lose all the bits to the left except the rightmost 8, giving:
1111 1100

4. That's a negative, right? Calculate its value. -4. So that's your answer to the shift example. b= -4.

Finally, note that in this example a manual cast was used. If you wrote:
byte b = -13;
b >>= 2;
The compiler would auto-cast for you, but the answer would be the same. See K&B, the first couple pages of Chap. 3 on this. Extrapolate from the above example and work a few using >>> and <<. Then re-look at K&B material on this and it should make sense.

[ April 09, 2005: Message edited by: Pete Knecht ]

Originally posted by Marcus Green:
"Many SCJPers have been posting by studying with 1-2 weeks without Java experience and passed with flying score."

And some people report being abducted by aliens...

I have been following every public posting on the subject of Java Programmer Certification since 1998 (this is tens of thousands of messages) and the general consensus is that the time to study is measured in months not weeks.

Thanks, I needed to hear this. I was suspicious of these claims anyway, but it's good to hear someone w/ experience knock them down. I've been studying for several months, and I still find new surprises and confusions every day on topics I thought I already understood. Plus, trying to hold it all in memory.....It's gradually coming together, though (I think).

Originally posted by sai purnima:

I think we can use super to call static methods but it should have a return statemnt so that a relavent super constuctor is called.Is this write else give the correct answer.One more thing we can call static methods and variables outside super also.

Okay, that's an interesting subtlety, but it makes sense. The point of calling super(SomeClass.staticMethod()) is to pass some value on to an overloaded constructor of the superclass, so I would expect a compiler glitch if I try to pass *void*, i.e. nothing.

BUT, if your last sentence is true (which was the point/question of my original post), then that constructor rule given by K&B is in error, and we should know about it. It could well mean a question or two on the exam. I've further noticed that that rule in question does not show up in their Two Minute Drill section at the end of the chapter...which also makes me think they might have meant to drop it from the main chapter as well but it just slipped through.
Thanks, Pete.
[ April 08, 2005: Message edited by: Pete Knecht ]

Originally posted by Anuj Soumya:

hii pete

Instance variables are varibale declared at class level.In your code the Static int i; is an Instance variable.that is why you are able to access it after the constructor is called.

We're understanding the term "instance" in very different ways.

I dont think it means that the only way to access a static varibale is thru Super() call parameter!!! that would be so wrong.


Well, maybe it would be wrong; that's what I'm trying to get crystal clear on.

Originally posted by Anuj Soumya:
hii Pete

if you see page 316, the point just above what you mention ..
it says that "You cannot make a call to an instance method or an instance variable, until after the super constructor runs".

if you see your code.. you are accessing the Static variable after you are calling super()!!! which it totally legal.infact you can access any instance variable(static or not) after super has run!!

what the second point on page 316 means is that before calling super , the only variable that you can use is Static. and that also as an argument to Super() or this().

i hope i was clear


Thanks for the reply, but I'm not satisfied. First, yes, the previous constructor rule dealt with instance variables and methods, but that is not the issue here. Both the rule I'm questioning and my code example deal with static vars and methods. The second rule on p. 316 pretty clearly says you can only access/use static vars and methods as arguments to super() and this() calls. I've given a simple counterexample to this which seems to work.

But because a) I am a relative newbie, and b) I respect the K&B book, I'm hesitant to outright say they have stated the rule falsely until I hear some expert opinion. Thanks, Pete.