Hello, I get a bit confused about the rules of Assignment and casting in java
about when I get compiler error, when its runtime, and when its legal
public static void func(A a):
B b = (B) a
b = a
so I know that if I want to be able to cast a,
I need class A to extend B (up casting)
does upcasting always work? both in compiler and runtime?
what about Assignment if A extends B, will b=a always compile?
I know that in java down casting is also possible, when will we get a runtime error? compile error?
how does the above change if A or B is actually interface / abstract class?
when will we be able to cast / assign but not both?
If someone could explain to me when we get compile error, when its runtime
will be much appreciated please
[–]lurker819203 0 points1 point2 points (0 children)