if (obj instanceof C) {
//your code
}
More Related Contents:
- Difference between Inheritance and Composition
- Do subclasses inherit private fields?
- Why is there no multiple inheritance in Java, but implementing multiple interfaces is allowed?
- At runtime, find all classes in a Java application that extend a base class
- Why java classes do not inherit annotations from implemented interfaces?
- Is there a way to override class variables in Java?
- Calling a subclass method from superclass
- What is the main difference between Inheritance and Polymorphism?
- Most efficient way to cast List to List
- Why do we assign a parent reference to the child object in Java?
- Inheritance in Java – creating an object of the subclass invokes also the constructor of the superclass. Why exactly?
- Access to private inherited fields via reflection in Java
- Is it possible to call subclasses’ methods on a superclass object?
- Why does the “protected” modifier in Java allow access to other classes in same package?
- Is polymorphism possible without inheritance?
- Calling super super class method
- How do Java method annotations work in conjunction with method overriding?
- can’t cast to implemented interface
- How can a derived class invoke private method of base class?
- Builder Pattern and Inheritance
- Are static variables inherited
- Hiding Fields in Java Inheritance
- Why does every object in Java implicitly extend java.lang.Object class?
- Java method overriding and variable shadowing
- Java generic method inheritance and override rules
- When do instance variables get initialized and values assigned?
- Does an instance of superclass get created when we instantiate an object?
- Initialize field before super constructor runs?
- Using a private variable in a inherited class – Java
- How to enable enum inheritance