Skip to content

Instantly share code, notes, and snippets.

@ddieppa
Last active August 28, 2024 02:13
Show Gist options
  • Save ddieppa/a136f03faaff0d1d555f33963436b3ff to your computer and use it in GitHub Desktop.
Save ddieppa/a136f03faaff0d1d555f33963436b3ff to your computer and use it in GitHub Desktop.
Job Interviews
published: true

Interview questions

C# Questions

  • Overloading vs Overriding

    • Overloading: Is the ability to have multiple methods within the same class with the same name, but with different parameters. Each of these methods has their own implementation as well, meaning that they can behave differently depending on what is passed in.
    • Overriding: Is the ability to redefine the implementation of a method in a class that inherits from a parent class. When a method is overridden, the name and the parameters stay the same, but the implementation that gets called depends on the type of the object that's calling it.
  • DI(Dependency Injection) what is and what solve?

    • DI: Is a software design pattern, which is a technique for achieving Inversion of Control (IoC) between classes and their dependencies. Is a technique whereby one object (or static method) supplies the dependencies of another object
    • Solve: Is a key part of building loosely coupled applications, since implementation details can be written to depend on and implement higher-level abstractions, rather than the other way around
  • What is SOLID

    • S: Single Responsibility
      • States that each class, module, or function in your program should only do one job
    • O: Open Close
      • Software entities should be open for extension, but closed for modification.
    • L: Liskov Substitution
      • Any class must be directly replaceable by any of its subclasses without error
    • I: Interface Segregation
      • Many client-specific interfaces are better than one general-purpose interface
    • D: Dependency Inversion
      • High-level modules should not depend on low-level modules. Instead, both should depend on abstractions
  • Reflection

    • pros
    • cons
  • what http response contains

  • http code 200 and 500, what they are

  • what I have implemented using Rest API

  • what is sql injection and how to avoid it (validations)

  • 4 important http verbs

    • POST, GET, PUT, DELETE
  • when you think of microservices, what comes to mind?

  • what is most important thing when designing database (what are main concepts?)

    • Database design basics
    • Determine the purpose of your database: This helps prepare you for the remaining steps.
    • Find and organize the information required: Gather all of the types of information you might want to record in the database, such as product name and order number.
    • Divide the information into tables: Divide your information items into major entities or subjects, such as Products or Orders. Each subject then becomes a table.
    • Turn information items into columns: Decide what information you want to store in each table. Each item becomes a field, and is displayed as a column in the table. For example, an Employees table might include fields such as Last Name and Hire Date.
    • Specify primary keys: Choose each table’s primary key. The primary key is a column that is used to uniquely identify each row. An example might be Product ID or Order ID.
    • Set up the table relationships: Look at each table and decide how the data in one table is related to the data in other tables. Add fields to tables or create new tables to clarify the relationships, as necessary.
    • Refine your design: Analyze your design for errors. Create the tables and add a few records of sample data. See if you can get the results you want from your tables. Make adjustments to the design, as needed.
    • Apply the normalization rules: Apply the data normalization rules to see if your tables are structured correctly. Make adjustments to the tables, as needed.
  • what are main concepts of rest api?

  • how do you secure your api?

  • how do you test your apis?

what is main difference between abstract class and interface

  • Abstract: Use it when wanna achieve Generalization

    • Implementation: Can contain both abstract members (methods without implementation) and concrete members (methods with implementation).
    • Inheritance: A class can inherit from only one abstract class.
    • Access Modifiers: Members can have different access modifiers (public, protected, private).
    • Fields: Can declare fields (variables) to store state.
    • Constructors: Can have constructors to initialize the state of the object.
    • Use Case: When you want to provide a common base with some default implementation and force derived classes to implement specific methods.
  • Interface: Use it when wanna achieve Standardization. In C# interfaces can contain some default implementations for their members, which allows you to evolve interfaces without breaking existing implementations.

    • Implementation: Contains abstract members (method signatures without implementation) and can now include default implementations for some or all of its members.
    • Inheritance: A class can implement multiple interfaces.
    • Access Modifiers: All members are implicitly public.
    • Fields: Cannot declare fields.
    • Constructors: Cannot have constructors.
    • Use Case: When you want to define a contract that multiple unrelated classes can adhere to, promoting polymorphism and loose coupling. The ability to provide default implementations adds flexibility in evolving interfaces without breaking existing implementations.
  • how are you with working on minimal requirements?

  • what is Static, when to use it https://stackoverflow.com/questions/241339/when-to-use-static-classes-in-c-sharp A static constructor is only called one time, and a static class remains in memory for the lifetime of the application domain in which your program resides. Two common uses of static fields are to keep a count of the number of objects that have been instantiated, or to store a value that must be shared among all instances.

    • pros The advantage of using a static class is that the compiler can check to make sure that no instance members are accidentally added. The compiler will guarantee that instances of this class cannot be created.
    • cons Only one copy of a static member exists, regardless of how many instances of the class are created. Static methods and properties cannot access non-static fields and events in their containing type, and they cannot access an instance variable of any object unless it's explicitly passed in a method parameter. Static methods can be overloaded but not overridden, because they belong to the class, and not to any instance of the class. No polimorphism, no interfaces

Please explain the purpose of the keyword "static" in C#. Please provide an example where a static variable (not constant) can be used

In C#, the keyword "static" is used to declare members that belong to the type itself rather than to a specific instance of the type. This means that static members are shared across all instances of the class and can be accessed without creating an instance of the class.

The purpose of the "static" keyword is to allow accessing methods, fields, and properties directly on the class without needing to instantiate an object. This can be particularly useful for utility classes or when maintaining state or performing operations that are not tied to a specific instance.

Please explain where and how "async" and "await" keywords are used. Please provide an

async Keyword: This is used to designate a method, lambda, or anonymous function as asynchronous. An async method typically returns a Task, Task, or void (only for event handlers).

await Keyword: This is used within an async method to pause its execution until the awaited task is complete. The await keyword can be thought of as a non-blocking wait, allowing the main thread to continue executing other code while the task is running.

The async and await keywords in C# are used to facilitate asynchronous programming, making it easier to write programs that perform multiple tasks concurrently, such as I/O-bound operations. This is particularly useful for tasks that take a long time to complete, like network requests, file I/O, or database operations, as it helps prevent blocking the main thread and keeps your application responsive.

Please explain the concept of dependency injection. Provide an example where DI is used

Dependency Injection (DI) is a design pattern used to achieve Inversion of Control (IoC) in software applications. In DI, the dependencies of a class are provided from the outside rather than being created within the class itself. This allows for better decoupling of components, making the code more modular, testable, and maintainable. Dependency: An object that another object depends on to function. Inversion of Control: The control of object creation and lifecycle is "inverted," meaning it's handled by an external entity (often a DI container). Loose Coupling: Classes are not directly responsible for creating or managing their dependencies, leading to more modular and maintainable code. Testability: DI makes it easier to replace dependencies with mocks or stubs in unit tests.

What is the difference between POST and PUT methods in restful services. Can they be used interchangeably

  • POST method is used to create a new resource on the server. It sends data to the server to be stored under a new URL. Each time a POST request is made, a new resource is created with a unique identifier assigned by the server.

  • PUT method is used to update an existing resource on the server. It sends data to the server to replace the entire resource or create it if it doesn't exist. The PUT request is idempotent, meaning that multiple identical requests will have the same effect as a single request.

While both POST and PUT methods can be used to send data to the server, they have different purposes and behaviors. POST is used for creating new resources, while PUT is used for updating existing resources. They should not be used interchangeably as it would violate the principles of RESTful design.

Javascript Questions

  • what are the ways of create and object in Javascript
    • Object Literal syntax
    • using the new keyword
    • Object.create
    • Object.assign
    • ES6 classes
  • what is the rest functionality in javascript (rest params?)
  • Get the top of an array and how to get the bottom
  • what are observables in javascript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment