I want to understand all the advantages of singly rooted class (object) hierarchy in languages like .NET, Java.
I can think of one advantage. Let’s say I have a function which I want to accept all data types (or references thereof). Then in that case instead of writing a function for each data type, I can write a single function:
public void MyFun(object obj)
{
// Some code
}
What other advantages we get from such type of hierarchy?
I’ll quote some lines from a nice book – Thinking in Java by Bruce Eckel: