Nad Shez

Greenhorn
+ Follow
since Jun 17, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nad Shez

I recently passed my SCJP. Sure the certification reinforces the parameters of the language well, but all i made during the time were test programs. So any tips/books you guys recommend that can give me a kick start in making some real programs? Thanks.
I recently passed my SCJP. Sure the certification reinforces the parameters of the language well, but all i made during the time were test programs. So any tips/books you guys recommend that can give me a kick start in making some real programs? Thanks.
17 years ago
No, they're not! But to be sure, i advise you to visit the following link on the sun site with the exam objectives

Sun Certified Programmer for Java[tm] 2 Platform 1.4 (CX-310-035)
I think a more appropriate statement would be
if a statement within a method throws a checked exception, that exception must be dealt within that method using a try/catch block or declared in the throws clause of the method
consider this simple code

aMethod() throws an exception at line 9, so it can either deal with this exception in the method body by using a try/catch block (which it doesn't!) OR propagate it to the caller by declaring it in its throws clause (which it does at line 8).
Next in the line is method main() (that btw too can declare Exceptions in its throws clause, just like any other method) that called aMethod() at line 4. Again, it can either deal with this probability of getting an exception by either using a try/catch block (which it does) OR propagate it to the caller (System in main's case) by declaring it in its throws clause.
Since aMethod() declares that it might throw an Exception, any method calling aMethod() must use a try/catch block or propagate it using throws clause. Failing to do either flags a compiler error. If aMethod() hadn't declared, then there is no responsibility on the calling body, but then aMethod() itself must deal with any exceptions it throws using a try/catch block.
so remember that you can't get past the compiler unless you "deal" with a checked exception by either using a try/catch block or propagating it using the throws clause.
Note that the rule DOES NOT apply to unchecked exception (Error, RuntimeException, & all subclasses of these two) are known as unchecked exception. All the rest are checked exceptions. A good program is not supposed to throw any unchecked exceptions in the first place, so a compiler gives no error if you throw a unchecked exception & don't "deal" with it in the above described manner.
I suggest you experiment with the above code. e.g. remove the "throws Exception" from aMethod(), compile & see what happens .. or comment try/catch block around aMethod(), compile & see what happens. Also try replacing Exception() at line 9 with RuntimeException() or Error() to get a better understanding of unchecked exception.
Hope this helps.
Thanks for the detailed explanation Thomas. I've got it! As for the footwork Steve, only if they'd allow a calculator in the exam, i wouldn't even need Integer.toBinaryString()!
Can anyone please send me some link or explain how to convert negative integers to Binary format? Thanks.
++ or -- if placed _before_ a variable increment or decrement the value before it takes part in the "rest of the calculation". If placed _after_ a variable, increment or decrement after it takes part in the "rest of the calculation". What this means is that if a variable is appearing twice in a statement, the second time it appears, it would have the "updated" value. e.g.
int i = 5, j = 2, k;
k = i++ + j;

i=6, j=2, & k=7, right? Yes. since i is incremented after i++ is executed, but for understanding point of view, value of i is set to 6 not by the end of the statement, but by the end of when i++ is done .. meaning when it gets to the + operator in the middle. so
k = i++ + i;

would give us k=11 .. since i++ would evaluate to 5, but before the expression is further evaluated, i is set to 6 .. so when the right side of the + operator is evaluated & value of i is requested, its 6 .. hence 5+6 would give us 11. value of i by the end of expression would still be 6.
now to the main course
int k = 1;
++k+k++ + +k;// ++k + k++ + +k
Evaluating it from left to right step by step
++k yields 2 & sets the value of k = 2
2 + k++ + +k;
k++ yields 2 but sets the value of k = 3
2 + 2 + +k;
+k is a simple + Unary operator that has no effect in this case so it yields the current value of k i-e 3
2 + 2 + 3;

equals 7.
Hope that helps. please correct me if I'm wrong in my crude explanation.
So basically learn almost everything about strictfp!
Sorry about my displayed name didn't know that there was a naming policy, so i've changed it now.
Thanks everyone.
I'm studying for Java Programmer Certification 1.4, & would like to know about the following.
a) strictfp. apart from that its a keyword, can there be questions regarding its proper usage, its validity along with other modifiers, etc?
b) Am i supposed to learn the working of methods resume, stop, suspend in Thread class, even though they're deprecated?!
Thank you.