Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

C# Interview Questions | Edureka

79 views

Published on

YouTube Link: https://youtu.be/ipYKV3U8SyM
**Edureka Online Courses: https://www.edureka.co**
This Edureka PPT on Top 50 C# Interview Question and Answers will help you to prepare yourself for C# developer Interviews. It covers questions for the following levels:
Beginner Level
Intermediate Level
Experienced Professionals

Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in

Published in: Technology
  • Be the first to comment

C# Interview Questions | Edureka

  1. 1. Copyright © 2018, edureka and/or its affiliates. All rights reserved.
  2. 2. C# Interview Questions
  3. 3. www.edureka.co/ C# Beginner Interview Questions Question 1 List down the differences between Public, Static and Void Keywords.
  4. 4. www.edureka.co/ C# Beginner Interview Questions Question 1 List down the differences between Public, Static and Void Keywords. keyword Description Static It is a keyword used for declaring a member of a type, specific to that type Void It states that the method does not return any value Public It is an access specifier which states that the method of a class can be accessed publicly
  5. 5. www.edureka.co/ C# Interview Questions Define C# and list the features. Question 2
  6. 6. www.edureka.co/ C# Interview Questions Define C# and list the features. Question 2 Object Oriented Managed language Type Safe Part of the .NET Framework and was developed by Microsoft Developed for all kinds of Software Used my million developers
  7. 7. www.edureka.co/ C# Interview Questions Define C# and list the features? Question 2 Constructors and Destructors Easy to grasp Object Oriented
  8. 8. www.edureka.co/ C# Interview Questions List down the reason behind the usage of C# Language. Question 3 Question 3
  9. 9. www.edureka.co/ C# Interview Questions List down the reason behind the usage of C# Language. Easy To Pickup Component Oriented Structured Approach Code readability is easy Question 3
  10. 10. www.edureka.co/ C# Interview Questions What are the advantages of using C#? Question 4
  11. 11. www.edureka.co/ C# Interview Questions What are the advantages of using C#? Question 4 Simple & Fast No BufferingCross Platform High Scalability
  12. 12. www.edureka.co/ C# Interview Questions What are the different types of comments in C#? Question 5
  13. 13. www.edureka.co/ C# Interview Questions What are the different types of comments in C#? Question 5 // hello, this is a single line comment ///hello this is a XML comment /*hello this is multi line Comment/* Single Line Comments XML Comments Multi Line Comments
  14. 14. www.edureka.co/ C# Interview Questions Illustrate the process of Code compilation in C#. Question 6
  15. 15. www.edureka.co/ C# Interview Questions Illustrate the process of Code compilation in C#. Question 6 Compilation of Source Code Clubbing newly created code Executing assembly CLR(Common Language RunTime)
  16. 16. www.edureka.co/ C# Interview Questions List down the Access Modifiers available in C#. Question 7 Private
  17. 17. www.edureka.co/ C# Interview Questions List down the Access Modifiers available in C#. Question 7 Protected PrivateInternal Protected Internal Public
  18. 18. www.edureka.co/ C# Interview Questions Question 8 List down the different IDE’s provided by MICROSOFT for C# Development.
  19. 19. www.edureka.co/ C# Interview Questions Question 8 List down the different IDE’s provided by MICROSOFT for C# Development. Visual Studio Visual Web Developer
  20. 20. www.edureka.co/ C# Interview Questions Distinguish between Continue and Break Statement? Question 9
  21. 21. www.edureka.co/ C# Interview Questions Distinguish between Continue and Break Statement? Question 9 Using Break Statement you can jump out of the loop while using Continue Statement you can jump over an iteration and continue the execution using System; using System.Collections; using System.Linq; using System.Text; namespace break_example{ Class break_Stmnt{ public static void main(String args[]){ for(int i=0;i<=6;i++) { if(i==5) { break; } Console.Readline("The number is +i"); } } } using System; using System.Collections; using System.Linq; using System.Text; namespace continue_example{ Class continue_Stmnt{ public static void main(String args[]){ for(int i=0;i<=6;i++) { if(i==5) { continue; } Console.Readline("The number is +i"); } } } Break Continue
  22. 22. www.edureka.co/ C# Interview Questions What are the different approaches of Passing Parameters to a method? Question 10
  23. 23. www.edureka.co/ C# Interview Questions What are the different approaches of Passing Parameters to a method? Question 10 Value Parameters Reference Parameters Output Parameters
  24. 24. www.edureka.co/pmpPMP® CERTIFICATION EXAM TRAINING
  25. 25. C# Intermediate Interview Questions
  26. 26. www.edureka.co/ C# Intermediate Interview Questions Distinguish between finally and finalize block? Question 11
  27. 27. www.edureka.co/ C# Intermediate Interview Questions Distinguish between finally and finalize block? Question 11 finally block is called after the execution of try and catch blocks. Finalize method is called just before garbage collection Try { //statement } Catch(Exception statement) { //error }
  28. 28. www.edureka.co/ C# Interview Questions What is MANAGED and UNMANAGED code? Question 12
  29. 29. www.edureka.co/ C# Interview Questions What is MANAGED and UNMANAGED code? Question 12 Managed Code Unmanaged Code ▪ It is executed by CLR(Common Language Runtime) ▪ All the application code is dependent on .NET Platform ▪ It is executed by runtime application of some other structure ▪ The runtime application deals with memory, security and other execution activities
  30. 30. www.edureka.co/ C# Interview Questions What is an Object? Question 13
  31. 31. www.edureka.co/ C# Interview Questions What is an Object? Question 13 An Object is an instance of a class Created by New keyword in C#
  32. 32. www.edureka.co/ C# Interview Questions What is a class? Question 14
  33. 33. www.edureka.co/ C# Interview Questions What is a class? Question 14 Blueprint of an Object 1 Defines different platforms for object 2
  34. 34. www.edureka.co/ C# Interview Questions Define an abstract class. Question 15
  35. 35. www.edureka.co/ C# Interview Questions Define an abstract class. Question 15 Objects can’t be instantiated Follows a single approach
  36. 36. www.edureka.co/ C# Interview Questions Define Sealed classes in C#. Question 16
  37. 37. www.edureka.co/ C# Interview Questions Define Sealed classes in C#. Question 16 Sealed Classes Created when you want to restrict the class being inherited Makes use of Sealed modifiers
  38. 38. www.edureka.co/ C# Interview Questions Define a Partial class. Question 17
  39. 39. www.edureka.co/ C# Interview Questions Question 17 • Makes use of split function • It spilts the definition of the class into multiple classes in either same source code files or multiple code files • One can create a class definition in multiple files but it is compiled as one class at run-time • When an instance of such a class is created a user can access all the methods from every source file Define a Partial class.
  40. 40. www.edureka.co/ C# Interview Questions List down the fundamental OOPs concepts? Question 18
  41. 41. www.edureka.co/ C# Interview Questions Question 18 List down the fundamental OOPs concepts? Inheritance Abstraction Polymorphism Encapsulation
  42. 42. www.edureka.co/ C# Interview Questions Explain the process of Inheriting the class into another class. Question 19
  43. 43. www.edureka.co/ C# Interview Questions Explain the process of Inheriting the class into another class. Question 19 Colon is used as an inheritance operator in C#. Place the colon and class name Public class Derivedclass: childclass
  44. 44. www.edureka.co/ C# Interview Questions Define method Overloading in C#. Question 20
  45. 45. www.edureka.co/ C# Interview Questions ❑ Creates multiple methods with the same name and class but unique signatures ❑ Makes use of overload resolution Define Method Overloading in C#. Question 20
  46. 46. www.edureka.co/ C# Interview Questions List the differences between Method Overriding and Method Overloading. Question 21
  47. 47. www.edureka.co/ C# Interview Questions Question 21 List the differences between method overriding and method overloading. Method Overriding Method Overloading The definition of the derived class is changed which in turn changes the method behavior Simply creates a method with name and class being same but has different and unique signatures Occurs in two classes It is performed within class Parameter must be different Parameter must be same
  48. 48. www.edureka.co/ C# Interview Questions Explain StreamReader/StreamWriter class. Question 22
  49. 49. www.edureka.co/ C# Interview Questions Question 22 Explain StreamReader/StreamWriter class. They are classes of namespace.System.IO Class Testprogram { using(StreamReader sr = new StreamReader("C:Readme.txt") { // Any code to read// } using(StreamWriter sr = new StreamWriter("C:Readme.txt") { // Any code to write// } }
  50. 50. www.edureka.co/ C# Interview Questions What is an Interface? Question 23
  51. 51. www.edureka.co/ C# Interview Questions Question 23 What is an Interface? • It is basically a class with no implementation • It contains only the declaration of Properties, attributes and behaviors
  52. 52. www.edureka.co/ C# Interview Questions Distinguish between a class and struct? Question 24
  53. 53. www.edureka.co/ C# Interview Questions Question 24 Distinguish between a class and struct? Class Struct It supports Inheritance It does not support Inheritance It is pass by reference It is pass by value Members are by default Private Members are public by default
  54. 54. www.edureka.co/ C# Interview Questions Question 25 List the difference between Virtual and Abstract method.
  55. 55. www.edureka.co/ C# Interview Questions Question 25 List the difference between Virtual and Abstract method. Virtual Abstract It must always have a default implementation It does not have any implementation by default It is overridden by the keyword override It forces the derived class to override the method Virtual methods have code They don’t have actual code in them
  56. 56. www.edureka.co/ C# Interview Questions Illustrate Namespaces in C#. Question 26
  57. 57. www.edureka.co/ C# Interview Questions Illustrate Namespaces in C#. Question 26 Namespaces are used for organizing large code projects. “System” is one of the most popular and widely used namespace in C#
  58. 58. www.edureka.co/ C# Interview Questions Define using statement in C#. Question 27
  59. 59. www.edureka.co/ C# Interview Questions Question 27 Define using statement in C#. “Using” keyword denotes that the particular namespace is being used by program. The class console is defined under system.
  60. 60. www.edureka.co/ C# Interview Questions Define an Escape Sequence, Name a few strings in Escape Sequence. Question 28
  61. 61. www.edureka.co/ C# Interview Questions Question 28 An Escape Sequence is denoted by a backslash(). An Escape Sequence is a single character Few Escape Sequence are as follows: 4n- newline character b- backspace‘- Single quote - backlash Define an Escape Sequence, Name a few strings in Escape Sequence.
  62. 62. www.edureka.co/ C# Interview Questions Define Boxing and Unboxing in C#. Question 29
  63. 63. www.edureka.co/ C# Interview Questions Question 29 Define Boxing and Unboxing in C#. Converting a value type to reference type is called boxing Explicit conversion of the same reference type is called unboxing int value=10 //-------------Boxing---------// Object boxedvalue=value1; //-----------Unboxing---------// int UnBoxing=int(boxedvalue)
  64. 64. www.edureka.co/ C# Interview Questions Define an array. Question 30
  65. 65. www.edureka.co/ C# Interview Questions Question 30 Define an array. An array is used to store multiple variables of the same datatype.
  66. 66. www.edureka.co/ C# Interview Questions Define a Jagged Array in C#. Question 31
  67. 67. www.edureka.co/ C# Interview Questions Define a Jagged Array in C#. Question 31 03 Int[][] jagArray = new int[5][]; A Jagged Array is referred to as an “array of arrays” • It is a nested array whose elements are arrays • The elements can be of different size and dimension
  68. 68. www.edureka.co/ C# Interview Questions Distinguish between Array and Arraylist in C#. Question 32
  69. 69. www.edureka.co/ C# Interview Questions Question 32 Distinguish between Array and Arraylist in C#. Array ArrayList Array uses the vector array for storing elements It uses LinkedList to store elements Size of array must be defined There is no need for specifying storage Typecasting is not necessary Typecasting is necessary
  70. 70. www.edureka.co/ C# Interview Questions Define Collections. Question 33
  71. 71. www.edureka.co/ C# Interview Questions Question 33 Define Collections. A collection essentially works like a container for instances of other classes. Every class implements Collection interface.
  72. 72. www.edureka.co/ C# Interview Questions Write a short note on Interface. Question 34
  73. 73. www.edureka.co/ C# Interview Questions Question 34 Write a short note on Interface. An Interface is a class with no implementation. It consists of a declaration of methods, parameters and values.
  74. 74. C# Advance Interview Questions
  75. 75. www.edureka.co/ C# Advance Level Interview Questions Illustrate Serialization. Question 35
  76. 76. www.edureka.co/ C# Interview Questions Question 35 Illustrate Serialization. A Process that involves converting some code into its binary format is known as serialization. Binary Serialization XML Serialization SOAP
  77. 77. www.edureka.co/ C# Interview Questions Define Parsing. Explain how to parse a Datetime String. Question 36
  78. 78. www.edureka.co/ C# Interview Questions Define Parsing. Explain how to parse a Datetime String. Question 36 A method of converting string into another data type is called Parsing To parse a DateTime string code is given below: String text = “200” int.num = int.Parse(text) string dateTime = "Aug 26,2019"; Datetime parsedvalue = Datetime.Parse(dateTime);
  79. 79. www.edureka.co/ C# Interview Questions Define Delegate. Question 37
  80. 80. www.edureka.co/ C# Interview Questions Question 37 A Delegate is a variable that holds the reference to a method. It is a function pointer of the reference type Define Delegate. public Delegate int myDel(int number); //declaring a delegate public class Program { public int SubstractNumbers(int a) //Class Program has the method same signature as delegate called { int difference = a - 10; return difference; } public void start() { myDel DelegateExample = SubstractNumbers; } } Example:
  81. 81. www.edureka.co/ C# Interview Questions Distinguish between System.String and System.Text.StringBuilder classes? Question 38
  82. 82. www.edureka.co/ C# Interview Questions Question 38 Distinguish between System.String and System.Text.StringBuilder classes? System.String System.Text.StringBuilder It is immutable It is mutable Cannot perform variety of operations Supports variety of operations A new memory is allocated to the new value and previous memory is released New memory is not allocated
  83. 83. www.edureka.co/ C# Interview Questions Illustrate the differences between the System.Array.CopyTo() and System.Array.Clone(). Question 39
  84. 84. www.edureka.co/ C# Interview Questions Question 39 Illustrate the differences between the System.Array.CopyTo() and System.Array.Clone(). Using the clone() method, a new array object is created containing all elements of the original array. Using the copyto() method all the elements of the existing array gets copied into another existing array
  85. 85. www.edureka.co/ C# Interview Questions Write the Syntax for catching an exception in C#. Question 40
  86. 86. www.edureka.co/ C# Interview Questions Question 40 Write the Syntax for catching an exception in C#. • To catch an exception we make use of try-catch block. • The catch block has a parameter of the system.Exception type. try { GetAllData(); } catch(Exception ex){ }
  87. 87. www.edureka.co/ C# Interview Questions Explain about generics in C#.NET Question 41
  88. 88. www.edureka.co/ C# Interview Questions Question 41 Generics are used to make reusable code classes that decrease the code redundancy Explain about generics in C#.NET Generics create collection Increase type safety, performance and optimization
  89. 89. www.edureka.co/ C# Interview Questions List down the differences between finalize and dispose() methods. Question 42
  90. 90. www.edureka.co/ C# Interview Questions List down the differences between finalize and dispose() methods. Question 42 Dispose releases unmanaged resources Finalize doesn’t give assurance of garbage collection Finalize releases unmanaged resources too
  91. 91. www.edureka.co/ C# Interview Questions Define C# I/O classes . List the commonly used classes. Question 43
  92. 92. www.edureka.co/ C# Interview Questions Define C# I/O classes . List the commonly used classes. Question 43 C# consists of System.Io namespace which consists of classes that compute various operations on files like creation, deletion, opening and closing etc. StreamWriter StreamReader File
  93. 93. www.edureka.co/ C# Interview Questions Define Thread. Explain about Multithreading. Question 44
  94. 94. www.edureka.co/ C# Interview Questions Thread is a set of instructions that when executed enables the program to perform concurrent processing. When you execute more than one process/task at a time then it is called multithreading. Define Thread. Explain about Multithreading. Question 44 By default C# consists of only one thread. Thread follows a lifecycle where it starts whenever a thread is created and gets terminated immediately after execution.
  95. 95. www.edureka.co/ C# Interview Questions Question 45 What are Events?
  96. 96. www.edureka.co/ C# Interview Questions Question 45 Events in C# follow a concept where it consists of a Publisher, Subscriber, Notification and a handler You can think of an event as an encapsulated delegateWhat are Events? public Delegate void TestEvent(); public TestEvent TestEvent1
  97. 97. www.edureka.co/ C# Interview Questions Explain Synchronous and Asynchronous Operations. Question 46
  98. 98. www.edureka.co/ C# Interview Questions Synchronization is a way of creating a thread-safe code where only a single thread will access the code in a given time. Question 46 A synchronous call waits for completion of method and then continuous the program flow. Synchronous Programming adversely affects the UI operations In Asynchronous Operation, the method call immediately returns allowing the program to perform other operations Explain Synchronous and Asynchronous Operations.
  99. 99. www.edureka.co/ C# Interview Questions Explain Async and Await. Question 47
  100. 100. www.edureka.co/ C# Interview Questions Question 47 Async and Await keywords are mostly used for creating asynchronous methods in C#. Explain Async and Await. public async Task>CalculateCount() { await Task.Delay(2000); return 1; } public async task mytestmethod() { Task> count = CalculateCount(); int result = await count; }
  101. 101. www.edureka.co/ C# Interview Questions Explain Deadlock. Question 48
  102. 102. www.edureka.co/ C# Interview Questions A Deadlock is a situation that arises when a process isn’t able to complete its execution because two or more than two processes are waiting for each other to get finished. Question 48 A shared resource is held up by a process and hence in turn other processes are waiting causing a Deadlock. Explain Deadlock.
  103. 103. www.edureka.co/ C# Interview Questions Illustrate Race Condition. Question 49
  104. 104. www.edureka.co/ C# Interview Questions Question 49 Race Condition A Race condition occurs when two threads access the same resource and try to change it at the same time. The thread that access the resource first cannot be predicted. Illustrate Race Condition.
  105. 105. www.edureka.co/ C# Interview Questions What is Thread Pooling? Question 50
  106. 106. www.edureka.co/ C# Interview Questions Question 50 What is Thread Pooling? A Thread Pool is a collection of threads that perform tasks without disturbing the primary thread. Once the task is completed by a thread it returns to the primary thread.
  107. 107. www.edureka.co/pmpPMP® CERTIFICATION EXAM TRAINING
  108. 108. PMP® CERTIFICATION EXAM TRAINING www.edureka.co

×