Win Surprise Gifts!!!
Top 5 Contributors of the Month
Post New Question
Subscribe to Interview Questions
What is object Reference Tracing?
Posted By :
Posted Date :
April 26, 2009
Object Reference Tracing is record sequential stack traces each time whenever object reference counter is incremented or decremented. These traces help to detect object reference errors, double-dereferencing, failure to reference.
You can also find related Interview Question to
What is object Reference Tracing?
Difference between a java object reference and c++ pointer.
The prime difference is that pointers are to locate the address of the primitive variables only, where as object reference locates the object in the heap.
What methods which can be called without instantiating an object first are called ?
What is a Null object?
It is an object of some class whose purpose is to indicate that a real object of that class does not exist. One common use for a null object is a return value from a member function that is supposed to return an object with some specified properties but cannot find such an object.
What is Object Oriented model?
This model is based on collection of objects. An object contains values stored in instance variables with in the object. An object also contains bodies of code that operate on the object. These bodies of code are called methods. Objects that contain same types of values and the same methods are grouped together into classes.
what are value types and reference types?
Value type - bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short, strut, uint, ulong, ushort
Value types are stored in the Stack
Reference type - class, delegate, interface, object, string
Reference types are stored in the Heap
What are Value types and Reference types?
Value types directly contain their data which are either allocated on the stack or allocated in-line in a structure. Reference types store a reference to the value's memory address, and are allocated on the heap. Reference types can be self-describing types, pointer types, or interface types. Variables that are value types each have their own copy of the data, and therefore operations on one variable do not affect other variables. Variables that are reference types can refer to the same object; therefore, operations on one variable can affect the same object referred to by another variable. All types derive from the System.Object base type.
What is Reference counting in COM ?
Reference counting is a memory management technique used to count how many times an object has a pointer referring to it. The first time it is created, the reference count is set to one. When the last reference to the object is nulled, the reference count is set to zero and the object is deleted. Care must be exercised to prevent a context switch from changing the reference count at the time of deletion. In the methods that follow, the syntax is shortened to keep the scope of the discussion brief and manageable.
How can you reference current thread of the method ?
"Thread.CurrentThread" refers to the current thread running in the method."CurrentThread" is a public static property.
How do I call a member method and pass a primitive type (Value Type) by reference?
Use the ref keyword when declaring the parameter of the method, for example:
public bool GetValue( ref int returnValue );
This will pass the numeric by reference.You can modify the value of returnValue within the body of GetValue and it will persist when the method call returns.
How can I look up a parent class method or property of any System-level object?
Use the Class View window, accessed from the standard toolbar by clicking View | Class View.
Value Types & Reference Types
In C# data types are classified into two categories-value types and reference types. The difference between value type and reference type is that the variables of value type are allocated on stack, whereas, variables of reference type are allocated on heap. Secondly, the variable of value type contains data, whereas, variable of reference type contains the address of the memory location where data of that variable is stored. Among built-in data types, all the types of integers, floats, doubles, decimals, chars and bools are value types, whereas, the string and object are reference types. Among user-defined data types, classes, interfaces and delegates are reference types, whereas, structure is a value type.
Memory allocated for objects of value types is freed when they go out of scope. Memory allocated for objects of reference types is freed when they are no more being referenced.
Both the value and reference types have advantages and disadvantages. Memory allocation on stack is faster than that on heap. So, if the object is small, we must use a value type rather than a reference type. On the other hand, if the object is big we must avoid declaring it as a value type. Because, if we assign it to any other object, its whole contents would get copied, consuming additional memory. As against this, in case of a reference type only the reference is copied rather than the whole object
Value type & reference types difference? Example from .NET. Integer & struct are value types or reference types in .NET?
Most programming languages provide builtin data types, such as integers and floatingpointnumbers, that are copied when they are passed as arguments (that is, they are passed by value). In the .NET Framework, these are called value types. The runtime
supports two kinds of value types:
The .NET Framework defines builtin
value types, such as System.Int32 and
System.Boolean, which correspond and are identical to primitive data types
used by programming languages.
Your language will provide ways to define your own value types, which derive from System.ValueType. If you want to define a type representing a value that is small, such as a complex number (using two floatingpoint numbers),
you might choose to define it as a value type because you can pass the value type efficiently by value. If the type you are defining would be more efficiently passed by reference, you should define it as a class instead.
Variables of reference types, referred to as objects, store references to the actual data. This following are the reference types:
This following are the builtin
What are value types and reference types?
Value type - bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short, strut, uint,ulong, ushort. Value types are stored in the Stack
Reference type - class, delegate, interface, object, string. Reference types are stored in the Heap
What is the difference between "using System.Data;" and directly adding the reference from "Add References Dialog Box"?
When you compiles a program using command line, u add the references using /r switch. When you compile a program using Visual Studio, it adds those references to our assembly, which are added using "Add Reference" dialog box. While "using" statement facilitates us to use classes without using their fully qualified names.
For example: if u have added a reference to "System.Data.SqlClient" using "Add Reference" dialog box then u can use SqlConnection class like this:
But if u add a "using System.Data.SqlClient" statement at the start of ur code then u can directly use SqlConnection class.
On the other hand if u add a reference using "using System.Data.SqlClient" statement, but don't add it using "Add Reference" dialog box, Visual Studio will give error message while we compile the program.
Quick Links For Interview Questions Categories:
Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.
So, Start looking our
section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.
Hall of Fame
Terms of Service
Tell A Friend