C# .NET Interview Questions

¡Supera tus tareas y exámenes ahora con Quizwiz!

How are methods overloaded

Methods are overloaded by the number of parameters, or types. You can overload a method by having different data types, number of parameters, or a different order of parameters.

Countingsort

N

Radix Sort

N

Selection Sort

N2

What are namespaces and how are they used?

Name spaces are used to organize classes in the .NET framework. They dictate the logical structure of the code.

Can multiple inheritance be implemented in C#?

No, derived classes can inherit from only one base class. If you want to inherit from multiple base classes use a interface

Can a struct be inherited?

No, it is implicitly sealed.

Define what a property is

Properties are a type of class memeber, Getters and setters

What is inheritance

Provides a convenient way to reuse existing code in a diferent context.

What are the access modifiers in C#?

Public, Private, Protected, Internal, Protected Internal

What is an outer join

Returns matching rows from both tables as well as any unmatched rows from one or both the tables

What are sealed modifiers

Sealed types cannot be inherited

What is self join and why is it required?

Self join is the act of joining a table with itself.

What is an inline function

Serves as a compiler directive, and to change linkage behavior

What is the difference between a struct and a class?

Structs cannot be inherited. Structs are passed by value and not by reference, Structs are stored on the stack, not the heap. Which results in better performance with Structs.

What is the GAC and where is it located

The GAC is the Global Assembly Cache. Share assemblies reside in this, and allow applications to share assemblies instead of having assemblies distributed with each application. Versioning allows multiple assembly versions to exist in the GAC and applications can specify version numbers in their config file.

What is the execution entry point for a C# console application

The Main method

What is polymorphism?

The ability to process objects in different ways depending ont heir data type or class

What are sealed classes?

A sealed class means it cannot be inehrited in the derived class.

What is overloading

Methods are created with the same name. A print string method for instance.

What is a constructor?

A special method that gets invoked automatically, whenever an object of a given class is instantiated.

What is a class?

A class is a generic definition template of an object that will be created of that time.

What is an abstract class in c#?

A class that is not instantiated, if a method is defined as abstract, it must be implemented in the derived class.

What is a Constructor

A constructor is a class member executed when an instance of the class is created. It has the same name as a class and can be overloaded. They are used for initialization.

What is BNF?

Backus Naur Form, a mathematical way to describe a language.

Bubble Sort

Best: N Worst: N2

Insertion Sort

Best: N Worst: N2

What is the queue?

A queue is a container of objects taht are isnerted and removed according to the First in First Out principle. Only two operations, enqueue and dequeue.

QuickSort

Best:nlogn Avg: nlogn Worst:N2

What is a virtual method/

A virtual method has implementation and provides the derived class with the option to override it

What is an abstract method?

Abstract methods don't provide implementation and forces the derived class to override the method.

What are the basic concepts of OOP

Abstraction, Encapsulation, Inheritance, Polymorphism

Internal

Access is restricted to classes within the current project assembly

Protected Internal

Access is restricted to classes within the current project assembly and types derived from the containing class.

What is an abstract class

An abstract class is a class that can not be instantiated. It exists for inheritance and it must be inherited. Usually base-classes in a n inheritance hierarchy. You cannot make an object of this class.

What is an interface in c#?

An interface is similar to a class with methods. There are not any implementations in an interface. Classes which implement the interface should have an implementation of methods defined in the abstract class

What is an object?

An object is an instance of a class, that contains some properties.

What is boxing?

Boxing is the process of explicitly converting a value type into a corresponding reference type. It involves creating a new object on the heap and placing the value there, reversing the process is unboxing, which converts the value in an object reference on the heap into a corresponding value type on the stack.

How do you initiated a string without escaping each backslash

By using an @ sign in front of the string.

What is DLL Hell and how does .NET solve it?

DLL Hell is the difficulty of managing DLLs on a system. When a DLL (assembly) is loaded in .NET, it is loaded by name, version, and certificate. The assembly contains all of this information in its metadata. The GAC provides the solution so that you can have multiple versions of a DLL side-by-side

What are the types of constructors?

