I believe I’ve mentioned before I try not to ask memorization type questions; at the very least, I try to ask the question in such a way that the candidate demonstrates they understand more than the textbook definition, which I believe indicates that they’ve either 1) used it in the real world, or 2) actually thought about it in depth – both good signs.
I invented this question on the fly, but in retrospect I rather like it. I don’t know what the “real” answer is, but I certainly have my opinion, and it’s proven to be a very good discussion starter. It involves both Java and .NET, but it’s not really required to know both.
In Java, there are four levels of method/class visibility:public,protected,private, anddefault(package). In .NET, there are also four levels:public,protected,private, andinternal.Java’s
packagevisibility allows artifacts to be “seen” from the same package (i.e. namespace in .NET parlance). .NET’sinternalvisibility allows methods to be “seen” if they are in the sameassembly(roughly equivalent to aJARfile in Java).It’s generally perceived that .NET “copied” a lot of features from Java (whether that’s an accurate depiction is irrelevant here). Why then, did the .NET designers choose to make their fourth visibility different from Java’s? What “problem” did they see?