Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Dot net-interview-questions-and-answers part ii

29 visualizaciones

Publicado el

To know more details on .NET click here and call us:- http://bigclasses.com/dot-net-online-..., +91 800 811 4040 BigClasses.com offers the best advanced .net online training in the IT industry. We provide job oriented training with real time work exposure with real time working experts. We deliver the advanced .net training with all the new concepts and techniques to make you understand in a very easy and efficient way. Our Dot net training includes with repositories for all WCF queries. Concurrency, Throttling and Callbacks WCF concurrency (Single, Multiple and Reentrant) and throttling WCF Interop and Binary Security Token WCF Callbacks To know more details on .NET click here and call us:- https://goo.gl/QcQKqN, +91 800 811 4040 For regular Updates on ASP.NET please like our Facebook page:- Facebook:- https://www.facebook.com/bigclasses/ Twitter:- https://twitter.com/bigclasses LinkedIn:- https://www.linkedin.com/company/bigc... Google+: https://plus.google.com/+Bigclasseson... .NET Course Page:- http://bigclasses.com/dot-net-online-...

Publicado en: Educación
  • Sé el primero en comentar

Dot net-interview-questions-and-answers part ii

  1. 1. Frequently Asked Interview Questions PART 2
  2. 2. There is a once-per-process-per-type overhead with XmlSerializer. So the first time you serialize or deserialize an object of a given type in an application, there is a significant delay. This normally doesn't matter, but it may mean, for example, that XmlSerializer is a poor choice for loading configuration settings during startup of a GUI application. 51.Why is XmlSerializer so slow?
  3. 3. The JIT compiler is an important element of CLR, which loads MSIL on target machines for execution. The MSIL is stored in .NET assemblies after the developer has compiled the code written in any .NET- compliant programming language, such as Visual Basic and C#. JIT compiler translates the MSIL code of an assembly and uses the CPU architecture of the target machine to execute a .NET application. It also stores the resulting native code so that it is accessible for subsequent calls. If a code executing on a target machine calls a non-native method, the JIT compiler converts the MSIL of that method into native code. JIT compiler also enforces type-safety in runtime environment of .NET Framework. It checks for the values that are passed to parameters of any method. For example, the JIT compiler detects any event, if a user tries to assign a 32-bit value to a parameter that can only accept 8-bit value. 52.What is the role of the JIT compiler in .NET Framework?
  4. 4. XmlSerializer will refuse to serialize instances of any class that implements IDictionary, e.g. Hashtable. SoapFormatter and BinaryFormatter do not have this restriction. 53.Why do I get errors when I try to serialize a Hashtable?
  5. 5. String and StringBuilder classes are used to store string values but the difference in them is that String is immutable (read only) by nature, because a value once assigned to a String object cannot be changed after its creation. When the value in the String object is modified, a new object is created, in memory, with a new value assigned to the String object. On the other hand, the StringBuilder class is mutable, as it occupies the same space even if you change the value. The StringBuilder class is more efficient where you have to perform a large amount of string manipulation. 54.What is difference between System.String and System.StringBuilder classes?
  6. 6. XmlSerializer needs to know in advance what type of objects it will find in an ArrayList. To specify the type, use the XmlArrayItem attibute like this: public class Person{ public string Name; public int Age; } public class Population{ [XmlArrayItem(typeof(Person))] public ArrayList People; } 55.Why am I getting an InvalidOperationException when I serialize an ArrayList?
  7. 7. CLR provides an environment to execute .NET applications on target machines. CLR is also a common runtime environment for all .NET code irrespective of their programming language, as the compilers of respective language in .NET Framework convert every source code into a common language known as MSIL or IL (Intermediate Language). CLR also provides various services to execute processes, such as memory management service and security services. CLR performs various tasks to manage the execution process of .NET applications. The responsibilities of CLR are listed as follows: Automatic memory management Garbage Collection Code Access Security Code verification JIT compilation of .NET code 56.Describe the roles of CLR in .NET Framework?
  8. 8. There are at least two types of .NET attribute. The first type I will refer to as a metadata attribute - it allows some data to be attached to a class or method. This data becomes part of the metadata for the class, and (like other class metadata) can be accessed via reflection. An example of a metadata attribute is [serializable], which can be attached to a class and means that instances of the class can be serialized. [serializable] public class CTest {} The other type of attribute is a context attribute. Context attributes use a similar syntax to metadata attributes but they are fundamentally different. Context attributes provide an interception mechanism whereby instance activation and method calls can be pre- and/or post-processed. If you have encountered Keith Brown's universal delegator you'll be familiar with this idea. 57.What are attributes?
  9. 9. There is no difference between int and int32. System.Int32 is a .NET Class and int is an alias name for System.Int32. 58.What is the difference between int and int32?
  10. 10. The CAS security policy revolves around two key concepts - code groups and permissions. Each .NET assembly is a member of a particular code group, and each code group is granted the permissions specified in a named permission set. For example, using the default security policy, a control downloaded from a web site belongs to the 'Zone - Internet' code group, which adheres to the permissions defined by the 'Internet' named permission set. (Naturally the 'Internet' named permission set represents a very restrictive range of permissions.) 59.How does CAS work?
  11. 11. A variable can be defined as a meaningful name that is given to a data storage location in the computer memory that contains a value. Every variable associated with a data type determines what type of value can be stored in the variable, for example an integer, such as 100, a decimal, such as 30.05, or a character, such as 'A'. You can declare variables by using the following syntax: <Data_type> <variable_name> ; A constant is similar to a variable except that the value, which you assign to a constant, cannot be changed, as in case of a variable. Constants must be initialized at the same time they are declared. You can declare constants by using the following syntax: const int interestRate = 10; 60.Define variable and constant?
  12. 12. Caspol has a couple of options that might help. First, you can ask caspol to tell you what code group an assembly belongs to, using caspol -rsg. Similarly, you can ask what permissions are being applied to a particular assembly using caspol -rsp. 61.I'm having some trouble with CAS. How can I troubleshoot the problem?
  13. 13. A data type is a data storage format that can contain a specific type or range of values. Whenever you declare variables, each variable must be assigned a specific data type. Some common data types include integers, floating point, characters, and strings. The following are the two types of data types available in .NET: Value type - Refers to the data type that contains the data. In other words, the exact value or the data is directly stored in this data type. It means that when you assign a value type variable to another variable, then it copies the value rather than copying the reference of that variable. When you create a value type variable, a single space in memory is allocated to store the value (stack memory). Primitive data types, such as int, float, and char are examples of value type variables. Reference type - Refers to a data type that can access data by reference. Reference is a value or an address that accesses a particular data by address, which is stored elsewhere in memory (heap memory). You can say that reference is the physical address of data, where the data is stored in memory or in the storage device. Some built-in reference types variables in .Net are string, array, and object. 62.What is a data type? How many types of data types are there in .NET?
  14. 14. Yes, it is often relatively straightforward to regenerate high-level source from IL. Lutz Roeder's Reflector does a very good job of turning IL into C# or VB.NET. 63.Can source code be reverse-engineered from IL?
  15. 15. Variables that are defined in a C# program belong to two major categories: value type and reference type. The variables that are based on value type contain a value that is either allocated on a stack or allocated in-line in a structure. The variables that are based on reference types store the memory address of a variable, which in turn stores the value and are allocated on the heap. The variables that are based on value types have their own copy of data and therefore operations done on one variable do not affect other variables. The reference-type variables reflect the changes made in the referring variables. Predict the output of the following code segment: int x = 42; int y = 12; int w; object o; o = x; w = y * (int)o; Console.WriteLine(w); /* The output of the code is 504. */ 64.Mention the two major categories that distinctly classify the variables of C# programs?
  16. 16. You can buy an IL obfuscation tool. These tools work by 'optimising' the IL in such a way that reverse-engineering becomes much more difficult. Of course if you are writing web services then reverse-engineering is not a problem as clients do not have access to your IL. 65.How can I stop my code being reverse-engineered from IL?
  17. 17. In .NET, the namespace keyword is used to declare a namespace in the code. The syntax for declaring a namespace in C# is: namespace UserNameSpace; The syntax for declaring a namespace in VB is: Namespace UserNameSpace 66.What is the syntax to declare a namespace in .NET?
  18. 18. Yes. Peter Drayton posted this simple example to the DOTNET mailing list: .assembly MyAssembly {} .class MyApp { .method static void Main() { .entrypoint ldstr "Hello, IL!" call void System.Console::WriteLine(class System.Object) ret } } Just put this into a file called hello.il, and then run ilasm hello.il. An exe assembly will be generated. 67.Can I write IL programs directly?
  19. 19. Constants perform the same tasks as read-only variables with some differences. The differences between constants and read-only are Constants: 1. Constants are dealt with at compile-time. 2. Constants supports value-type variables. 3. Constants should be used when it is very unlikely that the value will ever change. Read-only: 1. Read-only variables are evaluated at runtime. 2. Read-only variables can hold reference type variables. 3. Read-only variables should be used when run-time calculation is required. 68.What is the difference between constants and read-only variables that are used in programs?
  20. 20. Yes. A couple of simple examples are that you can throw exceptions that are not derived from System.Exception, and you can have non-zero-based arrays. 69.Can I do things in IL that I can't do in C#?
  21. 21. The while and for loops are used to execute those units of code that need to be repeatedly executed, unless the result of the specified condition evaluates to false. The only difference between the two is in their syntax. The for loop is distinguished by setting an explicit loop variable. 70.Differentiate between the while and for loop in C#.
  22. 22. Pretty much, for .NET developers. The .NET Framework has a new remoting model which is not based on DCOM. DCOM was pretty much dead anyway, once firewalls became widespread and Microsoft got SOAP fever. Of course DCOM will still be used in interop scenarios. 71.Is DCOM dead?
  23. 23. Identifiers are northing but names given to various entities uniquely identified in a program. The name of identifiers must differ in spelling or casing. For example, MyProg and myProg are two different identifiers. Programming languages, such as C# and Visual Basic, strictly restrict the programmers from using any keyword as identifiers. Programmers cannot develop a class whose name is public, because, public is a keyword used to specify the accessibility of data in programs. 72.What is an identifier?
  24. 24. Not immediately. The approach for .NET 1.0 was to provide access to the existing COM+ services (through an interop layer) rather than replace the services with native .NET ones. Various tools and attributes were provided to make this as painless as possible. Over time it is expected that interop will become more seamless - this may mean that some services become a core part of the CLR, and/or it may mean that some services will be rewritten as managed code which runs on top of the CLR. For more on this topic, search for postings by Joe Long in the archives - Joe is the MS group manager for COM+. Start with this message: http://discuss.develop.com/archives/wa.exe?A2=ind0007&L=DOTNET&P=R6 8370 73.Is COM+ dead?
  25. 25. The switch statement is a selection control statement that is used to handle multiple choices and transfer control to the case statements within its body. The following code snippet shows an example of the use of the switch statement in C#: switch(choice) { case 1: console.WriteLine("First"); break; case 2: console.WriteLine("Second"); break; default: console.WriteLine("Wrong choice"); break; } In switch statements, the break statement is used at the end of a case statement. The break statement is mandatory in C# and it avoids the fall through of one case statement to another. 74.What does a break statement do in the switch statement?
  26. 26. The configuration file is really only for settings configured at deployment time. It can be used to deal with versioning issues with .NET components. And it's often used for connections strings - it's useful to be able to deploy an application to connect to a test or staging server, but this is not something you'd normally change in production once the application is deployed. 75.So What Exactly Is The Configuration File For Then?
  27. 27. Keywords are those words that are reserved to be used for a specific task. These words cannot be used as identifiers. You cannot use a keyword to define the name of a variable or method. Keywords are used in programs to use the features of object-oriented programming. For example, the abstract keyword is used to implement abstraction and the inherits keyword is used to implement inheritance by deriving subclasses in C# and Visual Basic, respectively. The new keyword is universally used in C# and Visual Basic to implement encapsulation by creating objects. 76.Explain keywords with example?
  28. 28. An event is just a wrapper for a multicast delegate. Adding a public event to a class is almost the same as adding a public multicast delegate field. In both cases, subscriber objects can register for notifications, and in both cases the publisher object can send notifications to the subscribers. However, a public multicast delegate has the undesirable property that external objects can invoke the delegate, something we'd normally want to restrict to the publisher. Hence events - an event adds public methods to the containing class to add and remove receivers, but does not make the invocation mechanism public. 77.What is the difference between an event and a delegate?
  29. 29. The variables that are based on value types directly contain values. The characteristics of value-type variables that are supported in C# programming language are as follows: All value-type variables derive implicitly from the System.ValueType class You cannot derive any new type from a value type Value types have an implicit default constructor that initializes the default value of that type The value type consists of two main categories: o Structs - Summarizes small groups of related variables. o Enumerations - Consists of a set of named constants. 78.Briefly explain the characteristics of value-type variables that are supported in the C# programming language?
  30. 30. Generics, anonymous methods, partial classes, iterators, property visibility (separate visibility for get and set) and static classes. See http://msdn.microsoft.com/msdnmag/issues/04/05/C20/default.aspx for more information about these features. 79.What are the new features of .NET 2.0?
  31. 31. The syntax of using the while loop in C# is: while(condition) //condition { //statements } You can find an example of using the while loop in C#: int i = 0; while(i < 5) { Console.WriteLine("{0} ", i); i++; } The output of the preceding code is: 0 1 2 3 4 . 80.Give the syntax of using the while loop in a C# program.
  32. 32. Here is a selection of new features in the .NET 2.0 class library (beta 1): � Generic collections in the System.Collections.Generic namespace. � The System.Nullable<T> type. (Note that C# has special syntax for this type, e.g. int? is equivalent to Nullable<int>) � The GZipStream and DeflateStream classes in the System.IO.Compression namespace. � The Semaphore class in the System.Threading namespace. � Wrappers for DPAPI in the form of the ProtectedData and ProtectedMemory classes in the System.Security.Cryptography namespace. � The IPC remoting channel in the System.Runtime.Remoting.Channels.Ipc namespace, for optimised intra-machine communication. 81.What's new in the .NET 2.0 class library?
  33. 33. The variables that are based on reference types store references to the actual data. The keywords that are used to declare reference types are: 1. Class - Refers to the primary building block for the programs, which is used to encapsulate variables and methods into a single unit. 2. Interface - Contains only the signatures of methods, properties, events, or indexers. 3. Delegate - Refers to a reference type that is used to encapsulate a named or anonymous method 82.Briefly explain the characteristics of reference-type variables that are supported in the C# programming language.
  34. 34. 1. System.Int16 2. System.Int32 3. System.Int64 4. System.Int128 83.The C# keyword .int. maps to which .NET type?
  35. 35. OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object is created in the program to represent a class. Therefore, an object encapsulates all the features, such as data and behavior that are associated to a class. OOP allows developers to develop modular programs and assemble them as software. Objects are used to access data and behaviors of different software modules, such as classes, namespaces, and sharable assemblies. .NET Framework supports only OOP languages, such as Visual Basic .NET, Visual C#, and Visual C++. 84.What is object-oriented programming (OOP)?
  36. 36. 1. string s = #.n Test string.; 2. string s = ..n Test string.; 3. string s = @.n Test string.; 4. string s = .n Test string.; 85.Which of these string definitions will prevent escaping on backslashes in C#?
  37. 37. A class describes all the attributes of objects, as well as the methods that implement the behavior of member objects. It is a comprehensive data type, which represents a blue print of objects. It is a template of object. A class can be defined as the primary building block of OOP. It also serves as a template that describes the properties, state, and behaviors common to a particular group of objects. A class contains data and behavior of an entity. For example, the aircraft class can contain data, such as model number, category, and color and behavior, such as duration of flight, speed, and number of passengers. A class inherits the data members and behaviors of other classes by extending from them. 86.What is a class?
  38. 38. 1. int[,] myArray; 2. int[][] myArray; 3. int[2] myArray; 4. System.Array[2] myArray; 87.Which of these statements correctly declares a two-dimensional array in C#?
  39. 39. The following are the four basic features of OOP: Abstraction - Refers to the process of exposing only the relevant and essential data to the users without showing unnecessary information. Polymorphism - Allows you to use an entity in multiple forms. Encapsulation - Prevents the data from unwanted access by binding of code and data in a single unit called object. Inheritance - Promotes the reusability of code and eliminates the use of redundant code. It is the property through which a child class obtains all the features defined in its parent class. When a class inherits the common properties of another class, the class inheriting the properties is called a derived class and the class that allows inheritance of its common properties is called a base class. 88.Explain the basic features of OOPs?
  40. 40. 1. Classes that are both in the same assembly and derived from the declaring class. 2. Only methods that are in the same class as the method in question. 3. Internal methods can be only be called using reflection. 4. Classes within the same assembly, and classes derived from the declaring class. 89.If a method is marked as protected internal who can access it?
  41. 41. Class: 1. A class is a reference type. 2. While instantiating a class, CLR allocates memory for its instance in heap. 3. Classes support inheritance. 4. Variables of a class can be assigned as null. 5. Class can contain constructor/destructor. Structure: 1. A structure is a value type. 2. In structure, memory is allocated on stack. 3. Structures do not support inheritance. 4. Structure members cannot have null values. 5. Structure does not require constructor/destructor and members can be initialiazed automatically 90.What is the difference between a class and a structure?
  42. 42. a) Encapsulating an object in a value type. b) Encapsulating a copy of an object in a value type. c) Encapsulating a value type in an object. d) Encapsulating a copy of a value type in an object. 91.What is boxing?
  43. 43. Structures and classes are the two most important data structures that are used by programmers to build modular programs by using OOP languages, such as Visual Basic .NET, and Visual C#. The following are some of the similarities between a class and a structure: Access specifiers, such as public, private, and protected, are identically used in structures and classes to restrict the access of their data and methods outside their body. The access level for class members and struct members, including nested classes and structs, is private by default. Private nested types are not accessible from outside the containing type. Both can have constructors, methods, properties, fields, constants, enumerations, events, and event handlers. Both structures and classes can implement interfaces to use multiple-inheritance in code. Both structures and classes can have constructors with parameter. Both structures and classes can have delegates and events. 92.What are similarities between a class and a structure?
  44. 44. 1. A peripheral assembly designed to monitor permissions requests from an application. 2. Any DLL file used by an EXE file. 3. An assembly containing localized resources for another assembly. 4. An assembly designed to alter the appearance or .skin. of an application. 93.What is a satellite Assembly?
  45. 45. Yes, you must handle exceptions in code so that you can deal with any unexpected situations that occur when a program is running. For example, dividing a number by zero or passing a string value to a variable that holds an integer value would result in an exception. 94. Is it a good practice to handle exceptions in code?
  46. 46. 1. A strongly typed function pointer. ] 2. A light weight thread or process that can call a single method. 3. A reference to an object in a different process. 4. An inter-process message channel. 95.What is a delegate?
  47. 47. Constructor is a special method of a class, which is called automatically when the instance of a class is created. It is created with the same name as the class and initializes all class members, whenever you access the class. The main features of a constructor are as follows: Constructors do not have any return type Constructors are always public It is not mandatory to declare a constructor; it is invoked automatically by .NET Framework 96.Explain the concept of constructor?
  48. 48. 1. The runtime checks to see that only one version of an assembly is on the machine at any one time. 2. .NET allows assemblies to specify the name AND the version of any assemblies they need to run. 3. The compiler offers compile time checking for backward compatibility. 4. It doesn.t. 97.How does assembly versioning in .NET prevent DLL Hell?
  49. 49. In .NET 4.0, a new namespace, System.Runtime.ExceptionServices, has been introduced which contains the following classes for handling exceptions in a better and advanced manner: HandleProcessCorruptedStateExceptionsAttribute Class - Enables managed code to handle the corrupted state exceptions that occur in an operating system. These exceptions cannot be caught by specifying the try...catch block. To handle such exceptions, you can apply this attribute to the method that is assigned to handle these exceptions. FirstChanceExceptionEventArgs Class - Generates an event whenever a managed exception first occurs in your code, before the common language runtime begins searching for event handlers 98.How has exception handling changed in .NET Framework 4.0?
  50. 50. public class A { private A instance; private A() { } public static A Instance { get { if ( A == null ) A = new A(); return instance; } } } 1. Factory 2. Abstract Factory 3. Singleton 4. Builder 99.Which .Gang of Four. design pattern is shown below?
  51. 51. A delegate is similar to a class that is used for storing the reference to a method and invoking that method at runtime, as required. A delegate can hold the reference of only those methods whose signatures are same as that of the delegate. Some of the examples of delegates are type-safe functions, pointers, or callbacks. 100.What is a delegate?
  52. 52. To know more details on dot net click https://bigclasses.com/dot-net-online- training.html and call us:- +91 800 811 4040 For regular Updates on dot net please like our Facebook page:- Facebook:- https://www.facebook.com/bigclasses/ Twitter:- https://twitter.com/bigclasses LinkedIn:- https://www.linkedin.com/company/bigclasses Google+: https://plus.google.com/+Bigclassesonline DOT NET Course Page:- https://bigclasses.com/dot-net-online-training.html Contact us: - India +91 800 811 4040 USA +1 732 325 1626 Email us at: - info@bigclasses.com

×