Developer interview questions – C# .net

By | Mar 30, 2018

Some basic interview questions.

Its not comprehensive and ill extend this as needed.

C# Basics

  • What are the different types of loops you get in C#?
    (Answer : For, For-each, While & Do While)
  • In a loop you can use the terms continue and break. Explain the differences.
  • What is Object Oriented Programming?
    (Answer: Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions)
  • What is a class?
    (Answer: a class is an code-template for creating objects)
  • What is a object?
    (Answer: a object is an instance in memory of a class)
  • What is a sealed class?
    (Answer: a class structure that is sealed cannot be inherited from)
  • What is an event?
    (Answer: An event is a notification sent by an object to signal the occurrence of an action)
  • What is a delegate?
    (Answer: A delegate is a type that represents references to methods with a particular signature)
  • Name an Immutable type.
    (Answer: String)
  • What is an Immutable type?
    (Answer: An immutable type, in the context of C#, is a type of object whose data cannot be changed after its creation)
  • What is the difference between Private and Protected fields?
    (Answer: Private fields can only be accessed by the owner class. Protected fields can be accessed by the owner as well as derived classes)
  • What are the implications of using a Nullable bool?
    (Answer : 3 potential states instead of 2. Null, True & False)
  • Do you know what CRUD is?
    (Answer: Create, Read, Update & Delete)

C# Project Structure related

    • What is a namespace and why do we need it?
      (Answer: A namespace is used to group, classify, identify and access related code elements)
    • What is the Microsoft standard for namespaces?
      (Answer: Company.Product|Technology.Feature.Subnamespace)
    • When building an application in C# that has a web user interface and database. What different types of projects you should ideally have inside your solution?
      (Answer: UI, Business Layer, Data Layer)
    • When writing an application how many git repositories would you use?
    • Should your folder structure in C# mirror your namespaces?
      (Answer: Ideally yes)

C# Intermediate

  • What is the difference between .Net Framework and .Net core?
    (Answer: .Net Framework is nog considered legacy and only works on Windows. .Net core is cross platform capable)
  • What is the difference between constants and static variables.
    (Answer: Constants are set at compile time, statics and read-only variables are set at runtime)
  • Why are static variables potentially dangerous when used?
    (Answer: There is a potential that errors can slip in if an thread is using the value meant for another thread)
  • What is a Nuget package?
    (Answer: NuGet is a package manager designed to enable developers to share reusable code.)
  • What is the benefit of using Nuget package?
    (Answer: Enable developers to share reusable code that is version based.)
  • What is the difference between Try, Catch and Try, Finally?
    (Answer: The Catch section will only be executed in the case of an error. Finally will always be executed)
  • What is the difference between Throw and Throw ex?
    (Answer: Throw ex is potentially bad as it looses the stack trace and all the information needed for troubleshooting)
  • What is the difference between logging, tracing and auditing?
  • Is there a string type in C# that could be used to if the contents is confidential?
    (Answer: SecureString)
  • Can a static class have a constructor?
    (Answer: Yes)
  • What are access modifiers in C#?
    (Answer: Access modifiers are keywords in object-oriented languages that set the accessibility of classes, methods, and other members.)

    • Name the different types of access modifiers you get in C#.
      (Answer: Private, Protected, Internal, Public)

      • What is the point of the protected access modifier?
        • Explain encapsulations.
        • Explain what the virtual keyword is used for.
        • Explain what the abstract keyword is used for.
  • What are design patterns?
    (Answer: design patterns are commonly occurring patterns of class structures used to solve common problems)

    • Where would you use an Abstract class instead of an Interface?
      (Answer: Abstract classes are used to enforce a signature & behaviour, Interfaces are used to enforce a signature)
    • What is inheritance?
      • Does C# support multi-Inheritance?
        (Answer: Yes only through Interfaces.)
      • Explain Polymorphism
        (Answer: Polymorphism is an OOP ability where a sub class can be cast as another from which the subclass inherits. Animal -> Mammal -> Human.
        Human can be cast as Animal)
    • What is composition?
      (Answer: Composition is when an object is composed of of other objects and the parent object takes ownership / responsibility to own the life cycle of another’s and use it internally)
    • What is aggregation?
      (Answer: Aggregation is when a object makes use of of another object to extends its own behaviour but the parent object does not take ownership / responsibility to own the life cycle of the other objects)
    • What is the differences between Composition and Aggregation?
    • What is the benefit of using a Factory method pattern?
      (Answer: Factory Method is a creational pattern used to create instances of classes that implemented a common interface. It separates the process of creating an object from the code that depends on the interface of the object. )
    • Where would I use an Adapter pattern?
      (Answer: Adapter pattern is the most common pattern. A Class wraps another and extends the behaviour without inheriting from the source class)
    • What is the benefits of using a template pattern in your code?
      (Answer: Forces a behaviour and a design on those that inherit from it)
    • Give examples of behavioral and structural pattern.
    • What are the benefits of the bridge pattern?
  • What is a Tupel?
    (Answer: a lightweight / generic class to used provide structure.)
  • What is the GAC?
    (Answer: Global allocation cache)

    • Why do we need the GAC?
  • Have you heard of Open API or Swagger? What is it?
  • What is the benefits of using

Intermediate – memory management

    • Where would you use the IDisposable interface?
      (Answer: IDisposable is often used as an easy way to do cleanup of managed objects. )

      • Where would use the using clause?
        (Answer: Use USING statement when objects implements IDisposable interface) 
    • What is GC in .net?
      • Explain how the garbage collector work.

Troubleshooting

  • When building your application in visual studio you get an error that the dll you are trying to build is already in use. How do you solve this?
  • If you get an “Access Violation Exception” in C# what does it mean and how would you solve it?
  • You get a HTTP 400 when calling a web service endpoint. What does it mean and how would you solve it?
  • In SQL you have a large stored procedure of several hundred lines that have dependencies on several other stored procedures it is returning the incorrect values. How do you go about debugging this?
  • You are using IIS of your development machine and it keeps on crashing when you access the website. Where would you go on your pc to get more information about what is happening?

C# Data Access

  • What is the benefits of using parameterized queries?
    (Answer: Query execution plans get cached which result in faster execution and it helps to prevent SQL injection)
  • Give me some examples of an OR Mapper.
    (Answer: Entity framework, LLBLGen, NHibernate & Dapper)
  • What is the benefit of using a OR Mapper?
    (Answer: OR Mapper maps data tables and relationships to class structures which allows developers to interact with database elements as if they are just classes in code)
  • What is the benefits of ADO.net over Entity framework?
    (Answer: Ado.net has much faster execution time that Entity framework but you pay the cost in the form of performance over the ease of usability 

    • What is the benefits of Entity framework over ADO.net?
      (Answer: Entity framework allows developers to do rapid database application development at a slight cost in performance)
  • What is the benefits of using Dapper over ADO.net & Entity framework?

SQL

  • What is the difference between SQL and DDL?
    (Answer:  SQL is used to retrieve, interact and alter data. DDL is used to interact and alter data structures)
  • In SQL Server, what is collation? (Answer: refers to a set of character and character encoding rules when saving character related data)
  • What is a no-sql database?
    • Where would you use it?
  • What is 3rd normal form?
    • When will you de-normalize data?
  • What is the purpose of a Foreign key?
    • What is referential integrity?
  • Explain the difference between left, right and inner join.
  • When do you use a trigger?
  • What is a CTE (Common table expression)?
    (Answer: a type of SQL query that handles hierarchical and recursive data models with nested parent-> child relationships)

    • Why should you use a CTE (Common table expression) instead of a recursive stored procedure?
      (Answer: A CTE can be used to: Create a recursive query)
    • Is there a limit in SQL server on how many times a stored proc can recursively call itself?
      (Answer: 32)
  • Why does data need to be indexed? How does it work?
  • What is data replication?
  • We are importing documents into our sql database, How would I go about searching within the documents? (Answer: Full text searching)
  • If you had to optimize a stored procedure, how would you go about it? What are the things you will look at?

C# Advanced

  • You have to create a web service. How do you ensure Interoperability?
    • If I have a WCF service making use of TCP binding. What would I need to do to ensure Interoperability?
      (Answer : Use the Http binding)
  • How would you design a library so that it can be extended or changed without having to alter the existing code.
    (Answer: Virtual methods & Template patterns or IOC)
  • What is the point of generics?
    • Does generics support Inheritance?
  • How would you change the default way C# compares the equality of two instances?
  • Where would you use the observer pattern?
  • Name the different types of collections you get in .net.
    • What is the difference in behaviour between a .net Queue and a Stack.
  • What is thread locking?
  • What is the difference between .net Threads and Tasks?

Advanced – memory related

    • What is the difference between a Value type and a Reference type.
    • What is the difference between an Object and a Class.
    • What is the difference between the Heap & the Stack?
      • What is the Heap?
        (Answer : The Heap Space contains all objects are created within an application)
      • What is the Stack?
        (Answer:  The Stack is a pointer to a limited size of memory that is allocated per function. The stack is where reference to objects in the Heap are stored.)

        • What does it mean if you get a Stack overflow? (Answer : In software, a stack overflow occurs if the call stack pointer exceeds the stack bound. The call stack may consist of a limited amount of address space)
    • The .NET Garbage Collector has 3 generations and each generation has its own heap can you explain how objects move from the first to the 3rd generation and what does it mean?

Security & Privacy

  • What is SQL injection and how do you prevent it?
  • What is cross site scripting?
  • What would you use to prevent Hackers from listening in on the internet and intercepting  client usernames, passwords and banking information?
    (Answer: Certificates, SSL Certificate)

    • Name the different types of SSL certificates you get.
      (Answer : Basic \ Single domain SSL, Multi-domain SSL, Wildcard SSL)
  • How do you prevent man in the middle attacks when you are making use of a certificate already? (Answer: Set a Http Secure Transport Header (HSTS))
  • How would I protect my code from people that would like to reverse engineer our code. (Answer: Use a strong name key,  use code obfuscation, Code a certain way, make all public classes sealed)

Concepts

  • What is class explosion?
  • What is coupling?
  • What is separation of concerns?
  • What is parallel processing?
  • What is inversion of control (IOC)?
  • What is the difference between an API & Service?

Opinion check of person

  • Why do we need coding standards?
  • Is it a good idea to comment your code or is there another way?
  • Do you think code reviews are beneficial?
  • Is C# better than VB.net or Delphi.net
  • Do you think design patterns are still needed?
  • Is designing for code-reuse good or bad?
    • Is coupling good or bad?
  • What type of databases should a team use when starting a project…
    (Answer: depends on the use case)

Rattle the cage questions

To be used on very confident looking individuals before the real interview.

  • Why is a man hole cover round?
    (Answer: It does not need to be rotated to cover the hole and to prevent the lid from falling into the whole)
  • If you look at a clock and the time is 3:15, what’s the angle between the hour and the minute hands?
    (Answer : Usually, if the answer to a brainteaser seems too easy, chances are the answer’s wrong. And in this case, the answer is not zero degrees. The hour hand, remember, moves as well. That is, in addition to the minute hand. And so, at 3:15, the hour hand and the minute hand are not on top of each other. In fact, the hour hand has moved a quarter of the way between the 3 and 4. This means it’s moved a quarter of 30 degrees (360 degrees divided by 12 equals 30). So the answer, to be exact, is seven and a half degrees (30 divided by four).)
  • If you have seven white socks and nine black socks in a drawer, how many socks do you have to pull out blindly in order to ensure that you have a matching pair?
    (Answer: The answer is three: if the first one is one color (say, white), and the second one is the other color (black), then the third one, no matter what the color, will make a matching pair. )

Architectural

  • What is the difference between layers and tiers.
  • What is SOA?
  • What is the point of MVC (Model – View – Controller)?
  • What is REST?
  • Can I make use of REST without the HTTP protocol?

Infrastructure

    • What is the difference between hosting at a datacenter and hosting in the cloud?
    • IAAS vs PAAS
    • What is a fall-over cluster?

AWS

    • What is a EC2?
    • What is the difference between a managed and a server less service?
    • How do I achieve high availability in AWS?
    • How do I ensure Fault tolerance?
0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments