C# screen KEY

1. What is the name of the entry point function for all C# programs?

Main()

2. The C# data type int is a synonym for what CLR data type?

System.Int32

3. In C# all primitive data types and user defined data types inherit from what super object?

object

4. How is the C# string class use of == different from all other classes?

When you compare two strings with == you are actually using an overloaded version that compares the characters in the strings instead of the reference values of the two strings. So, if

string s1 = "cat";

string s2 = "cat";

Then the expression s1 == s2 returns true even though s1 and s2 point to two different objects.

5. What encoding does C# use for characters?

Unicode (16-bit)

6. What is the difference between the C# "ref" and "out" keywords when applied to method parameters?

Use "ref" when the parameter/argument has a value but the method changes it. Use "out" when the parameter/argument does not have value and the method supplies it.

7. What are the C# "checked" and "unchecked" keywords used for?

To control whether arithmetic overflow throws an exception (checked) or truncates bits (unchecked).

8. What is the difference between a C# "using" directive and a C/C++ "#include" directive?

A "using" does not add any code to the program it just tells the compiler where to find a namespace. The "include" actually adds code.

9. What is the difference between a C# struct and a C# class in terms of reference types and value types?

A struct is a value object and class is a reference object.

10. Besides "public" and "private", what other two access modifiers can a C# class take?

"protected" and "internal"

11. Why does C# use class destructors far less often that C++?

C# uses the GC (Garbage Collection) mechanism.

12. In C#, are static methods accessed through a class name, an object name, or both?

Class name only.

13. How do you make a C# class abstract (when you want to inherit from it but never implement it directly)?

Use the "abstract" modifier keyword.

14. How do you prevent a C# class from being used as a base class (inherited from)?

Use the "sealed" modifier keyword.

15. C# does not support multiple inheritance. What C# mechanism allows you to have a semblance of multiple inheritance functionality?

Interfaces

16. What are the two kinds of C# properties?

get and set

17. Syntactically, what is the difference between calling a method and a property?

Methods require parentheses, properties do not use parentheses.

18. What is the approximate C# equivalent to a C++ function pointer?

delegate

19. What C# keyword do you use to implement a variable length argument list?

params

20. In C# if you must use pointers, how do you do it?

Use the "unsafe" keyword.

WINFORMS:

  • Which properties on a Windows Forms Control allow you to control it's layout? (Answer: Docking and Anchoring)
  • What method do you call on a Windows Forms Control or drawing object when you are done using it (Answer: Dispose)
  • When will an object be eligable for garbage collection? (Answer: when no other objects are referencing it)

1. How many SQL database tables are required to track the following info?

Customer

Purchase order number

Purchase order date

Purchased items

Purchase price for each item

Assuming that:

Same customer can make multiple purchases on different or same dates

One purchase order can contain multiple items

All items have specific item numbers

Solution: three tables;

Customer table – that will contain customer’s information like address, …

Items table – that will contain product type, manufacturing company, expiration date, …

Order table – that will contain item number, customer id, quantity ordered, date of purchase …

2. Generate all possible test scenarios and test cases to test a pencil sharper

Solution:

I use new pencils and check whether the machine sharpens well or not.

I use a used pencil with core too short that needs re-sharpening and check whether the machine sharpens well or not.

I use pencils with cores of different core size but same material and see how fast the machine will sharpen.

I use the machine continuously for a long period of time and check whether the blade gets blunt quickly or not.

I will check how long will it take for the chipping container filled to capacity and see the impact on its usage.

I will check how economical is the sharpener. Does it chop muck core? …

I push the pencil and see how resistant is the machine. I will check whether it shatter or break the exposed core entirely and check whether the impact be mitigated or not.

I will try sharpening with a clean piece of paper spread before me and check whether litter the place with chopped pieces of black core and other chippings or not.

I will check whether the machine is easy to use or not. I will check whether its sharpening blade is well covered or not.

I will check the protection /security mechanisms –

Protection from theft,

Whether I can protect unauthorized users from using or harm it.

3. What's the difference between a Queue and a Stack? What data structure would be used implement a Stack and a Queue.

Solution:

Difference between a Queue and a Stack:

A stack is a list in which deletion and insertion of elements can occur only in one designated position called the top of the stack. It applies LIFO (Last in first out manipulation of insertion and deletion of elements). The right most element is the top of the stack.

Queue is a list in which elements are added to the rear (enque) and removed from the front (dequeue). It applies FIFO (First in first out manipulation of insertion and deletion of elements).

We use a linked list data structure to implement any of the two efficiently.

4. What's the big O order of binary search?

Solution:

Order of ( log N) – where the logarithm is in base two.

.Net Related

Does C# support multiple inheritance?
No, use interfaces instead.

What’s the implicit name of the parameter that gets passed into the class’ set method?
Value, and its datatype depends on whatever variable we’re changing.

What’s the top .NET class that everything is derived from?
System.Object.

How’s method overriding different from overloading?
When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.

What is CLR?
The .NET Framework provides a runtime environment called the Common Language Runtime or CLR (similar to the Java Virtual Machine or JVM in Java), which handles the execution of code and provides useful services for the implementation of the program. CLR takes care of code management at program execution and provides various beneficial services such as memory management, thread management, security management, code verification, compilation, and other system services. The managed code that targets CLR benefits from useful features such as cross-language integration, cross-language exception handling, versioning, enhanced security, deployment support, and debugging.

