Kapil Hingu

Greenhorn
+ Follow
since May 01, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Kapil Hingu

Ok. How about this one...

What makes you think- what you think is right, is not wrong.

Regards,
Kapil
18 years ago
What makes you think- what you think is positive, is not negative.

-Kapil
18 years ago
Hi
I would like to know the minimum no. of questions out of 122 to be answered corretly inorder to be certified.

Thanks
Kapil Hingu
(SCJP 1.4)
19 years ago
Hi Grady,

If you look at operator precedence order of || and &&, && has the higher precedence than operator ||.
And also if you remember java always evaluates left oprand first for binary operators.
So the expression will get evaluated as -

boolean x = (a = true) || (b = true) && (c = true);//Original expression.

x = ((a = true) || ((b = true) && (c = true)));//According to the precedence.

x = (true || ((b = true) && (c = true)));//Left oprand evaluated first.

At this point sencond expression i.e ((b = true) && (c = true)) will never get evaluated as has got short circuited.

Hence the result is,

x = true; with a = true , b = false & c = false.

I hope this answers your question and not adding any confusion
Correct me if my understanding is wrong!

Regards,
Kapil
Hi,
For your query about accessing 'str' from the run method which is called by Thread objects t1 & t2 -
Remember that run method that you write is call back method which gets called by the run method of thread class.
Thread class could do it because you have registered your class with the thread (passed in the constructor of Thread class).
Look at the following code snippet to understand how Thread class might have implemented this feature.



Answer given is: Compile-time error.
Reason: the second catch clause attempts to catch an exception that is never thrown in the try block.

[/QB]

Hi Kitty,

Code snippet of Dan's exam uses checked exceptions(RedException & BlueException) i.e subclass of class Exception.
Checked exceptions represents invalid conditions which are outside the immediate control of the program(e.g. Database problems, Network breakdowns etc.)
For all checked exceptions methods are obliged to establish a policy for all checked exceptions thrown by its implementation
(either pass the checked exception further up the stack, or handle it somehow).
This is why if you expect method m1 to throw BlueException either include it in signature of method m1 or make it unchecked exception by extending it from RuntimeException.

Regards,
Kapil