You have to know the difference between the bitwise '& |' operators and the logical '&& | |' operators. In an expression involving bitwise operators, all the operands are evaluated. In an expression involving logical operators - , the second operand may not be evaluated if-
the operand is && and the first operand evaluates to false
the operand is | | and the first operand evaluates to true
Hope that helps!
------------------ Ajith Kallambella M. Sun Certified Programmer for the Java�2 Platform. IBM Certified Developer - XML and Related Technologies, V1.
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Hi, It might not be clear to all those in this thread. The correct answer is 1, 2, 3, and 4 (all) will throw exceptions. The explanation, a very good one at that, is given above by the honorable Ajith (Sheriff). Manfred.
hi sona, can u explain why 2 is a correct answer.since (s!=null) returns false and && is being used in the expression the second operand (s.length()>0) will not get evaluated.so how will 2 throw an exception? any explanation??? rajashree.
Hi Folks Lot of misunderstanding going on this Thread. Well, to start with let me give the answer first and then explain the reason for the same. The answer is (1), (3) and (4) . Please note (2) does not throws any exception. I have given the reason in my code below.
This question is a classical SCJP question where we may be tempted to jump to conclusion. I guess this ends this Hot discussionin this thread.
Rgds, Ravindra Mohan.
[This message has been edited by Ravindra Mohan (edited May 03, 2001).]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com