I tried this code. It works fine. My confusion is, methods callToAClassprintAndReturnSomething() and callToBClassprintAndReturnSomething() , both have void return type as void. But methods being called in them printAndReturnSomething() and printAndReturnSomething() both have return types of objects of class A and class B. So how does this work ? How can the void return type accept returned objects of class A and class B ?
Thanks
Thanks