Anton Uwe

Ranch Hand
+ Follow
since Jan 10, 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 Anton Uwe

@Prasad Shindikar
Do you have an Object class written by yourself? This might lead to such "funny" behaviour...
@raja kanak

No, this cast is not required.
i was able to answer all questions with the knowledge of K&B book. But i did a lot of code writing, too.
Answer A) is correct. Let's see, why. The loop will be over the index of the array assigning the value uf arr[loopindex] to i and setting arr[i]=0.

loopindex arr-content before arr-content after

0 1,2,3,4 i=1 1,0,3,4
1 1,0,3,4 i=0 0,0,3,4
2 0,0,3,4 i=3 0,0,3,0
3 0,0,3,0 i=0 0,0,3,0
Calling a static method the runtime type doesn't matter.
You have declared "SuperClassWithDifferentMethods sc3=...". The compiler will substitute your sc3.method5()-call with "SuperClassWithDifferentMethods.method5();".

Edit: Please note that static methods are not instance methods.
[ March 06, 2007: Message edited by: Anton Uwe ]
16 years ago
Edit: Double post due to a forum error.
[ March 06, 2007: Message edited by: Anton Uwe ]
"assert t>1:foo(8);" surely will not compile, because "foo(8)" does not evaluate to a value. But what do you mean with "problem"?
Because "public static void method5() {..." is static and there is no "overriding" of static methods, the call "sc3.method5();" is the same as "supClass.method5();", both will be replaced by "SuperClassWithDifferentMethods.method5();".

Because method1() is overridden, "supClass.method1();" will call method1() in OverridingClass. That's exactly what overriding means.
16 years ago
Because you cannot "override" static methods...

You are actually telling a thread to sleep, in this case, it just happens that the thread is your "current" thread.

Thread.sleep() (Thread.currentThread().sleep() is calling the static sleep() in a non-static manner) always will put the current Thread to sleep.
As you can see it has to be He obviously simply made a typo...
It will depend on your exp. i think, but i see a good chance.
16 years ago
Have you read the opening post of this thread?
16 years ago
Well, i'll dare to answer:

It is possible to widen Byte, Short, Integer and Long to Number or even to Object, but it is impossible to widen Byte to Short, Short to Integer and so on...
16 years ago
By the way: Your code will not compile: "Three_dimensinal t = null;" has to be "Three t = null;"

You declared method() to be static. So your call "t.method()" will be replaced by "Three.method()".