What is CTS?
Common Type System (CTS) describes how types are declared, used and managed in the runtime and facilitates cross-language integration, type safety, and high performance code execution.

What is CLS?
The CLS is simply a specification that defines the rules to support language integration in such a way that programs written in any language, yet can interoperate with one another, taking full advantage of inheritance, polymorphism, exceptions, and other features. These rules and the specification are documented in the ECMA proposed standard document, "Partition I Architecture", http://msdn.microsoft.com/net/ecma.

What is strong name?
A name that consists of an assembly's identity—its simple text name, version number, and culture information (if provided)—strengthened by a public key and a digital signature generated over the assembly.

What is Application Domain?
The primary purpose of the AppDomain is to isolate an application from other applications. Win32 processes provide isolation by having distinct memory address spaces. This is effective, but it is expensive and doesn't scale well. The .NET runtime enforces AppDomain isolation by keeping control over the use of memory - all memory in the AppDomain is managed by the .NET runtime, so the runtime can ensure that AppDomains do not access each other's memory. Objects in different application domains communicate either by transporting copies of objects across application domain boundaries, or by using a proxy to exchange messages.

What is serialization in .NET? What are the ways to control serialization?
Serialization is the process of converting an object into a stream of bytes. Deserialization is the opposite process of creating an object from a stream of bytes. Serialization/Deserialization is mostly used to transport objects (e.g. during remoting), or to persist objects (e.g. to a file or database).Serialization can be defined as the process of storing the state of an object to a storage medium. During this process, the public and private fields of the object and the name of the class, including the assembly containing the class, are converted to a stream of bytes, which is then written to a data stream. When the object is subsequently deserialized, an exact clone of the original object is created. Binary serialization preserves type fidelity, which is useful for preserving the state of an object between different invocations of an application. For example, you can share an object between different applications by serializing it to the clipboard. You can serialize an object to a stream, disk, memory, over the network, and so forth. Remoting uses serialization to pass objects "by value" from one computer or application domain to another. XML serialization serializes only public properties and fields and does not preserve type fidelity. This is useful when you want to provide or consume data without restricting the application that uses the data. Because XML is an open standard, it is an attractive choice for sharing data across the Web. SOAP is an open standard, which makes it an attractive choice. There are two separate mechanisms provided by the .NET class library - XmlSerializer and SoapFormatter/BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and uses SoapFormatter/BinaryFormatter for remoting. Both are available for use in your own code.

What are Satellite Assemblies?
Satellite assemblies are often used to deploy language-specific resources for an application. These language-specific assemblies work in side-by-side execution because the application has a separate product ID for each language and installs satellite assemblies in a language-specific subdirectory for each language. When uninstalling, the application removes only the satellite assemblies associated with a given language and .NET Framework version. No core .NET Framework files are removed unless the last language for that .NET Framework version is being removed.

What is Global Assembly Cache (GAC) and what is the purpose of it?
Each computer where the common language runtime is installed has a machine-wide code cache called the global assembly cache. The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer. You should share assemblies by installing them into the global assembly cache only when you need to.

What is Reflection in .NET?
All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.

What is the managed and unmanaged code in .net?
The .NET Framework provides a run-time environment called the Common Language Runtime, which manages the execution of code and provides services that make the development process easier. Compilers and tools expose the runtime's functionality and enable you to write code that benefits from this managed execution environment. Code that you develop with a language compiler that targets the runtime is called managed code; it benefits from features such as cross-language integration, cross-language exception handling, enhanced security, versioning and deployment support, a simplified model for component interaction, and debugging and profiling services.

What are Namespaces?
The namespace keyword is used to declare a scope. This namespace scope lets you organize code and gives you a way to create globally-unique types. Even if you do not explicitly declare one, a default namespace is created. This unnamed namespace, sometimes called the global namespace, is present in every file. Any identifier in the global namespace is available for use in a named namespace. Namespaces implicitly have public access and this is not modifiable.

What are the access-specifiers available in c#?
Private, Protected, Public, Internal, Protected Internal.

Advantage of ADO.Net?
  • ADO.NET Does Not Depend On Continuously Live Connections
  • Database Interactions Are Performed Using Data Commands
  • Data Can Be Cached in Datasets
  • Datasets Are Independent of Data Sources
  • Data Is Persisted as XML
  • Schemas Define Data Structures
Difference between OLEDB Provider and SqlClient ?
SQLClient .NET classes are highly optimized for the .net / sqlserver combination and achieve optimal results. The SqlClient data provider is fast. It's faster than the Oracle provider, and faster than accessing database via the OleDb layer. It's faster because it accesses the native library (which automatically gives you better performance), and it was written with lots of help from the SQL Server team.

Differences between dataset.clone and dataset.copy?
Clone - Copies the structure of the DataSet, including all DataTable schemas, relations, and constraints.Does not copy any data
Copy - Copies both the structure and data for this DataSet.

In a Webservice, need to display 10 rows from a table. So DataReader or DataSet is best choice?
WebService will support only DataSet.

What is Remoting?
The process of communication between different operating system processes, regardless of whether they are on the same computer. The .NET remoting system is an architecture designed to simplify communication between objects living in different application domains, whether on the same computer or not, and between different contexts, whether in the same application domain or not.

What’s the difference between System.String and System.StringBuilder classes?
System.String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

What’s a delegate?
A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.

What’s an interface class?
It’s an abstract class with public abstract methods all of which must be implemented in the inherited classes.

What is the transport protocol you use to call a Web service ?
SOAP is the preferred protocol.