If we focus on below section of code abc is an object which is null, so while using + operator should not jvm call toString() function directly on abc rather than valueOf() ? What is your opinion on this ?
Actually + operator performs the concatenation by using append function of StringBuilder class, which calls the value of method in the first operand. append(String) function in StringBuilder internally performs append operation by calling append method of AbstractStringBuilder class which checks for the second operand if it is null, then it is take its value as "null" string.
In this way, it return nullnull as a result. In short the the code converts to following code after compilation -
Hey Valentin ,
With in the same class you can access the inner classes with name of inner class or with the name outer.inner class both of them are fine. But from another class you shall have to use outer.inner format only then the inner class would be accessable.
As in the below code. test2 function in StaticVariableAndInhiretance class would give compilation error reason being it does not what B is. test1 and test2 functions in StaticVariableAndInhiretance1 class woks fine for the same reason as mentioned above.
I hope this would clear all your doubts.
subject: What's the result of this inner class code?