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

  • SEARCH
  • Home
  • 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 6972585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:59:19+00:00 2026-05-27T16:59:19+00:00

object a = new Dog(); vs Dog a = new Dog(); In both cases

  • 0
object a = new Dog();

vs

Dog a = new Dog();

In both cases a.GetType() gives Dog.
Both invoke same constructor (with same hierarchy).

Then can you please tell me the difference between these two statements?

  • 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-27T16:59:19+00:00Added an answer on May 27, 2026 at 4:59 pm

    Both create a Dog object. Only the second allows you to directly invoke Dog methods or to otherwise treat it like a dog, such as if you need to pass the object to a method as a parameter of type Dog (or something in the Dog hierarchy that is more specific than simply object).

    object obj = new Dog(); 
    // can only see members declared on object
    var type = obj.GetType(); // can do this
    Console.WriteLine(obj.ToString()); // also this
    obj.Bark(); // Error! Bark is not a member of System.Object
    
    Dog dog = new Dog();
    // can do all of the methods declared for Object
    dog.Bark(); // can finally use the method defined for Dog
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When you instantiate a new object by calling constructor, i.e. Foo bar = new
I'm trying to create a new object of type T via its constructor when
Every time I create a new Dog object on a main Java class, I
I have a new object with a collection of new objects within it on
After creating a new object (Foo), I set the key (BarId) for an EntityRef
I want to create a new object using Class::DBI. One of the fields of
Here's the thing: object[] arrayText = new object[1]; if (arrayText[1] == null) { MessageBox.Show(Is
[Bindable]public var headingData1:Object = new Object(); <mx:HTTPService id=srv url=components.xml resultFormat=object result=getHeadings(event);/> private function getHeadings(evt:ResultEvent):void{
function getData(d){ Back = new Object(); $.getJSON('../do.php?', function(response){ if(response.type == 'success'){ Back = {
I am tryıng to create new object of other class ın a for loop.

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.