Given three classes A, B, and C, where B is a subclass of A, and C is a subclass of B.
(a) (o instanceof B) && (!(o instanceof A))
(b) (o instanceof B) && (!(o instanceof C))
(c) !((o instanceof A) || (o instanceof B))
(d) (o instanceof B)
(e) (o instanceof B) && !((o instanceof A) || (o instanceof C))
Question: Which option is true only when an object denoted by reference o
has actually been instantiated from class B?
Note: I am unable to understand the question. Even though the object is instantiated from B, we can instantiate objects from any of the classes A, B or C.
What is the question exactly trying to state?
Since this is clearly a homework exercise, it is not appropriate for me to provide an answer directly. Instead, I have written a little program for you to demonstrate what the question means, and running it will provide an answer.
You can try this out for yourself: