0 votes
1 view
in Java by (3.4k points)
edited by

If class B and class C extend class A and I have an object of type B or C, how can I determine of which type it is an instance?

1 Answer

0 votes
by (46.1k points)

Simply, use this syntax to determine an object's class:

if (obj instanceof C) {

//your code

}

Click here to learn more about Object.getClass()

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...