.NET/C# Developer Interview Questions

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What are the possible ways of hosting a WCF service?

1. Console Application, 2. Windows Application, 3. Windows Service, 4. Web Server (IIS)

Sealed class

A class that cannot be derived from.

Queues

A queue is a container of objects (a linear collection ) that are inserted and removed according to the first-in first-out principle. Only two operations are allowed in a queue, enqueue and dequeue.

When can a race condition occur?

A race condition occurs when two or more threads can access shared data and they try to change it at the same time. Because the thread scheduling algorithm can swap between treads at any time, you don't know the order in which the threads will attempt to access the shared data. Therefore, the result of the change in data is dependent on the thread scheduling algorithm, i.e. both threads are "racing" to access/change the data.

Reference Type

A reference type contains a pointer to another memory location that holds the data

Singleton Class

A singleton is a class which only allows one instance of itself to be created. As a design pattern, this ensures access to that single instance through the application, It can be useful in cases where you have a "global" object with only one instance.

Stacks

A stack is a container of objects that are inserted and removed according to the last-in first-out principle. A stack is a limited access data structure.

What are threads?

A thread is the fundamental unit of execution within an application: A running application consists of at least one thread. Each trad has its own stack and runs independently from the application's other threads. By default, threads share their resources, such as file handles or memory. Problems can occur when access to shared resources is not properly controlled. Data corruption is a common side effect of having two threads simultaneously write data to the same block of memory.

Trees

A tree is a data structure consisting of nodes organized as a hierarchy.

Private

Access is limited to the containing type

Internal

Access is limited to the current assembly

(Protected Internal)

Access is limited to the current assembly or type derived from the containing class.

Public

Access is not restricted

Asynchronus JavaScript and XML (AJAX)

Ajax is a client-side script that communicates to and from a server/database without the need for a postback or a page refresh.

What is the difference between an interface and an abstract class?

An interface declares a set of related methods, outside of any class. Interfaces can have no state of implementation. A class that implements an interface must provide an implementation of all the methods of that interface. An abstract class is an incomplete class definition that declares but does not define all its methods. Abstract classes may contain state (data members) and/or implementation (methods) abstract classes can be inherited without implementing the abstract methods (though such a derived class is abstract itself)

Linked List

An ordered set of data elements, each containing a link to its successor (and predecessor for a doubly-linked-list).

Quick Sort

In quick sort, we pick a random element and position the array, such that all numbers that are less than the partitioning element come before all elements that are greater than it. The partitioning can be performed efficiently through a series of swaps.

Reference

Points to a memory location.

System.Object

The base class from which all classes are derived.

Clustered Index

A clustered index represents the physical order of the rows as they are stored in the database.

DataSet

A collection of DataTables. Conceptually, the DataSet acts as a set of DataTable instances. DataSet simplifies programs that use many DataTables.

Value Type

A data type is a value type if it holds the data within its own memory allocation.

Delegate

A delegate is a class that can hold a reference to a method. It can hold references only to methods that match its signature. A delegate can serve to point the event sender to an object or method that will receive (handle) the events it raises.

Graphs

A graph, like a tree, is a collection of nodes and edges, but has no rules dictating the connection among the nodes.

Hash Table

A hash table is a data structure that maps keys to values for highly efficient lookup.

Non-clustered Index

A non-clustered index is a logical ordering of the rows.

ReadOnly

A readonly field can be initialized either at the time of declaration or within the constructor of same class. Therefore, readonly fields can be used for run-time constants

Protected

Access is limited to the containing class or types derived from the containing class.

ArrayList

An ArrayList, or dynamically re-sizing array, is an array that re-sizes itself as needed while still providing 0(1) access. A Typical implementation is that when the array is full, the array doubles in size. Each doubling takes 0(n) time.

Abstract

An abstract class can implement some code, but cannot be instantiated. These are useful for functions that are common to all the derived children

Event

An event is a message sent by an object to signal the occurrence of an action. The action cold be cause by user interaction or by some other program logic

Indexers

An indexer provides array-like syntax. It allows a type to be accessed the same way as an array

System.Array.Clone()

Array.Clone creates a copy of an array as an object. It therefore needs to be case to the actual array type before it can be used to do very much. It works on both single and multi-dimensional arrays.

System.Array.CopyTo()

Array.CopyTo copies the elements of one array to another pre-existing aray starting grom a given index. Both arrays must be singe dimensional.

DataReader

Class in .NET that retrieve a forwarded stream of data from the database. DataReaders are appropriate when the need is to simply display the result set, as only one record at a time is ever present in memory.

Just-In-Time(JIT)

Compiles the Intermediate Language code to machine readable code before execution and then saves to memory. (Compiles at runtime)

What is a deadlock?

Consider the situation in which two threads block each other because each is waiting for a lock that the other holds. This is called a deadlock: Each thread is permanently stalled because neither can continue running to the point of releasing the lock that the other needs.

Constants

Constant fields must be assigned a value at the time of declaration and after that they cannot be modified. A constant field is a compile-time constant.

What are the two commands to remove all of the data from a table?

DELETE and TRUNCATE

Common Type System (CTS)

Datatypes defined in two different languages are compiled to a common datatype.

Heap

Does not track running memory and stores objects in a way that allows them to be reached at any moment.

Forms authentication

Enables you to identify users with a custom database such as an ASP.Net membership database. Alternatively you can implement your own custom database. Once authenticated you can reference the roles the user is in to restrict access to portions of your Web site.

Windows authentication

Enables you to identify users without creating a custom page.Credentials are stored in the Web servers local user database or an Active Directory domain. Once identified you can use the users credentials to gain access to resources that are protected by Windows authorization.

Finalize()

Finalize frees unmanaged resources that are held by an object before that object is destroyed. Internally called by the Garbage Collector and cannot be called by code.

Dispose

Frees unmanaged resources at any time. It is called by user code and must implement IDisposable interface.

What are the different verbs used in a RESTful Service?

GET, POST, PUT, DELETE, PATCH

Common Language Runtime (CLR)

Handles garbage collection, security, verification, and IL to Native translation.

Value

Holds both data and memory in the same location.

Binary Search

In binary search, we look for an element x in a sorted array by first comparing x to the midpoint of the array. It x is less than the midpoint, then we search the right half of the array. We then repeat this process, treating the left and right halves as sub-arrays. Again, we compare x to the midpoint of this sub-array and then search either its left or right side. We repeat this process until we either find x or the sub-array has size 0.

Bubble Sort

In bubble sort, we stat at the beginning of the array and swap the first two elements if the first is grater than the second. Then, we go to the next pair, and so on, continuously making sweeps of the array until it is sorted.

What are virtual methods? Why are they useful?

In object oriented programming, child classes can override (redefine) methods defined by ancestor class. If the method is virtual, the method definition to invoke is determined at run time based in the actual type (class) of the object on which it is invoked. In C#, methods are only virtual when declared with the virtual keyword -- non-virtual methods are the default. If the method is not virtual, then the method definition invoked is determined at compile time based on the type of the reference (or pointer).

What is inheritance?

Inheritance allows a class to be defined as a modified or more specialized version of another class. When class B inherits from class A, class A is B's parent or base class, and class B is A's subclass. All the behaviors defined by class A are also part of class B, though possibly in a modified form. In fact, an instance of class B can be used wherever an instance of class A is required.

Interface

Interfaces do not contain code, they are an agreement that any class that implements this interface has all the functionality listed in it. This is useful for loosely coupling objects

Overloading

Keeping the same functional name, but the parameters it can accept change.

Stack

Last In First Out. A stack is a collection of elements that where the last to be added is the first to be released, meaning that elements of the bottom can not be directly accessed. Memory allocation operates on this principle.

Merge Sort

Merge sort divides the array in half, sorts each of those halves, and then merges them back together. Each of those halves has the same sorting algorithm applied to it. Eventually, you are merging just two single-lement arrays. It is the "merge" part that does all the heavy lifting.

Overriding

Modifying the functionality of the base class for that function.

Intermediate Language(IL)

Object oriented programming language used by compilers before static or dynamic compilation. The code is partially compiled because it is made to independent of the machine, and we don't know what environment it will run in.

What is Polymorphism?

Polymorphism is the capability to provide multiple implementations of an action and to select the correct implementation based on the surrounding context.

What are the different access modifiers?

Public Protected Internal (Protected Internal) Private

Response.Redirect

Redirects a request to a new URL and specifies the new URL.

Unboxing

Reference --> Value (heap-->stack)

Passport authentication

Relies on a centralized service provided by Microsoft. Passport authentication identifies a user with their email and passport which can work across different websites

Code Access Security

Security model which accepts or denies permission to the assembly depending on the origin of the code.

Selection Sort

Selection sort is simple, but inefficient. Find the smalles element using a linear scan and move it to the front. Then, find the second smallest and move it, again doing a linear scan. Continue doing this until all the elements are in place.

Garbage Collector

Serves as a memory manager that automatically allocates and releases memory for an application. Looks for objects that are no longer being used.

Stored Procedures vs Functions

Stored Procedures are pre-compile objects which are compiled for the first time and its compiled format is saved which executes whenever called. A function is compiled and executed every time it is called

Global Assembly Cache

Stores assemblies which are to be used by several applications on the computer.

System.String

String is immutable, and therefore can not be modified. If changed, it creates a new instance of string type in memory. Slower than string builder.

System.Text.Stringbilder

StringBuilder is mutable, so you can modify without creating a new instance. Faster than String object when dealing with large strings.

Common Language Specification (CLS)

Subset of CTS which sets the guidelines which allow a language to be compatible with any .NET Language.

How do you handle an error from within a stored procedure?

TRY ... CATCH error handling. The code that could error is placed within a TRY block, If an error does occur, the code within the CATCH block executes. OR @@Error could be checked for an errorcode and then an error thrown using RAISERROR

Server.Transfer

Terminates execution of the current page and starts execution of a new page

What is a ViewState?

The method to preserve the value of the page and controls between round trips. Example, navigating a way from a page with a form and returning and everything is still there.

Out Keyword

The out keyword is also used to pass an argument like ref keyword, but the argument can be passed withot assigning any value to it. An argument that is passed using an out keyword must be initialied in the called method before it returns back to calling method.

Serialization

The process of converting an object into a stream of bytes in order to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed.

Ref Keyword

The ref keyword is used to pass an argument as a reference. This means that when the value of that parameter is changed in the method, it gets reflected in the calling method. An argument that is passed using a ref keyword must be initialed in the calling method before it is passed to the called method.

Using Statement

The using block helps manage resources. Conceptually it protects the whole system's resources by specifying the scope of the usage of the resource. The using statement is combined with a type that implements IDisposable.

Boxing

Value --> Reference (stack--> heap)

What is the difference between WCF and ASP.NET Web API?

Windows Communication Foundation is designed to exchange standard SOAP-based messages using a variety of transport protocols like HTTP, TCP, MSMQ, etc. On the other hand, ASP.NET API is a framework for building non-SOAP based services over HTTP only.


Set pelajaran terkait

Talking to people/ conversation words

View Set

Tener Expressions, Irregular Verbs/Spanish 1, 5A La familia, 4B Quieres ir conmigo?/8th, Interrogatives/Asking Questions/8th, 4A ¿Adónde vas?/ 8th, 3B Para mantener la salud/8th, 3A ¿Desayuno o Almuerzo?, 2B Tu sala de clases/8th, Common -AR verbs/8t...

View Set

Kin 173 exam 2- skeletal muscle adaptation to exercise

View Set

ATI Fundamentals for Nursing Edition 11.0

View Set

CSCI 301 10/17/2023 - Testing Oracle & Testing Coverage

View Set