Regards,
Avishkar Nikale
Look for instanceof questions that test whether an object is an instance of an interface, when the object's class
implements the interface indirectly. An indirect implementation occurs when one of an object's superclasses
implements an interface, but the actual class of the instance does not—for example,
interface Foo { }
class A implements Foo { }
class B extends A { }
...
A a = new A();
B b = new B();
the following are true:
a instanceof Foo
b instanceof A
b instanceof Foo // implemented indirectly
An object is said to be of a particular interface type (meaning it will pass the instanceof test) if any of the
object's superclasses implement the interface.
Malatesh Karabisti wrote:
Try this and spot the difference. If else block always executes only one condition at time if it executes first one it won't executes second one. In your code "ref instanceof Browser" is true hence it won't even do a check for "ref instanceof IE". I think this time I explained better.![]()
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
thejaka samarakoon wrote:Why the output is Browser rather than IE.Since at runtime according to VMI it is selected as a IE.
SCJP6.0,My blog Ranchers from Delhi
SCJP6.0,My blog Ranchers from Delhi
SCJP6.0,My blog Ranchers from Delhi
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |