What happens when a subclass object is assigned as a superclass object
问题 So I have a question about a superclass A and subclass B, where A has 2 public variables and B has 1 more. I saw this snippet of code: A a = new A(); B b = new B(); a = b; What does that last line do? I don't really understand what actually happens when you use "=" between 2 classes in an inheritance relationship. 回答1: It's simple assignment. = is an assignment operator. Lets be clear of below points. In Java when an Object is created and it is accessible via. reference. A reference refer to