Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
code :
public class A extends B
or
public class A implments B (interface) 



I can understand about the comman concept that why a class when inherits or extends to other class become a child class of their inhereted class.

But...why does an class that implements an interface become a child class of that interface ?

why can i cast the class object with the reference of the interface ?

What I have tried:

i tried google , but didnt got any indeth information
Posted
Updated 10-Jul-20 3:40am

Because it is a child of the Interface: you can declare a B variable and assign a instance of A to it, just like you could if B was a class.
If A wasn't a child of B, you couldn't do that, nor could you call B interface methods on class A object instances.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900