What is need of object type casting?

Downcasting is necessary to gain access to members specific to subclass . Downcasting is done using cast operator. To downcast an object safely, we need instanceof operator. If the real object doesn’t match the type we downcast to, then ClassCastException will be thrown at runtime.18 May 2021

Read more

How do I find out my class name?

The simplest way is to call the getClass() method that returns the class’s name or interface represented by an object that is not an array. We can also use getSimpleName() or getCanonicalName() , which returns the simple name (as in source code) and canonical name of the underlying class, respectively.

Read more