Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7549339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:55:42+00:00 2026-05-30T09:55:42+00:00

I want to understand all the advantages of singly rooted class ( object )

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:55:43+00:00Added an answer on May 30, 2026 at 9:55 am

    I’ll quote some lines from a nice book – Thinking in Java by Bruce Eckel:


    All objects in a singly rooted hierarchy have an interface in common,
    so they are all ultimately the same type. The alternative (provided by
    C++) is that you don’t know that everything is the same fundamental
    type. From a backward-compatibility standpoint this fits the model of
    C better and can be thought of as less restrictive, but when you want
    to do full-on object-oriented programming you must then build your own
    hierarchy to provide the same convenience that’s built into other OOP
    languages. And in any new class library you acquire, some other
    incompatible interface will be used. It requires effort (and possibly
    multiple inheritance) to work the new interface into your design. Is
    the extra “flexibility” of C++ worth it? If you need it—if you have a
    large investment in C—it’s quite valuable. If you’re starting from
    scratch, other alternatives such as Java can often be more productive.


    All objects in a singly rooted hierarchy (such as Java provides) can
    be guaranteed to have certain functionality. You know you can perform
    certain basic operations on every object in your system. A singly
    rooted hierarchy, along with creating all objects on the heap, greatly
    simplifies argument passing.


    A singly rooted hierarchy makes it much easier to implement a garbage
    collector (which is conveniently built into Java). The necessary
    support can be installed in the base class, and the garbage collector
    can thus send the appropriate messages to every object in the system.
    Without a singly rooted hierarchy and a system to manipulate an object
    via a reference, it is difficult to implement a garbage collector.


    Since run-time type information is guaranteed to be in all objects,
    you’ll never end up with an object whose type you cannot determine.
    This is especially important with system level operations, such as
    exception handling, and to allow greater flexibility in programming.


    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an assignment for my first OOP class, and I understand all of
As I understand one of the main advantages of distributed revision control system like
I want to understand the role interface plays in inheritance between two classes. My
I want to understand the actual theory behind types rather than just learning about
I want to understand in which order are the elements of h_addr_list sorted when
I want to understand if code snippets are what I am looking for here.
I want to understand the use of xargs man in Rampion's code : screen
I want to understand the external linkage and internal linkage and their difference. I
I want to understand how a C++ program that was given to me works,
I want to understand how the mechanism of Shadowing and Nested function work. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.