Ultimate C#, .Net Interview Q&AE-Book
Total Page:16
File Type:pdf, Size:1020Kb
Register your resume: www.terrafirmajobs.com _________________________________________________ www.terrafirmajobs.com Ultimate C#, .Net Interview Q&AE-book Free E-books available with Terra Firma Java Interview Q&A Terra Firma’s Interview Kit Are you stressed at your Desk Restore the rhythm of your life IT Resume writing tips Heart-Care Tips To get these free e-books, email to: [email protected] with the title of the e-book. Copy Right Note You are permitted to freely distribute/print the unmodified version of this issue/e-book/article. We are not attempting to obtain commercial benefit from the valuable work of the authors and the Editor/Publisher claims the ‘fair use’ of copyrighted material. If you think that by publishing a particular material, your copyright has been violated, please let us know. The Editor/Publisher is not responsible for statements or opinions expressed herein nor do such statements necessarily express the views of Editor/Publisher. 1 More Career Tips: http://www.terrafirmajobs.com/ITpros/IT_resources.asp?id=4 ______________________________________________________________________________ Register your resume: www.terrafirmajobs.com _________________________________________________ Index Chapter Name Page 1) C# interview Questions and Answers. 4 1.1) Advance C# interview Questions 2) General Questions 17 2.1 ) General Questions 2.2 ) Methods and Property 2.3) Assembly Questions 2.4) XML Documentation Question 2.5) Debugging and Testing 3) ADO.net and Database Question 26 4) C#, DOT NET, XML, IIS Interview Questions 28 4.1 ) Framework. 4.2 ) COM 4.3 ) OOPS 4.4 ) C# Language Features 4.5 ) Access Specifier 4.6 ) Constructor / Destructor 4.7 ) ADO.net 4.8 ) ASP.net 4.8.1) Session. 4.8.2) Security. 4.8.3) Web Servcing & Remoting 4.9 ) XML 4.10 ) IIS 4.11 ) Controls 4.12 ) Programming 5) Dot NET. 120 5.1 ) Dot NET 5.2 ) Basic Technology. 5.3 ) Assemblies 5.4 ) Application Domain 5.5 ) Garbeg collection 5.6 ) Serialization 2 More Career Tips: http://www.terrafirmajobs.com/ITpros/IT_resources.asp?id=4 ______________________________________________________________________________ Register your resume: www.terrafirmajobs.com _________________________________________________ 5.7 ) Attribute 5.8 ) Code Access Security. 5.9 ) Interimediate Language (IL) 5.10 ) Implications for COM. 5.11 ) Miscellaneous 5.12 ) Class Library 5.12.1) File I/ O 5.12.2 ) Text Processing 5.12.3 ) Internet. 5.12.4) XML 5.12.5) Threading 5.12.6) Tracing. 6) C# FAQ's 151 6.1 ) Introduction 6.2 ) Basic Datatype. 6.3 ) Classes & Structs. 6.4 ) Exceptions 6.5 ) Runtime type information. 6.7 ) Advantage features. 6.8 ) Miscellaneous. 7) Interview Questions for Dot NET Forms. 161 8) Interview Questions for Dot NET Remoting 164 9) Interview Questions for ASP .NET 167 10 ) ASP.NET ,C#, VB.NET and COM etc….Full of microsoft Technology 173 11 ) .NET Framework FAQ's 204 12 ) C# and VB.NET 285 13) COM & COM + 307 14 ) Remoting FAQ's 311 15 ) WinForms FAQ 316 3 More Career Tips: http://www.terrafirmajobs.com/ITpros/IT_resources.asp?id=4 ______________________________________________________________________________ Register your resume: www.terrafirmajobs.com _________________________________________________ C# Interview Questions and Answers Q 1. What’s the implicit name of the parameter that gets passed into the class’ set method? Ans: - Value and its data type depend on whatever variable we’re changing. Q 2. How do you inherit from a class in C#? Ans: - Place a colon and then the name of the base class. Notice that it’s double colon in C++. Q 3. Does C# support multiple inheritances? Ans: - No, use interfaces instead. Q 4. When you inherit a protected class-level variable, who is it available to? Ans: - Classes in the same namespace. Q 5. Are private class-level variables inherited? Ans: - Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are. Q 6. Describe the accessibility modifier protected internal? Ans: - It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in). Q 7. C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write? Ans: - Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there’s no implementation in it. Q 8. What’s the top .NET class that everything is derived from? Ans: - System. Object. 4 More Career Tips: http://www.terrafirmajobs.com/ITpros/IT_resources.asp?id=4 ______________________________________________________________________________ Register your resume: www.terrafirmajobs.com _________________________________________________ Q 9. How’s method overriding different from overloading? Ans: - When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class. Q 10. What does the keyword virtual mean in the method definition? Ans: - The method can be over-ridden. Q 11. Can you declare the override method static while the original method is non-static? Ans: - No, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override. Q 12. Can you override private virtual methods? Ans: - No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access. Q 13. Can you prevent your class from being inherited and becoming a base class for some other classes? Ans: - Yes, that’s what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class Whatever Base Class Name. It’s the same concept as final class in Java. Q 14. Can you allow class to be inherited, but prevent the method from being over-ridden? Ans: - Yes, just leave the class public and make the method sealed. Q 16. What’s an abstract class? Ans: - A class that cannot be instantiated. A concept in C++ known as pure virtual method. A class that must be inherited and have the methods over- ridden. Essentially, it’s a blueprint for a class without any implementation. 5 More Career Tips: http://www.terrafirmajobs.com/ITpros/IT_resources.asp?id=4 ______________________________________________________________________________ Register your resume: www.terrafirmajobs.com _________________________________________________ Q 17. When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)? Ans: - When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden. Q 18. What’s an interface class? Ans: - It’s an abstract class with public abstract methods all of which must be implemented in the inherited classes. Q 19. Why can’t you specify the accessibility modifier for methods inside the interface? Ans: - They all must be public. Therefore, to prevent you from getting the false impression that you have any freedom of choice, you are not allowed to specify any accessibility, its public by default. Q 20 Can you inherit multiple interfaces? Ans: - Yes, why not. Q 21. And if they have conflicting method names? Ans: - It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay. Q 22. What’s the difference between an interface and abstract class? Ans: - In the interface all methods must be abstract; in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes. Q 23. How can you overload a method? Ans: - Different parameter data types, different number of parameters, different order of parameters. 6 More Career Tips: http://www.terrafirmajobs.com/ITpros/IT_resources.asp?id=4 ______________________________________________________________________________ Register your resume: www.terrafirmajobs.com _________________________________________________ Q 24. If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor? Ans: - Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class. Q 25. What’s the difference between Systems? String and System.StringBuilder classes? Ans: - System. String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed. Q 26. What’s the advantage of using System.Text.StringBuilder over System String? Ans: - String Builder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created. Q 27. Can you store multiple data types in System? Array? Ans:- No. Q 28. What’s the difference between the System.Array.CopyTo () and System.Array.Clone ()? Ans: - The first one performs a deep copy of the array, the second one is shallow. Q 29. How can you sort the elements of the array in descending order? Ans: - By calling Sort () and then Reverse () methods. Q 30. What’s the .NET data type that allows the retrieval of data by a unique key? Ans: - Hash Table. Q 31. What’s class Sorted List underneath? Ans: - A sorted Hash Table. 7 More Career Tips: http://www.terrafirmajobs.com/ITpros/IT_resources.asp?id=4 ______________________________________________________________________________ Register your resume: www.terrafirmajobs.com _________________________________________________ Q 32.