Blog for Junior Developers C#/.NET

Saturday, June 22, 2024

We are already at the halfway point, in several previous materials I presented you 50 very popular questions that you may encounter during job interviews when applying for the position of a junior .NET programmer. In today's article we will move on to the next ones.

100-interview-questions-and-answers-for-junior-developers-csharp-dotnet-part-6-10.jpg

51) What are the fundamental paradigms of object-oriented programming?


There are four pillars on which object-oriented programming is based: inheritance, polymorphism, abstraction and encapsulation.

Inheritance, a type of relationship between two classes that allows one of them to inherit the code of the other.

Polymorphism, the ability to save one method in different forms.

Abstraction, operating on objects without knowing the details of their implementation.

Encapsulation, i.e. hiding certain data to protect against incorrect operation.

Here you may also be asked to develop any of these 4 pillars. I develop each topic in more detail on my blog, so if you are interested in the details, be sure to take a look.


52) What are immutable objects?


Immutable objects are objects that remain immutable (read-only) after initialization. An example of an immutable object in C# is a string whose values ​​we cannot change. If we assign a string variable, a new object is actually created.


53) What is LINQ?


The acronym LINQ comes from Language-Integrated Query, it is a part of .NET technology that allows you to ask questions on objects.

This is a collection of extension methods from the System.Linq namespace. Thanks to LINQ, we can query a given collection or several collections and retrieve the objects we are interested in from them. We can use data filtering, sorting, joining or grouping.

We have two LINQ syntaxes to choose from, the so-called query syntax, i.e. query syntax, and method syntax, i.e. method syntax, also called lambda expression, i.e. lambda expressions.

var numbers = new List<int> { 0, 8, 9, 13 };
var evenNumber = numbers
                .Where(x => x % 2 == 0)
                .OrderByDescending(x => x);


54) What are lambda expressions?


Lambda expression, it is an anonymous method, a short method without declaration, which is most often used for LINQ queries. We can create such an expression in a simple way and exactly where we need to use it. This allows us to save time on writing a separate method with a full declaration.

var evenNumber = numbers
                .Where(x => x % 2 == 0);

x => x % 2 == 0
[input parameters] => [expression]


55) What is ORM?


ORM stands for Object Relational Mapping. It is a way of mapping an object-oriented architecture to a relational database. ORM allows us to create a query on a database using an object-oriented programming paradigm, i.e. we can operate on ordinary objects, e.g. in C#, and calls to various methods or properties will be converted into SQL queries.

_context.Books.Add(new Book);
_context.SaveChanges();

INSERT INTO Books(column1, columne2) 
VALUES (value1, value2);


56) What is Entity Framework Core?


Entity Framework Core is a lightweight, extensible, open-source, cross-platform ORM framework that is part of Microsoft .NET Core. It was created to be easier to use and have better performance than its predecessor Entity Framework.

Its main goal is to increase the productivity of programmers when working with databases. We can generate read queries and write commands against the database. If you want to query a database, you can use the LINQ syntax. Entity Framework Core will execute the appropriate query and map the result to your model objects. Entity Framework Core supports databases such as SQL Server, SQLite, PostgreSQL, MySQL, Oracle and Firebird.


57) How to implement multiple interfaces with the same method name in the same class?


In such a case, the interface name should be explicitly provided before the method name.

public interface IPerson1
{
    void DisplayName();
}

public interface IPerson2
{
    void DisplayName();
}

public class Student : IPerson1, IPerson2
{
    void IPerson1.DisplayName()
    {
    }
    void IPerson2.DisplayName()
    {
    }
}


58) Can we use this keyword in a static class?


NO. The keyword this cannot be used in a static class because the this keyword is a reference to the current class instance and a static class is not an instance of an object.


59) What is boxing and unboxing in C#?


Boxing converts a value type (int, double, char, etc.) to a reference type (object), using implicit conversion.

Unboxing is the opposite operation. That is, it converts a reference type (object) to a value type (int, double, char, etc.), this time using an explicit conversion.

int number1 = 1;         
object obj = number1;//boxing
int number2 = (int)obj;//unboxing


60) What are generic types in C#?


Thanks to generic types, we can create code that we can use multiple times without having to repeat the same pieces of code. A good example of a generic type in C# is a list. The list implementation allows us to pass and work on any elements.

We can also create our own generic classes. Where each occurrence of T (the default name is T, but it can be any name. It is recommended that it starts with the letter T) will be replaced with the type passed in the declaration.

public class List<T>;

var listOfInt = new List<int>();
var listOdDouble = new List<double>();
var listOdString = new List<string>();
var listOfStudents = new List<Student>();


TERMINATION


That's all in terms of questions for this material. We will come back to the next ones in the next article. If you like this material, be sure to join my community - free registration, where you will also have access to additional materials.

That's all for today, see you in the next article.

Author of the article:
Kazimierz Szpin

KAZIMIERZ SZPIN
Software Developer C#/.NET, Freelancer. Specializes in ASP.NET Core, ASP.NET MVC, ASP.NET Web API, Blazor, WPF and Windows Forms.
Author of the blog CodeWithKazik.com

Previous article - 100 Interview Questions (and Answers!) for Junior Developers C#/.NET (Part 5/10)
Next article - 100 Interview Questions (and Answers!) for Junior Developers C#/.NET (Part 7/10)
Dodaj komentarz

Search engine

© Copyright 2024 CodeWithKazik.com. All rights reserved. Privacy policy.
Design by Code With Kazik