|
INTERVIEW QUESTIONS
MICROSOFT
VISUAL BASIC
DETAILS
Question: What are the three methods in IUnknown interface and their use?
Answer: COM uses a method of "reference counting" to keep track of when the resources taken up by the object can be physically released. Basically it works like this. A object instance is created in a program and a reference is held against it. The reference count is 1. If another reference is made to the same instance of the object, the reference count is incremented by 1 so it is now 2. If the first reference is set to nothing, the reference count is decremented but as far as COM is concerened the object is still alive as the reference count is not 0. When the last reference is set to nothing, the count is decremenetd to 0 and COM can release the resources used by the object back to the system.
As a result of the above, all COM classes implement these 3 methods:-
QueryInterface AddRef Release The QueryInterface method is used by COM to query whether the component supports a particular interface (so it is passed an Interface ID). If it does support it, a pointer is returned to IUnknown otherwise NOTSUPPORTED value is returned (can't remember the exact name)
AddRef is responsible for the increment of the reference count.
Release is responsible for the decrement of the reference count.
Thus, circular references are a real problem within COM and Garbage collection employed under .Net is one of the ways around this problem.
|
|
|
Category |
Visual Basic Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 7270 users |
Added on |
7/27/2011 |
Views |
69962 |
Rate it! |
|
|
Question:
What are the three methods in IUnknown interface and their use?
Answer:
COM uses a method of "reference counting" to keep track of when the resources taken up by the object can be physically released. Basically it works like this. A object instance is created in a program and a reference is held against it. The reference count is 1. If another reference is made to the same instance of the object, the reference count is incremented by 1 so it is now 2. If the first reference is set to nothing, the reference count is decremented but as far as COM is concerened the object is still alive as the reference count is not 0. When the last reference is set to nothing, the count is decremenetd to 0 and COM can release the resources used by the object back to the system.
As a result of the above, all COM classes implement these 3 methods:-
QueryInterface AddRef Release The QueryInterface method is used by COM to query whether the component supports a particular interface (so it is passed an Interface ID). If it does support it, a pointer is returned to IUnknown otherwise NOTSUPPORTED value is returned (can't remember the exact name)
AddRef is responsible for the increment of the reference count.
Release is responsible for the decrement of the reference count.
Thus, circular references are a real problem within COM and Garbage collection employed under .Net is one of the ways around this problem. Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What is the difference between Listview and Treeview?
|
View Answer
|
|
What are ActiveX and Types of ActiveX Components in VB
|
View Answer
|
|
How many child forms can MDI have??
|
View Answer
|
|
How to write SQL query in Database environment, the query is parameterized eg: select * from account where accno=x x: has to be taken from an Input box
|
View Answer
|
|
How can i change font of menubar in visual basic6.0?
|
View Answer
|
|
What is adUseClient and adUseServer? Where it is going to affect in runtime?
|
View Answer
|
|
For getting more values from a function which parameter should we use, out or inout ?
|
View Answer
|
|
What is typedef? explain
|
View Answer
|
|
How will u get ocx file added to your project ?
|
View Answer
|
|
What is instead of trigger ? explain
|
View Answer
|
|
Pl explain Diff between array and collection object
|
View Answer
|
|
How will u handle error in vb application ? explain
|
View Answer
|
|
How to create instance of an object in vb ? pl explain
|
View Answer
|
|
What is compatibility ?
|
View Answer
|
|
What is modal and modeless? pl explain
|
View Answer
|
|
What is overloading and overriding ? pl explain diff between them
|
View Answer
|
|
What is oops? what is polymorphism ? does vb supports oops concept in totality? pl explain
|
View Answer
|
|
Dff between OCX , DLL and EXE ?
|
View Answer
|
|
What is interface in vb? pl explain its types in vb ? and theri usage
|
View Answer
|
|
What is activex? why it is reqd in vb? pl explain its usage
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Visual Basic Interview Questions & Answers - Exam Mode /
Learning Mode
|