Default, parameter, copy, static, and private

What is method hiding?

If the derived class doesntw ant to use methods in the base class, a derived class can implement the same method.

What does the virtual keyword do in C#?

If you want to give permission to a derived class to override a method in a base class, use the virtual keyword.

Why are strings in C# immutable?

Immutable means the string values cannot be changed once they have been created. If you change the value of the string, it creates a new instance of the string. This causes inefficient use of memory and extraneous garbage collection. StringBuilder class should be used when you are going to change strings.

What is a static field

It can only be stored once no matter how many instances of the class we crate

What is hte heap/

It has dynamic memory allocation. Variables on the heap have their memory allocated at run time, and it is slower than the stack. Heap is application specific. The heap has no dependencies on each other and can be accessed randomly at any time.

What is the virtual keyword

It indicates that a member can be overridden in a child class.

What is a singleton?

It is a design pattern used when only one instance of an object is created and shared meaning it only allows itself to be created once. Any attempt to create another results in a reference to the first. Singleton classes are created by defining all class constructors as private. A private static member is created as the same type of the class, along with a public static member that returns an instance of the class. public class SingletonExample { private static SingletonExample _Instance; private SingletonExample () { } public static SingletonExample GetInstance() { if (_Instance == null) { _Instance = new SingletonExample (); } return _Instance; } }

What is an inner join

It is the most common type of join in which it combines the rows from two tables and creates a result set containing only those records that are present in both tables.

What is data encapsulation

It is the process of hiding the important fields from the end user. set { if(value>0) { minSalary = value; } }

What is an interface

It is the same as an abstract class except we can only define method definitions and no implementations.

What is an interface

It mandates a set of behaviors but not the implementation, it must be inherited and you cannot create an instance of an interface.

What is polymorphism

It means one interface has many forms. You have the ability to assign different meaning or usage to something allowed a variable, function or object to have more than one different form. Compile time: function or operator overloading Runtime: inheritance and virtual functions

What is the difference between join and union

JOIN allows us to lookup records on the table based on the given conditions between two tables. UNION allows you to add two similar data sets to create resulting data sets that contains all the data from the source data set

Private

Method or attribute can be accessed by any code within the containing class only

Protected

Method or attribute can be accessed by any method in the inherited class and any method within the same class

Public

Method or attribute can be accessed from any code int he project.

What is the difference between the stack and queue?

The difference between the stack and queues are the way things are removed. In the stack we remove the item most recently added, in the queue we remove the item the least recently added.

What is the New modifer

The new modifier hides a member of the base class

How do you prevent a class from being inherited

The sealed keyword prohibits a class from being inherited

What is overriding in c#?

To override a base class method that is defined as a virtual, this is used.

What is the difference between UNION and UNION ALL

UNION and UNION ALL both unify for adding two datasets, but union all returns all the rows even if one or more rows are duplicated.

What is the differente between UNION, MINUS, and INTERSECT

UNION combines results form two tables and eliminates duplicate records, MINUS gives us all the rows from the first table except rows that are present in the second table, INTERSECT returns only the matching or common rows between 2 result sets

How can we transpose a table using SQL?

Use a CASE statement or DECODE statement

What is the difference between WHERE and HAVING

WHERE and HAVING both filter out records based on on or more conditions, but WHERE can only be applied ona static non aggregated column.

What is the stack?

When a program executes, a contiguous section of memory is set aside, which is the stack. Last in first out, pushing and popping. It is a recursive data structure.

What is a destructor

a destructor is a special method that gets invoked automatically whenever an object of a given class is destroyed.

What is OOP

a programming language organized around objects rather than actions and data rather than logic

Explain inheritance

it is a way to reuse code of an existing object.

Heapsort

nlogn

Mergesort

nlogn


Conjuntos de estudio relacionados

Middle School Science: What Effect Does the Moon Have on Earth?

View Set

AP Biology-Chapter 12.2: The Cell Cycle

View Set

Chap 3 Quiz Interpersonal / Perceptions

View Set

Biology 237 Unit 4 Exam Chap 12-15

View Set