1. What is Windows Presentation Foundation, WPF?
WPF allows creating rich application with respect to look and feel. The rich classes of WPF along with a design engine allow you to make innovative interfaces and client applications with 3D images, animation that is not available using HTML
2. What are the different documents supported in WPF?
The different documents supported by WPF are mainly fixed documents and flow documents. Fixed documents are used for what you see is what you get (WYSIWYG) applications. In such applications observance to the original design is important. E.g. Desktop applications Flow documents concentrate more on optimize viewing and readability., rather than using a “fixed” layout, flow documents adjust their content based on values of runtime variables. Adjusting content will also include adjusting size, resolution etc. E.g. a Web page.
3. What is XAML?
Extensible Application Markup Language is a XML based language used to create rich GUI’s. It supports both vector and bitmap images. These files are XML files with .xaml extension. It can be used for creating graphical effects. XAML allows creating visible UI elements and separate the UI definition from the programming logic.
4.What is XAML?
Extensible Application Markup Language is a XML based language used to create rich GUI’s. It supports both vector and bitmap images. These files are XML files with .xaml extension. It can be used for creating graphical effects. XAML allows creating visible UI elements and separate the UI definition from the programming logic.
6. Define Watch window?
Watch window is used to watch the values of application variables in Break mode.
7.Name the namespace for Web page in ASP.NET
System.Web.UI.Page
8. Write difference between overloading and overriding.
Overriding - Methods have the same signature as the parent class method.
Overloading - Methods have different parameters list or type or the return type.
9.Write namespace for user locale in ASP.NET
System.Web.UI.Page.Culture
10.Advantages and disadvantages of using multithreading
Advantages:
Simultaneous access to multiple applications
Reduced number of required servers
Improved performance and concurrency
Simplified coding of remote procedure calls and conversations
Disadvantages:
Code writing, debugging, managing concurrency, testing, porting existing code is difficult in multithreading and multicontexting.
Programmers need to remove static variables and replace any code that is not thread-safe to introduce threading into a previously non threaded application.
11.How does multi-threading work in .NET?
There are two main ways of multi-threading which .NET encourages:
To start your own threads with ThreadStart delegates, you should create a new thread "manually" for long-running tasks.
Using the ThreadPool class either directly (using ThreadPool.QueueUserWorkItem) or indirectly using asynchronous methods (such as Stream.BeginRead, or calling BeginInvoke on any delegate).
Use the thread pool only for brief jobs.
12. Benefits of using the Thread Pool.
Benefits of using the Thread Pool.
The benefits of using a Thread Pool are:
Thread creation and destruction overhead is negated,
Better performance and better system stability.
It is better to use a thread pool in cases where the number of threads is very large.
13.Limitations of using the Thread Pool.
A thread pool executes on a single processor. But they are theoretically associated to server farms in which a master process distributes tasks to worker processes on different computers to increase the overall throughput.
However, parallel problems are highly open to this approach.
14.Explain how to create and manage threads using Thread class in the System.Threading namespace in .NET.
using System.Threading;
private void ThreadTask()
{
int x;
int val;
Random r=new Random();
while(true)
{
x=this.progressBar1.Step*r.Next(-1,2);
val = this.progressBar1.Value + x;
if (val > this.progressBar1.Maximum)
val = this.progressBar1.Maximum;
else if (val < this.progressBar1.Minimum)
val = this.progressBar1.Minimum;
this.progressBar1.Value = val;
Thread.Sleep(100);
}
}
You need to write these lines first:
Thread t1 = new Thread(new ThreadStart(this.ThreadTask));
t1.IsBackground = true;
t1.Start();
15.Explain the purpose of Mutex class in .NET.
System uses synchronization mechanism to make sure that a resource is used by only one thread at a time when more than one thread needs to access a shared resource at the same time.
Mutex grants exclusive access to the shared resource to a single thread.
A second thread that needs to acquire a particular mutex is suspended until the first thread releases the mutex.
16.Describe the concepts of Monitor class, the interlocked class and the ReaderWriterLock class.
Access to objects by is controlled by the Monitor class. It grants a lock for an object to a single thread.
Critical sections can be access restricted by using object locks.
While a thread owns the lock for an object, no other thread can acquire that lock.
Interlocked class provides atomic operations for variables that are shared by multiple threads.
When two threads are executing concurrently on separate processors error protection is done.
The methods of this class help protect against errors that can occur when the scheduler switches contexts while a thread is updating a variable that can be accessed by other threads.
ReaderWriterLock synchronizes access to a resource. It allows either concurrent read access for multiple threads, or write access for a single thread.
A ReaderWriterLock provides better throughput than a simple one lock a time like Monitor.
18.Explain about Serialization in .NET. Explain binary serialization and XML serialization
System.Runtime.Serialization namespace provides Serialization in .NET.
The IFormatter interface in the namespace contains Serialize and De-serialize methods that save and load data of a stream.
So we need stream as a container for the serialized object(s) and a formatter that serializes these objects onto the stream to implement serialization in .net.
Binary serialization is a mechanism that creates exact binary copy of the object onto the storage media by writing the data to the output stream such that it can be used to re-construct the object automatically.
XML serialization results in strongly typed classes with public properties and fields that are converted to a serial format for storage or transport. This XML stream conforms to a specific XML Schema definition language (XSD) document.
19.Explain why Serialization.
An object is stored in a file, a database or even in the memory. However, data to be transferred over a network needs to be in a linear form for which serialization and deserialization are used.
Advantage of serialization is the ability of an object to be serialized into a persistent or a non-persistent storage media and then reconstructing the same object later by de-serializing the object.
Remoting and Web Services depend heavily on Serialization and De-serialization.
20.Explain the components that comprise the binary serialization architecture.
To binary serialize an object we need a FileStream object,
Constructor: FileStream(file_name, FileMode.Create);
And
BinaryFormatter
Constructor: binaryFormatter.Serialize(fileStreamObject, object1);
21.What is Formatters? Explain the binary formatter and the SOAP formatter.
A formatter determines the serialization format for objects.
.NET framework provides Binary formatter and SOAP formatter which inherit from the IFormatter interface
The Binary Formatter
It provides binary encoding for compact serialization for storage or socket-based network streams.
It is not appropriate for data to be passed through a firewall.
The SOAP Formatter
It provides formatting that can be used to enable objects to be serialized using the SOAP protocol.
The class is used for serialization through firewalls or diverse systems.
22.What are the main advantages of binary serialization?
An object is stored in a file, a database or even in the memory. However, data to be transferred over a network needs to be in a linear form for which serialization and deserialization are used.
Advantage of serialization is the ability of an object to be serialized into a persistent or a non-persistent storage media and then reconstructing the same object later by de-serializing the object.
Also Binary Serialization is faster, supports complex objects too with read only properties and even circular references.
23.How do you encapsulate the binary serialization?
public static void SerializeBinary( object o, string file_name)
{
using (FileStream fs = new FileStream(file_name, FileMode.Create)) {
BinaryFormatter fmt = new BinaryFormatter ();
fmt.Serialize(fs, o);
}
}
24.How do you implement a custom serialization?
CUSTOM SERIALIZATION implementation
public class A: ISerializable
{
private int a;
protected A(SerializationInfo si, StreamingContext sc)
{
this.a = serializationInfo.GetInt32("a");
}
public void ISerializable.GetObjectData(SerializationInfo si, StreamingContext sc)
{
si.AddValue("a", this.a);
}
}
25.What is the difference between the SoapFormatter and the XmlSerializer?
SoapFormatter
SOAP formatter will actually take the field values of an object and store all of that information in the stream passed.
SoapFormatter is better to serialize arbitrary data
XmlSerializer
XML Serialization would just serialize the public properties of an object.
The XML Serializer is used typically for serializing simple types across web services
xmlserializer is better, more flexible and faster
26.How can I optimize the serialization process?
The first call to a Web Service takes long because XmlSerializer generate an assembly optimized for each type in memory.
To optimize the serialization process pregeneration of serialization assembly with Visual Studio or sgen.exe is needed.
Implementing serialization separately can also increase the performance.
WPF allows creating rich application with respect to look and feel. The rich classes of WPF along with a design engine allow you to make innovative interfaces and client applications with 3D images, animation that is not available using HTML
2. What are the different documents supported in WPF?
The different documents supported by WPF are mainly fixed documents and flow documents. Fixed documents are used for what you see is what you get (WYSIWYG) applications. In such applications observance to the original design is important. E.g. Desktop applications Flow documents concentrate more on optimize viewing and readability., rather than using a “fixed” layout, flow documents adjust their content based on values of runtime variables. Adjusting content will also include adjusting size, resolution etc. E.g. a Web page.
3. What is XAML?
Extensible Application Markup Language is a XML based language used to create rich GUI’s. It supports both vector and bitmap images. These files are XML files with .xaml extension. It can be used for creating graphical effects. XAML allows creating visible UI elements and separate the UI definition from the programming logic.
4.What is XAML?
Extensible Application Markup Language is a XML based language used to create rich GUI’s. It supports both vector and bitmap images. These files are XML files with .xaml extension. It can be used for creating graphical effects. XAML allows creating visible UI elements and separate the UI definition from the programming logic.
6. Define Watch window?
Watch window is used to watch the values of application variables in Break mode.
7.Name the namespace for Web page in ASP.NET
System.Web.UI.Page
8. Write difference between overloading and overriding.
Overriding - Methods have the same signature as the parent class method.
Overloading - Methods have different parameters list or type or the return type.
9.Write namespace for user locale in ASP.NET
System.Web.UI.Page.Culture
10.Advantages and disadvantages of using multithreading
Advantages:
Simultaneous access to multiple applications
Reduced number of required servers
Improved performance and concurrency
Simplified coding of remote procedure calls and conversations
Disadvantages:
Code writing, debugging, managing concurrency, testing, porting existing code is difficult in multithreading and multicontexting.
Programmers need to remove static variables and replace any code that is not thread-safe to introduce threading into a previously non threaded application.
11.How does multi-threading work in .NET?
There are two main ways of multi-threading which .NET encourages:
To start your own threads with ThreadStart delegates, you should create a new thread "manually" for long-running tasks.
Using the ThreadPool class either directly (using ThreadPool.QueueUserWorkItem) or indirectly using asynchronous methods (such as Stream.BeginRead, or calling BeginInvoke on any delegate).
Use the thread pool only for brief jobs.
12. Benefits of using the Thread Pool.
Benefits of using the Thread Pool.
The benefits of using a Thread Pool are:
Thread creation and destruction overhead is negated,
Better performance and better system stability.
It is better to use a thread pool in cases where the number of threads is very large.
13.Limitations of using the Thread Pool.
A thread pool executes on a single processor. But they are theoretically associated to server farms in which a master process distributes tasks to worker processes on different computers to increase the overall throughput.
However, parallel problems are highly open to this approach.
14.Explain how to create and manage threads using Thread class in the System.Threading namespace in .NET.
using System.Threading;
private void ThreadTask()
{
int x;
int val;
Random r=new Random();
while(true)
{
x=this.progressBar1.Step*r.Next(-1,2);
val = this.progressBar1.Value + x;
if (val > this.progressBar1.Maximum)
val = this.progressBar1.Maximum;
else if (val < this.progressBar1.Minimum)
val = this.progressBar1.Minimum;
this.progressBar1.Value = val;
Thread.Sleep(100);
}
}
You need to write these lines first:
Thread t1 = new Thread(new ThreadStart(this.ThreadTask));
t1.IsBackground = true;
t1.Start();
15.Explain the purpose of Mutex class in .NET.
System uses synchronization mechanism to make sure that a resource is used by only one thread at a time when more than one thread needs to access a shared resource at the same time.
Mutex grants exclusive access to the shared resource to a single thread.
A second thread that needs to acquire a particular mutex is suspended until the first thread releases the mutex.
16.Describe the concepts of Monitor class, the interlocked class and the ReaderWriterLock class.
Access to objects by is controlled by the Monitor class. It grants a lock for an object to a single thread.
Critical sections can be access restricted by using object locks.
While a thread owns the lock for an object, no other thread can acquire that lock.
Interlocked class provides atomic operations for variables that are shared by multiple threads.
When two threads are executing concurrently on separate processors error protection is done.
The methods of this class help protect against errors that can occur when the scheduler switches contexts while a thread is updating a variable that can be accessed by other threads.
ReaderWriterLock synchronizes access to a resource. It allows either concurrent read access for multiple threads, or write access for a single thread.
A ReaderWriterLock provides better throughput than a simple one lock a time like Monitor.
18.Explain about Serialization in .NET. Explain binary serialization and XML serialization
System.Runtime.Serialization namespace provides Serialization in .NET.
The IFormatter interface in the namespace contains Serialize and De-serialize methods that save and load data of a stream.
So we need stream as a container for the serialized object(s) and a formatter that serializes these objects onto the stream to implement serialization in .net.
Binary serialization is a mechanism that creates exact binary copy of the object onto the storage media by writing the data to the output stream such that it can be used to re-construct the object automatically.
XML serialization results in strongly typed classes with public properties and fields that are converted to a serial format for storage or transport. This XML stream conforms to a specific XML Schema definition language (XSD) document.
19.Explain why Serialization.
An object is stored in a file, a database or even in the memory. However, data to be transferred over a network needs to be in a linear form for which serialization and deserialization are used.
Advantage of serialization is the ability of an object to be serialized into a persistent or a non-persistent storage media and then reconstructing the same object later by de-serializing the object.
Remoting and Web Services depend heavily on Serialization and De-serialization.
20.Explain the components that comprise the binary serialization architecture.
To binary serialize an object we need a FileStream object,
Constructor: FileStream(file_name, FileMode.Create);
And
BinaryFormatter
Constructor: binaryFormatter.Serialize(fileStreamObject, object1);
21.What is Formatters? Explain the binary formatter and the SOAP formatter.
A formatter determines the serialization format for objects.
.NET framework provides Binary formatter and SOAP formatter which inherit from the IFormatter interface
The Binary Formatter
It provides binary encoding for compact serialization for storage or socket-based network streams.
It is not appropriate for data to be passed through a firewall.
The SOAP Formatter
It provides formatting that can be used to enable objects to be serialized using the SOAP protocol.
The class is used for serialization through firewalls or diverse systems.
22.What are the main advantages of binary serialization?
An object is stored in a file, a database or even in the memory. However, data to be transferred over a network needs to be in a linear form for which serialization and deserialization are used.
Advantage of serialization is the ability of an object to be serialized into a persistent or a non-persistent storage media and then reconstructing the same object later by de-serializing the object.
Also Binary Serialization is faster, supports complex objects too with read only properties and even circular references.
23.How do you encapsulate the binary serialization?
public static void SerializeBinary( object o, string file_name)
{
using (FileStream fs = new FileStream(file_name, FileMode.Create)) {
BinaryFormatter fmt = new BinaryFormatter ();
fmt.Serialize(fs, o);
}
}
24.How do you implement a custom serialization?
CUSTOM SERIALIZATION implementation
public class A: ISerializable
{
private int a;
protected A(SerializationInfo si, StreamingContext sc)
{
this.a = serializationInfo.GetInt32("a");
}
public void ISerializable.GetObjectData(SerializationInfo si, StreamingContext sc)
{
si.AddValue("a", this.a);
}
}
25.What is the difference between the SoapFormatter and the XmlSerializer?
SoapFormatter
SOAP formatter will actually take the field values of an object and store all of that information in the stream passed.
SoapFormatter is better to serialize arbitrary data
XmlSerializer
XML Serialization would just serialize the public properties of an object.
The XML Serializer is used typically for serializing simple types across web services
xmlserializer is better, more flexible and faster
26.How can I optimize the serialization process?
The first call to a Web Service takes long because XmlSerializer generate an assembly optimized for each type in memory.
To optimize the serialization process pregeneration of serialization assembly with Visual Studio or sgen.exe is needed.
Implementing serialization separately can also increase the performance.
No comments:
Post a Comment