Question: Given three classes A, B, and C, where B is a subclass of A, and C is a subclass of B, which one of these

Given three classes A, B, and C, where B is a subclass of A, and C is a subclass of B, which one of these boolean expressions is true only when the reference o refers to an object of class B, and not to an object of class A or class C?

Select the one correct answer.

(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))

Step by Step Solution

3.40 Rating (150 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

b The expression o instanceof B will return true if the object referred to by o is of type B o... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Programming 8th Questions!