GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  Ado.NET
Go To First  |  Previous Question  |  Next Question 
 Ado.NET  |  Question 6 of 31    Print  
why can\'t we use Multiple inheritance and garbage collector paralelly in .net

  
Total Answers and Comments: 7 Last Update: September 11, 2008     Asked by: Amit 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: msraghunathan
 

FYI, .net doesn't support the mutiple inheritance, perhaps you may talk about multi-level inheritance.

In the later case, if a class is inherited from another class, at the time of creating instance, it will obviously give a call to its base class constructor (ie bottom - top approach).  Like wise the constructor execution is takes place in top down approach (ie. base class constructor is executed and the derived class constructor is executed).

So for GC, it will collect only when an object does not have any reference.  As we see previously, the derived is constructed based on base class.  There is a reference is set to be.  Obviously GC cannot be collected.



Above answer was rated as good by the following members:
surendra_sahu786
January 30, 2006 06:18:20   #1  
anand80@hotmail.com Member Since: January 2006   Contribution: 1    

RE: why can't we use Multiple inheritance and garbage...
Multiple Inheritance was not allowed in .Net to avoid Diamond Problem (Where a class inherits from two classes which are both inherited from a same base class. Then on invoking the base functions the compiler may get confused to call which function). But wht the garbage collector has to do with this is a matter that we need to really look into. I will try to find the answer for this and come back.
 
Is this answer useful? Yes | No
January 30, 2006 06:22:10   #2  
samantbjain Member Since: January 2006   Contribution: 1    

RE: why can't we use Multiple inheritance and garbage...
we can use it . Multiple inheritance is used by interfaces while you can not force GC indipendent of Multiple inheritance . GC run on its own ie when system run out of memory.
 
Is this answer useful? Yes | No
February 10, 2006 22:08:21   #3  
ameen        

RE: why can't we use Multiple inheritance and garbage...

grabage collector

there are two types of Garbage Collector

managed garbage collector

see we will declaring variable object .. etc in our programes..once this kind of

variable object goes out of the scope they are put into the heap and they r checked r the further existence . once its beeing no longer used garbage collector wil deallcate mem for the that variable and objects.

Umanaged garbage collector

this was done mannually and u will be happen to open a connection with database will be open the file .etc. while this kind of the thing goes out of the scope

we have to explicitly call the garage colector by calling the closecommand of the datbase ...once te connection is closed it puts this memmory ino the heep .. and process follws the same


 
Is this answer useful? Yes | No
April 18, 2006 07:18:29   #4  
msraghunathan Member Since: April 2006   Contribution: 1    

RE: why can't we use Multiple inheritance and garbage...

FYI .net doesn't support the mutiple inheritance perhaps you may talk about multi-level inheritance.

In the later case if a class is inherited from another class at the time of creating instance it will obviously give a call to its base class constructor (ie bottom - top approach). Like wise the constructor execution is takes place in top down approach (ie. base class constructor is executed and the derived class constructor is executed).

So for GC it will collect only when an object does not have any reference. As we see previously the derived is constructed based on base class. There is a reference is set to be. Obviously GC cannot be collected.


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
June 20, 2006 11:50:33   #5  
NITIN        

RE: why can't we use Multiple inheritance and garbage...

.net doesn't support the mutiple inheritance perhaps you may talk about multi-level inheritance.

In the later case if a class is inherited from another class at the time of creating instance it will obviously give a call to its base class constructor (ie bottom - top approach).


 
Is this answer useful? Yes | No
January 04, 2007 13:46:19   #6  
Mob: +91 9849255958        

RE: why can't we use Multiple inheritance and garbage...
Actually GC is a low-level thread. When it gets activated all other threads in the applications are put on hold.
 
Is this answer useful? Yes | No
September 11, 2008 16:39:03   #7  
Pendurti Member Since: September 2008   Contribution: 10    

RE: why can't we use Multiple inheritance and garbage collector paralelly in .net
Well C# doesn't support multiple inheritance through classes.
If you want to have multiple inheritance in your program you need to make use of interfaces. A class cannot inherit from more than one class but a class can inherit from more than one interfaces. So C# supports multiple inheritance through interfaces.
And multiple inheritance and garbage collection can work independent of each other because in .NET framework garbage collection is taken care of by CLR. We can also manually invoke garbage collector using gc.collect().

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape