C# Interview Questions

Your Ad Here

C# InterviewQuestions
Interview Questions
----------------------------
Interview Questions
---------------------------
1. What are the main properties of object oriented programming?
a ) There are mainly 3 properties
1. Encapsulation/Abstraction
2. Inheritance
3. Polymorphism

2. What is encapsulation?
a ) This gives a way to hide the internal details of an object from its users.

3. What is inheritance ?
a ) It provides a way to build/create new classes using existing classes.

4. What is polymorphism?
a ) It provides a way to take more than one form.

5. What is a constructor?
a ) Constructor enables an object to initialize itself when it is first created.

6. What are the properties of a constructor?
a ) They are
1. They should have the same name as that of a class
2. They do not specify a return type.
3. we can use access modifiers to constructor.

7. How many types of access modifiers are there ?
a ) 5 types
1. Private
2. Public
3. Protected
4. Internal
5. Protected Internal

8. What access modifiers we can use for a class?
a ) We can use 2 access modifiers
1. Public
2. Internal

9. What is the default access modifier of a class?
a ) It is Internal

10. What is the default access modifier for class members?
a ) It is Private

11. Can we use access modifier on static constructor?
a ) No

12. How many static constructors we can declare for a single class?
a ) A class can have only one static constructor.

13. What is method overloading?
a ) It is a process of creating methods that have the same name but with different parameter lists and different definitions. This method overloading is used when you want your methods to do same tasks but using different input parameters.

14. What happens when we use ‘private’ modifier to a constructor of a class?
a ) When we declare a constructor of a class as private then we can’t create a objects of that class and we can not use that class as a base class for inheritance

15. Can we overload constructors?
a ) Yes

16. What are instant variables?
a ) Class variables are known as instant variables. Instant variables are different for each object and they are accessed using the objects. When ever a class is instantiated a new copy of the each of the instant variable is created.

17. What are static variables?
a ) These are also known as class variables. Static variables are common for all objects of a class. Only one copy of static variables will be created for all the objects of a class.

18. What are the differences between structure and class
a ) Structure:
It is value type
It is stored on stack
Does not support inheritance
Suitable for small data structure
Class:
It is reference type
It is stored on heap
Supports inheritance
Suitable for complex data structures

19. What is a value type? Give examples
a ) It stores value directly. Value types are stored on stack. Separate memory will be given for each instant of a value type.
Ex: int, float, char, struct

20. What are reference type?
a ) It stores a reference to the value. They are stored on heap.
Ex: class, string, array.
21. What are the properties of constant members?
a ) 1. They should use the modifier ‘ const’
2. Their value should be given when they are defined (it can’t be changed later)
3. They are implicitly static.

22. Why we use this keyword?
a ) This is used to distinguish local and instant variables that have the same name.

23. Does a copy of a static variable is created every time a class is instantiated?
a ) No.

24. What is a partial class?
a ) A partial class is a class which resides in multiple files. It should use 'partial' keyword. Generally it is used in situations where multiple developers need acess to the same class.

25. What is the name of the class from which all .net classes are derived?
a ) System.Object

26. Does c# support global variables?
a ) No. all declarations must be done inside a class.

27. Differences between property and indexer?
a ) Property
A property can be static member
The get accessor of a property corresponds to a method with no parameters
Indexer
An indexer is always an instant member
The get accessor of an indexer corresponds to the same formal parameter list as the indexer.

28. Differences between overloading and overriding?
a ) Overloading
1. used we want a method with more than one definition with in the same scope
2. in overloading, methods will have same name but different number, types, order of arguments.
Overriding
1. this is used when we have parent, child classes.
2. in overriding , methods will have same name with same arguments and same return type.

29. what is the order of the constructor execution in inheritance?
a ) They are executed from top(parent class) to bottom(child class)

30. what is the order of the destructors execution in inheritance?
a ) They are executed from bottom(child class) to top(parent/base class)
31. What are the inheritance types?
a ) 1. single level inheritance
2. multi level inheritance
3. multiple inheritance
4. hierarchical inheritance

32. Can we inherit the private members of a class
a ) Yes. But they are not accessible.

33. Why we use the keyword virtual?
a ) When you want to override a method of base class in derived class you should use this virtual keyword to the method in base class

34. Why we use override keyword?
a ) When you want to override a method of base class in derived class you should use this override keyword to the method in derived class

35. What are the abstract classes?
a ) Abstract classes are the classes for which we can not create objects. Means an abstract class can not be instantiated.

36. What are abstract methods?
a ) Abstract methods are the methods which does not contain their body part means they does not provide any implementation.

37. What are the properties of abstract methods?
a ) 1. they do not contain body part.
2. their definition/implementation should be given in non-abstract classes by overriding that method.
3. we can not use static modifier to it.

38. What are the sealed classes?
a ) If you want to prevent a class from being inherited you can use this keyword sealed to that particular class

39. What are sealed methods?
a ) A sealed method is a method which can not be overridden by its derived class.

40. Does a sealed class is an abstract class? Why?
a ) No a sealed class is not an abstract class. Because we can’t inherit a sealed class but we can inherit an abstract class.
41. How can we achieve multiple inheritance in c#?

a ) Using interfaces.

42. An interface is a value type or reference type?

a ) An interface is a reference type.

43. Does an interface extend classes?

a ) No

44. Can we write constructors and destructors for an interface?

a ) No.

45. What are the default modifiers of members of an interface?

a ) Public and abstract

46. What are the differences between an abstract class and an interface?

a ) Abstract class

1. it can contain implementation to some methods.

2. we can apply access modifiers to one or more methods in an abstract class

3. a class can not inherit more than one abstract class

4. an abstract class can have fields and constants defined

Interface

1. it just contains declarations. No implementation for any method.

2. we can not apply access modifiers to methods inside an interface

3. a class can inherit more than one interface

4. interface does not contain any field definition.

47. Can an interface is implemented by any number of classes?

a ) Yes.

48. What are the types of polymorphism?

a ) 2 types

1. operation polymorphism

2. inclusion polymorphism

49. How we achieve operation polymorphism and inclusion polymorphism?

a ) Operation polymorphism is achieved using overloaded methods and operators

And inclusion polymorphism is achieved using virtual functions.

50. what do you mean by compile time polymorphism?
a ) It is a process of selecting and binding the appropriate method to the object for a particular call at compile time.

51. What are the types of strings?
a ) 2 types
1. mutable strings
2. immutable strings

52. Is a string is a reference type or value type?
a ) A string is reference type

53. What do you mean by mutable and immutable ?
a ) Mutable means we can alter the characters contained in them.
Immutable means that we can not alter the characters contained in them

54. What are String and StringBuilder classes?
a ) String class is an immutable class and
StringBuilder class is an mutable class

55. Tell me some methods present in StringBuilder class?
a ) They are
Append(),
Insert(),
Remove(),
Replace(),
appendFormat()

56. What is the namespace of StringBuilder class?
a ) System.Text

57. Tell me some methods present in String class?
a ) They are
Copy(),
Equals(),
ConCat(),
Compare(),
Trim(),
Substring(),

58. Can you store multiple data types in System.Array ?
a ) No.

59. What is the class from which an array is created(derived) automatically in c#
a ) System.Array

60. Some common methods of System.Array class?
a ) Clear(), CpoyTo(), GetValue(), Sort(), Reverse() etc.

61. Can private virtual methods be overridden ?
a ) No. we can not access private methods in inherited classes.

62. Can we inherit multiple interfaces?
a ) yes. In c# multiple inheritance is achieved through interfaces.

63.How can a method be overloaded?
a ) a method can be overloaded by creating a method with the same name but with different parameter order, data types and number

64. Will finally block get executed if the exception had not occurred?
a ) Yes. Finally block always gets executed regardless of an error.

65. Can multiple catch blocks be executed ?
a ) No. once the appropriate catch code is fired control transfer to the finally block then continues with the rest of the code.

66. What is the accessibility level of a protected variable?
a ) It is available to the classes in the same name space.

67. Can you override private virtual methods
a ) No.

68. Can we inherit multiple interfaces?
a) Yes. We can’t inherit multiple classes but we can inherit multiple interfaces.

69. Can we use virtual keyword to a destructor?
a ) No

70. What is the access level of a internal variable?
a ) current assembly

Subscribe
Posted in Labels: , , kick it on DotNetKicks.com |

13 comments:

  1. Anonymous Says:

    how to open a pharmacy http://drugstore4.com/fr/product/himalaya-herbolax-tabs.html abbot labs pharmacy [url=http://drugstore4.com/de/product/zerit.html]zerit[/url]
    mayo pharmacy http://drugstore4.com/product/albuterol.html where can i find pharmacy technician jobs in houston texas [url=http://drugstore4.com/de/product/alfacip.html]mexican pharmacy elivel[/url]
    st louis pharmacy http://drugstore4.com/de/product/himalaya-diarex-tabs.html pharmacy in pharmacognosy [url=http://drugstore4.com/de/product/pilagan-4.html]pilagan 4[/url]
    pharmacy tropicale http://drugstore4.com/product/himalaya-gasex-syrup.html pharmacy lyons ny [url=http://drugstore4.com/fr/product/alesse.html]victoria pharmacy canada[/url]

  2. Anonymous Says:

    gif animation software http://freshoemsoftware.com/it/category-4/product-27125/Red-Giant-Trapcode-Particular-2-0-for-Adobe-After-Effects Microsoft Windows 2000 Advanced Server with SP4 [url=http://freshoemsoftware.com/de/category-11/product-14925/File-Rescue-Plus-4-0]File Rescue Plus 4 0[/url]
    best scientific calculator software http://freshoemsoftware.com/category-3/Graphics-and-Publishing?page=6 change accent software voice [url=http://freshoemsoftware.com/de/category-14/product-28532/YZSoft-AA-Mail-Server-Pro-3-9]free computer fax software[/url]
    VJ Ripper Pro 1.2 http://freshoemsoftware.com/it/category-100-102/product-18417/Maxprog-LoanCalc-2-6-Multilingual free pocket pc software [url=http://freshoemsoftware.com/fr/category-100-104/product-12603/-raft-Director-Tools-8-1-for-3ds-max-and-maya] raft Director Tools 8 1 for 3ds max and maya[/url]
    installing software on a dell powervault http://freshoemsoftware.com/product-15038/001-File-Joiner-and-Splitter-4-0-Pro discounted software for students [url=http://freshoemsoftware.com/es/product-27988/Adult-PDF-Encrypt-3-0]CZ Print Job Tracker Premium Edition 4.0[/url]
    vhs to dvd software http://freshoemsoftware.com/es/category-100-110/product-14153/3Com-Network-Supervisor-5-2 JSCAPE Secure FTP Server 4.4 [url=http://freshoemsoftware.com/de/category-100-113/product-17183/ClubDJ-PRO-2-1]ClubDJ PRO 2 1[/url]
    free software search engines http://freshoemsoftware.com/es/category-100-108/product-20777/Atrise-ToRTF-2-2 printing software [url=http://freshoemsoftware.com/product-25115/Adobe-Incopy-CS4-Mac]divx editing croping software[/url]

  3. Anonymous Says:

    ems walkabout travel day pack http://icej.eu/sunroom travel and tourism technoligical [url=http://icej.eu/home/home-builders-stoney-creek-ontario]home builders stoney creek ontario[/url]
    travel agent that sell flight ticket http://icej.eu/storage/under-step-toy-storage travel agents 12538 [url=http://icej.eu/decor/wood-burning-stove-decor]travel house pontardawe[/url]
    patrick air force base passenger travel http://icej.eu/sunrooms/four-seasons-sunrooms-selling-replacement-windows air travel polar routes [url=http://icej.eu/landscaping/leonora-phoenix-landscaping]leonora phoenix landscaping[/url]
    travel to scottland http://icej.eu/concrete/proper-concrete-abstract-and-group-nouns air travel to las vagas [url=http://icej.eu/siding/eagle-river-siding-contractors]air span class highlighted jamaica span travel tips travel[/url]
    mexico travel guide http://icej.eu/floor/cheap-husky-floor-liners study travel [url=http://icej.eu/home/alpharetta-ga-home-for-sale-by-owner]alpharetta ga home for sale by owner[/url]
    passport requirements canada travel http://icej.eu/moving/nickle-brothers-house-moving have spacesuit will travel lessons [url=http://icej.eu/decorations/volkswagen-decorations]travel warnings in ontario[/url]

  4. Anonymous Says:

    help with writing rap http://kzq.in/jovi/bon/jovi/song/you/want/to/make/a/memory fire emblem radiant dawn music [url=http://kzq.in/lenny-kravitz/lenny/kravitz/ill/be/there]lenny kravitz ill be there[/url]
    kudos rock legend http://kzq.in/james-blunt/james/blunt/madonna royalty free music library [url=http://kzq.in/mary-blige/mary/j/blige/auotgraphs]how to naturally cure yeast infections[/url]
    magiclamp sci trance http://kzq.in/jack-johnson/if/i/had/eyes/in/the/back/of/my/head/jack/johnson/lyrics laluna dance studio [url=http://kzq.in/kenny-rogers/wav/download/mary/did/you/know/kenny/rogers]wav download mary did you know kenny rogers[/url]
    steam pop off valve http://kzq.in/linkin-park/lyrics/of/somewhere/i/belong/of/linkin/park rock dip direction [url=http://kzq.in/linkin-park/the/meaning/linkin/park]converting cda files to mp3 online[/url]
    primo cuban blues mp3 download http://kzq.in/michael-jackson/michael/jackson/ringtones rademaker rock music [url=http://kzq.in/mary-blige/grown/woman/lyrics/by/mary/j/blige]grown woman lyrics by mary j blige[/url]
    ipod accesory http://kzq.in/lenny-kravitz/lenny/kravitz/limited/tour/edition music city best western [url=http://kzq.in/james-blunt/james/blunt/1974]skyblog music kanye west stronger[/url]

  5. Anonymous Says:

    [url=http://loveepicentre.com/testimonials.php][img]http://loveepicentre.com/uploades/photos/11.jpg[/img][/url]
    sergei fedorov dating [url=http://loveepicentre.com/testimonials.php]adult dating business[/url] jewish dating services for gays
    largest michigan dating site [url=http://loveepicentre.com/taketour.php]new online dating site world wide[/url] european women dating wives
    japanese women dating mexican men [url=http://loveepicentre.com/]is bret michaels still dating ambre[/url] sim dating games 18

  6. Anonymous Says:

    airfax county public library ebook account http://audiobookscollection.co.uk/D-V-Shirkov/m23937/ ebook modern fundamental of golf [url=http://audiobookscollection.co.uk/fr/Paleomagnetic-Principles-and-Practice/p102756/]the memory book ebook pdf[/url] free soap making ebook

  7. Anonymous Says:

    go with microsoft office 2007 ebook http://audiobookscollection.co.uk/On-Intelligence/p105270/ ebook a handful of dust [url=http://audiobookscollection.co.uk/es/Ageing-Spirituality-and-Well-being/p105460/]ebook las vegas[/url] free forex ebook downloads

  8. Anonymous Says:

    teens personal budget software http://buysoftwareonline.co.uk/de/product-36557/Finance-Helper-4-8 organization goes with open source software [url=http://buysoftwareonline.co.uk/de/product-33470/Photomatix-Tone-Mapping-2-0-for-Photoshop-x32]address label software free download[/url] what is breeze software
    [url=http://buysoftwareonline.co.uk/es/news-40/Opera-Releases-Beta-of-Android-Browser]Opera Releases Beta of Android Browser - Cheap Legal OEM Software, Software Sale, Download OEM[/url] medical billing discont software
    [url=http://buysoftwareonline.co.uk/product-36758/Avlan-Design-Animated-GIF-Producer-5-1][img]http://buyoem.co.uk/image/6.gif[/img][/url]

  9. Anonymous Says:

    [url=http://onlinemedistore.com/products/minocycline.htm][img]http://onlinemedistore.com/6.jpg[/img][/url]
    pharmacy in kosovo http://onlinemedistore.com/products/viagra-soft-tabs.htm aps pharmacy [url=http://onlinemedistore.com/products/voltaren.htm]mexican online pharmacy[/url]
    postgraduate study at uppsala university of pharmacy sweden http://onlinemedistore.com/products/exelon.htm compound pharmacy nashville tennessee vet [url=http://onlinemedistore.com/products/citalopram.htm]citalopram[/url]
    diabetes continuing education pharmacy http://onlinemedistore.com/catalogue/l.htm soma pharmacy online [url=http://onlinemedistore.com/products/ed-discount-pack-3.htm]pharmacy authorized access definition[/url]
    pharmacy school failed http://onlinemedistore.com/products/cialis-professional.htm pharmacy closings [url=http://onlinemedistore.com/products/ed-discount-pack-1.htm]ed discount pack 1[/url]

  10. Anonymous Says:

    [url=http://certifiedpharmacy.co.uk/products/zithromax.htm][img]http://onlinemedistore.com/3.jpg[/img][/url]
    pharmacy technology http://certifiedpharmacy.co.uk/products/prilosec.htm keyword online pharmacy [url=http://certifiedpharmacy.co.uk/products/arava.htm]find a cvs pharmacy[/url]
    ar board of pharmacy http://certifiedpharmacy.co.uk/products/ditropan.htm online pharmacy tech [url=http://certifiedpharmacy.co.uk/categories/weight-loss.htm]weight loss[/url]
    consulting pharmacy layout http://certifiedpharmacy.co.uk/products/bystolic.htm us based pharmacy overnight xanax [url=http://certifiedpharmacy.co.uk/products/zithromax.htm]jobs pharmacy[/url]
    ninth street pharmacy in pa http://certifiedpharmacy.co.uk/products/lasuna.htm norris pharmacy pine grove wv [url=http://certifiedpharmacy.co.uk/products/generic-motrin.htm]generic motrin[/url]

  11. Anonymous Says:

    [url=http://certifiedpharmacy.co.uk/products/dostinex.htm][img]http://onlinemedistore.com/9.jpg[/img][/url]
    mexico mail pharmacy http://certifiedpharmacy.co.uk/products/hydrochlorothiazide.htm nucara pharmacy [url=http://certifiedpharmacy.co.uk/products/isoptin.htm]gordonsville medical pharmacy va[/url]
    world wide scholarship of pharmacy http://certifiedpharmacy.co.uk/products/hard-on-oral-jelly.htm duane pharmacy [url=http://certifiedpharmacy.co.uk/products/sublingual-viagra.htm]sublingual viagra[/url]
    loss online pharmacy weight http://certifiedpharmacy.co.uk/products/retin-a-0-02-.htm wiechart pharmacy in lima ohio [url=http://certifiedpharmacy.co.uk/products/differin.htm]idaho pharmacy board[/url]
    tricare for life pharmacy care non formulary http://certifiedpharmacy.co.uk/products/minocin.htm dilpomat pharmacy [url=http://certifiedpharmacy.co.uk/products/zebeta.htm]zebeta[/url]

  12. Anonymous Says:

    [url=http://fdaapproved.co.uk/products/starlix.htm][img]http://onlinemedistore.com/4.jpg[/img][/url]
    pharmacy noprescription http://fdaapproved.co.uk/products/horny-goat-weed.htm online overnight pharmacy [url=http://fdaapproved.co.uk/products/zyloprim.htm]scrafts pharmacy in livingston[/url]
    cvs pharmacy henderson nv http://fdaapproved.co.uk/products/minocycline.htm school of pharmacy [url=http://fdaapproved.co.uk/products/femara.htm]femara[/url]
    massachusetts board of registration pharmacy http://fdaapproved.co.uk/products/topamax.htm med house valleydale pharmacy [url=http://fdaapproved.co.uk/products/minocycline.htm]avoid the middle man pharmacy[/url]
    pharmacy databases http://fdaapproved.co.uk/products/ophthacare.htm elders pharmacy [url=http://fdaapproved.co.uk/products/metoclopramide.htm]metoclopramide[/url]

  13. Anonymous Says:

    free canadian dating site http://loveepicentre.com/ single parent dating heyburn idaho
    dating claudia s schlottmann [url=http://loveepicentre.com/]dating someone who is separated[/url] drake id dating
    forces dating [url=http://loveepicentre.com/success_stories/]dating kiev[/url] diabteic dating sites [url=http://loveepicentre.com/user/alihass/]alihass[/url] online dating myths