Direction:
Contacting
©Info
404-447-3025
Cart (0)
SUPPORT
FAQ
BLOG
Toggle navigation
About
Contact
Store
Login
Profile
Orders
Logout
Technology
Explore Programming Skills?
C#
.Net
Asp.Net MVC
Asp.Net
Asp.Net Core s
........................
Web API
WPF
Blog
Explore Home Features?
Angular
React
Java
Java Script
Git and GitHub
..................................
HTML5
Ajax
Google API
Explore Home Features?
About Us
Entity Framework
CSS
Html5
Bootstrap
......................
Google API
Other
WCF
Explore Home Features?
SQL Server
Oracle
MongoDB
MySql
Other
........................
Google API
Other
WCF
Services
Explore Home Features?
Servi1
Policies & Procedure
Blog
Site Photos & Contributers
Site Photos & Contributers
Explore Home Features?
About Us
Policies & Procedure
Blog
Site Photos & Contributers
Site Photos & Contributers
Explore Home Features?
About Us
Policies & Procedure
Blog
Site Photos & Contributers
Site Photos & Contributers
Explore Home Features?
About Us
Policies & Procedure
Blog
Site Photos & Contributers
Site Photos & Contributers
Dashboard
C# Sharp Top questions
Find by name:
New Post
Recent Post
Explain types of comment in C# with examples
Single line. Multiple line (/* */). /*This is a multiple line comment. XML
Can multiple catch blocks be executed?
No, Multiple catch blocks can't be executed. Once the proper catch code executed, the control is transferred to the finally block, and then the code that follows the finally block gets executed.
What is the difference between public, static, and void?
Public declared variables or methods are accessible anywhere in the application. Static declared variables or methods are globally accessible without creating an instance of the class. Static member are by default not globally accessible it depends upon the type of access modified used. The compiler stores the address of the method as the entry point and uses this information to begin execution before any objects are created. And Void is a type modifier that states that the method or variable does not return any value.
What is an object?
An object is an instance of a class through which we access the methods of that class. A "New" keyword is used to create an object. A class that creates an object in memory will contain information about the method, variables, and behavior of that class.
Define Constructors
A constructor is a member function of a class that has the same name as its class. A constructor is automatically invoked whenever an object class is created. It constructs the values of data members while initializing the class.
What is Jagged Arrays?
The Array which has elements of type array is called jagged Array. The elements can be of different dimensions and sizes. We can also call jagged Array as an Array of arrays.
What is the use of 'using' statement in C#?
The 'using' block is used to obtain a resource and process it and then automatically dispose of when the execution of the block completed.
What is serialization?
When we want to transport an object through a network, then we have to convert the object into a stream of bytes. The process of converting an object into a stream of bytes is called Serialization. For an object to be serializable, it should implement ISerialize Interface. De-serialization is the reverse process of creating an object from a stream of bytes.
Can we use "this" command within a static method?
We can't use 'This' in a static method because we can only use static variables/methods in a static method.
What is the difference between constants and read-only?
Constant variables are declared and initialized at compile time. The value can't be changed afterward. Read-only is used only when we want to assign the value at run time.
What is an interface class? Give one example of it
An Interface is an abstract class that has only public abstract methods, and the methods only have the declaration and not the definition. These abstract methods must be implemented in the inherited classes through private method.
. What are value types and reference types?
A Value Type holds the data within its own memory allocation and a Reference Type contains a pointer to another memory location that holds the real data. Reference Type variables are stored in the heap while Value Type variables are stored in the stack.
What are Custom Control and User Control?
Custom Controls are controls generated as compiled code (Dlls), those are easier to use and can be added to toolbox. Developers can drag and drop controls to their web forms. Attributes can, at design time. We can easily add custom controls to Multiple Applications (If Shared Dlls). So, If they are private, then we can copy to dll to bin directory of web application and then add reference and can use them.User Controls are very much similar to ASP include files, and are easy to create. User controls can't be placed in the toolbox and dragged - dropped from it. They have their design and code-behind. The file extension for user controls is ascx.
What are sealed classes in C#?
We create sealed classes when we want to restrict the class to be inherited. Sealed modifier used to prevent derivation from a class. If we forcefully specify a sealed class as base class, then a compile-time error occurs.
What is method overloading?
Method overloading is creating multiple methods with the same name with unique signatures in the same class. When we compile, the compiler uses overload resolution to determine the specific method to be invoke.
What is the difference between Array and Arraylist?
In an array, we can have items of the same type only. The size of the array is fixed when compared. To an arraylist is similar to an array, but it doesn't have a fixed size.
Can a private virtual method can be overridden?
No, because they are not accessible outside the class.
What are the differences between System.String and System.Text.StringBuilder classes?
System.String is immutable. When we modify the value of a string variable, then a new memory is allocated to the new value and the previous memory allocation released. System.StringBuilder was designed to have a concept of a mutable string where a variety of operations can be performed without allocation separate memory location for the modified string.
What's the difference between the System.Array.CopyTo() and System.Array.Clone() ?
Using Clone() method, we creates a new array object containing all the elements in the original Array and using CopyTo() method. All the elements of existing array copies into another existing array. Both methods perform a shallow copy.
How can we sort the elements of the Array in descending order?
Using Sort() methods followed by Reverse() method.
Write down the C# syntax to catch an exception
To catch an exception, we use try-catch blocks. Catch block can have a parameter of system.Exception type. eg.try { GetAllData(); } catch (Exception ex) {}
What's the difference between an interface and abstract class?
Interfaces have all the methods having only declaration but no definition. In an abstract class, we can have some concrete methods. In an interface class, all the methods are public. An abstract class may have private methods.
What is the difference between Finalize() and Dispose() methods?
Dispose() is called when we want for an object to release any unmanaged resources with them. On the other hand, Finalize() is used for the same purpose, but it doesn't assure the garbage collection of an object.
What are circular references?
Circular reference is situation in which two or more resources are interdependent on each other causes the lock condition and make the resources unusable.
. What is an object pool in .NET?
An object pool is a container having objects ready to be used. It tracks the object that is currently in use, total number of objects in the pool. This reduces the overhead of creating and re-creating objects.
What are generics in C#.NET?
Generics are used to make reusable code classes to decrease the code redundancy, increase type safety, and performance. Using generics, we can create collection classes. To create generic collection, System.Collections.Generic namespace should be used instead of classes such as ArrayList in the System.Collections namespace. Generics promotes the usage of parameterized types.
List down the commonly used types of exceptions in .net
ArgumentException, ArgumentNullException , ArgumentOutOfRangeException, ArithmeticException, DivideByZeroException ,OverflowException , IndexOutOfRangeException ,InvalidCastException ,InvalidOperationException , IOEndOfStreamException , NullReferenceException , OutOfMemoryException , StackOverflowException etc.
What are Custom Exceptions?
Sometimes there are some errors that need to be handled as per user requirements. Custom exceptions are used for them and are used defined exceptions.
How do you inherit a class into other class in C#?
Colon is used as inheritance operator in C#. Just place a colon and then the class name. eg.public class DerivedClass : BaseClass
What is the base class in .net from which all the classes are derived from?
System.Object
What is the difference between method overriding and method overloading?
In method overriding, we change the method definition in the derived class that changes the method behavior. Method overloading is creating a method with the same name within the same class having different signatures.
What are the different ways a method can be overloaded?
Methods can be overloaded using different data types for a parameter, different order of parameters, and different number of parameters.
Why can't you specify the accessibility modifier for methods inside the interface?
In an interface, we have virtual methods that do not have method definition. All the methods are there to be overridden in the derived class. That's why they all are public.
How can we set the class to be inherited, but prevent the method from being over-ridden?
Declare the class as public and make the method sealed to prevent it from being overridden.
What happens if the inherited interfaces have conflicting method names?
Implement is up to you as the method is inside your own class. There might be a problem when the methods from different interfaces expect different data, but as far as compiler cares you're okay.
What is the difference between a Struct and a Class?
Structs are value-type variables, and classes are reference types. Structs stored on the Stack causes additional overhead but faster retrieval. Structs cannot be inherited.
How to use nullable types in .Net?
Value types can take either their normal values or a null value. Such types are called nullable types. Int? someID = null;If(someID.HasVAlue){}
What is difference between the "throw" and "throw ex" in .NET?
"Throw" statement preserves original error stack whereas "throw ex" have the stack trace from their throw point. It is always advised to use "throw" because it provides more accurate error information.
Is C# code is managed or unmanaged code?
C# is managed code because Common language runtime can compile C# code to Intermediate language.
What is Console application?
A console application is an application that can be run in the command prompt in Windows. For any beginner on .Net, building a console application is ideally the first step, to begin with.
What is boxing in C#?
When a value type is converted to object type, it is called boxing.
What is unboxing in C#?
When an object type is converted to a value type, it is called unboxing.
What is encapsulation?
Encapsulation is defined 'as the process of enclosing one or more items within a physical or logical package'. Encapsulation, in object oriented programming methodology, prevents access to implementation details.
What is scope of a public member variable of a C# class?
Public access specifier allows a class to expose its member variables and member functions to other functions and objects. Any public member can be accessed from outside the class.
What is scope of a protected member variable of a C# class?
Protected access specifier allows a child class to access the member variables and member functions of its base class. This way it helps in implementing inheritance.
What is scope of a Internal member variable of a C# class?
Internal access specifier allows a class to expose its member variables and member functions to other functions and objects in the current assembly. In other words, any member with internal access specifier can be accessed from any class or method defined within the application in which the member is defined.
What is scope of a Protected Internal member variable of a C# class?
The protected internal access specifier allows a class to hide its member variables and member functions from other class objects and functions, except a child class within the same application. This is also used while implementing inheritance.
What are nullable types in C#?
By using the params keyword, a method parameter can be specified which takes a variable number of arguments or even no argument.
Can you pass additional type of parameters after using params in function definition?
No! additional parameters are not permitted after the params keyword in a method declaration. Only one params keyword is allowed in a method declaration.
What is a structure in C#?
In C#, a structure is a value type data type. It helps you to make a single variable hold related data of various data types. The struct keyword is used for creating a structure. Structures are used to represent a record. To define a structure, you must use the struct statement. The struct statement defines a new data type, with more than one member for your program.
What are the differences between a class and structure
Classes and Structures have the following basic differences − .classes are reference types and structs are value types. .structures do not support inheritance. .structures cannot have default constructor.
What is a enumeration in C#?
An enumeration is a set of named integer constants. An enumerated type is declared using the enum keyword. C# enumerations are value data type. In other words, enumeration contains its own values and cannot inherit or cannot pass inheritance.
What is the default access for a class member?
Default access for the members is private.
Is multiple inheritance supported in C#?
No! C# does not support multiple inheritance.
What is polymorphism?
The word polymorphism means having many forms. In object-oriented programming paradigm, polymorphism is often expressed as 'one interface, multiple functions'.
What is early binding?
The mechanism of linking a function with an object during compile time is called early binding. It is also called static binding.
What do you mean by saying a "struct is a value type"?
A struct is a value type mean when a struct is created, the variable to which the struct is assigned holds the struct's actual data. When the struct is assigned to a new variable, it is copied. The new variable and the original variable therefore contain two separate copies of the same data. Changes made to one copy do not affect the other copy.
When do you generally use a class over a struct?
A class is used to model more complex behavior, or data that is intended to be modified after a class object is created. A struct is best suited for small data structures that contain primarily data that is not intended to be modified after the struct is created.
List the 5 different access modifiers in C#?
1. public 2. protected 3. internal 4. protected internal 5. private If you donot specify an access modifier for a method, what is the default access modifier?private
Classes and structs support inheritance. Is this statement true or false?
False, Only classes support inheritance. structs donot support inheritance.
If a class derives from another class, will the derived class automatically contain all the public, protected, and internal members of the base class?
Yes, the derived class will automatically contain all the public, protected, and internal members of the base class except its constructors and destructors.
Can you create an instance for an abstract class?
No, you cannot create an instance for an abstract class.
How do you prevent a class from being inherited by another class?
Use the sealed keyword to prevent a class from being inherited by another class.
Can a static class contain non static members?
No, a static class can contain only static members.
What is a constructor in C#?
Constructor is a class method that is executed when an object of a class is created. Constructor has the same name as the class, and usually used to initialize the data members of the new object.
In C#, What will happen if you do not explicitly provide a constructor for a class?
If you do not provide a constructor explicitly for your class, C# will create one by default that instantiates the object and sets all the member variables to their default values.
Structs are not reference types. Can structs have constructors?
Yes, even though Structs are not reference types, structs can have constructors.
Can a class have static constructor?
Yes, a class can have static constructor. Static constructors are called automatically, immediately before any static fields are accessed, and are generally used to initialize static class members. It is called automatically before the first instance is created or any static members are referenced. Static constructors are called before instance constructors
Does C# provide copy constructor?
No, C# does not provide copy constructor.
What is a Destructor?
A Destructor has the same name as the class with a tilde character and is used to destroy an instance of a class.
Can a class have more than 1 destructor?
No, a class can have only 1 destructor.
Can structs in C# have destructors?
No, structs can have constructors but not destructors, only classes can have destructors.
Can you pass parameters to destructors?
No, you cannot pass parameters to destructors. Hence, you cannot overload destructors. Destructors are invoked automatically by the garbage collector. When a class contains a destructor, an entry is created in the Finalize queue. When the destructor is called, the garbage collector is invoked to process the queue. If the destructor is empty, this just causes a needless loss of performance. Yes, it possible to force garbage collector to run by calling the Collect() method, but this is not considered a good practice because this might create a performance over head. Usually the programmer has no control over when the garbage collector runs. The garbage collector checks for objects that are no longer being used by the application. If it considers an object eligible for destruction, it calls the destructor(if there is one) and reclaims the memory used to store the object.
Usually in .NET, the CLR takes care of memory management. Is there any need for a programmer to explicitly release memory and resources? If yes, why and how?
If the application is using expensive external resource, it is recommend to explicitly release the resource before the garbage collector runs and frees the object. We can do this by implementing the Dispose method from the IDisposable interface that performs the necessary cleanup for the object. This can considerably improve the performance of the application.
When do we generally use destructors to release resources?
If the application uses unmanaged resources such as windows, files, and network connections, we use destructors to release resources.
Explain the difference between passing parameters by value and passing parameters by reference with an example?
We can pass parameters to a method by value or by reference. By default all value types are passed by value where as all reference types are passed by reference. By default, when a value type is passed to a method, a copy is passed instead of the object itself. Therefore, changes to the argument have no effect on the original copy in the calling method.An example is
What are constants in C#?
Constants in C# are immutable values which are known at compile time and do not change for the life of the program. Constants are declared using the const keyword. Constants must be initialized as they are declared. You cannot assign a value to a constant after it isdeclared.
What are Properties in C#. Explain with an example?
Properties in C# are class members that provide a flexible mechanism to read, write, or compute the values of private fields. Properties can be used as if they are public data members, but they are actually special methods called accessors. This enables data to be accessed easily and still helps promote the safety and flexibility of methods.
What is a sealed class?
A sealed class is a class that cannot be inherited from. This means, If you have a class called Customer that is marked as sealed. No other class can inherit from Customer class. For example, the below code generates a compile time error "MainClass cannot derive from sealed type Customer.
What is a sealed class?
A sealed class is a class that cannot be inherited from. This means, If you have a class called Customer that is marked as sealed. No other class can inherit from Customer class. For example, the below code generates a compile time error "MainClass cannot derive from sealed type Customer.
Does C# support multiple class inheritance?
No, C# supports single class inheritance only. However classes can implement multiple interfaces at the same time.
What are the 4 pillars of any object oriented programming language?
1. Abstraction 2. Inheritance 3. Encapsulation 4. Polymorphism
Give some examples for built in datatypes in C#?
1. int 2. float 3. bool
How do you create user defined data types in C#?
You use the struct, class, interface, and enum constructs to create your own custom types. The .NET Framework class library itself is a collection of custom types provided by Microsoft that you can use in your own applications.
What are the 2 types of data types available in C#?
1. Value Types 2. Reference Types
Give examples for reference types?
If you define a user defined data type by using the struct keyword, Is it a a value type or reference type? Value Type Class Delegate Array Interface If you define a user defined data type by using the class keyword, Is it a a value type or reference type? Reference type Are Value types sealed?Yes, Value types are sealed. What is the base class from which all value types are derived? System.ValueType Give examples for value types?Enum Struct
What are the differences between value types and reference types?
1. Value types are stored on the stack where as reference types are stored on the managed heap. 2. Value type variables directly contain their values where as reference variables holds only a reference to the location of the object that is created on the managed heap. 3. There is no heap allocation or garbage collection overhead for value-type variables. As reference types are stored on the managed heap, they have the over head of object allocation and garbage collection. 4. Value Types cannot inherit from another class or struct. Value types can only inherit from interfaces. Reference types can inherit from another class or interface.
What is Boxing and Unboxing?
Boxing - Converting a value type to reference type is called boxing. An example is shown below. int i = 101; object obj = (object)i; // Boxing
What is Boxing and Unboxing?
Boxing - Converting a value type to reference type is called boxing. An example is shown below. int i = 101; object obj = (object)i; // Boxing Unboxing - Converting a reference type to a value typpe is called unboxing. An example is shown below. obj = 101; i = (int)obj; // Unboxing Is boxing an implicit conversion?Yes, boxing happens implicitly. Is unboxing an implicit conversion? No, unboxing is an explicit conversion.
What happens during the process of boxing?
Boxing is used to store value types in the garbage-collected heap. Boxing is an implicit conversion of a value type to the type object or to any interface type implemented by this value type. Boxing a value type allocates an object instance on the heap and copies the value into the new object. Due to this boxing and unboxing can have performance impact.
What do you mean by String objects are immutable?
String objects are immutable means, they cannot be changed after they have been created. All of the String methods and C# operators that appear to modify a string actually return the results in a new string object. String objects are immutable.
What is the difference between an implicit conversion and an explicit conversion?
1. Explicit conversions require a cast operator whereas an implicit conversion is done automatically.
2. Explicit conversion can lead to data loss whereas with implicit conversions there is no data loss.
What type of data type conversion happens when the compiler encounters the following code?ChildClass CC = new ChildClass();
ParentClass PC = new ParentClass();
Implicit Conversion. For reference types, an implicit conversion always exists from a class to any one of its direct or indirect base classes or interfaces. No special syntax is necessary because a derived class always contains all the members of a base class.
Will the following code compile?
double d = 9999.11;
int i = d;
No, the above code will not compile. Double is a larger data type than an integer. An implicit conversion is not done automatically bcos there is a data loss. Hence we have to use explicit conversion as shown below.
double d = 9999.11;
int i = (int)d; //Cast double to int.
How the exception handling is done in C#?
In C# there is a “try… catch” block to handle the error.
Why to use “finally” block in C#?
Finally” block will be executed irrespective of exception. So while executing the code in try block when exception is occurred, control is returned to catch block and at last “finally” block will be executed. So closing connection to database / releasing the file handlers can be kept in “finally” block.
What is the difference between “finalize” and “finally” methods in C#?
Finalize – This method is used for garbage collection. So before destroying an object this method is called as part of clean up activity. Finally – This method is used for executing the code irrespective of exception occurred or not.
What is the difference between “throw ex” and “throw” methods in C#?
“throw ex” will replace the stack trace of the exception with stack trace info of re throw point. “throw” will preserve the original stack trace info.
Can we have only “try” block without “catch” block in C#?
Yes we can have only try block without catch block but we have to have finally block.
List out two different types of errors in C#?
Compile Time Error Run Time Error
Do we get error while executing “finally” block in C#?
Yes. We may get error in finally block.
Mention the assembly name where System namespace lies in C#?
Assembly Name – mscorlib.dll
What are the differences between static, public and void in C#?
Static classes/methods/variables are accessible throughout the application without creating instance. Compiler will store the method address as an entry point. Public methods or variables are accessible throughout the application. Void is used for the methods to indicate it will not return any value.
What is the difference between “out” and “ref” parameters in C#?
“out” parameter can be passed to a method and it need not be initialized where as “ref” parameter has to be initialized before it is used.
What are value types in C#?
decimal int byte enum double long float
What are reference types in C#?
class string interface object
Can we override private virtual method in C#?
No. We can’t override private virtual methods as it is not accessible outside the class.
Explain access modifier – “protected internal” in C#?
“protected internal” can be accessed in the same assembly and the child classes can also access these methods.
In try block if we add return statement whether finally block is executed in C#?
Yes. Finally block will still be executed in presence of return statement in try block.
What you mean by inner exception in C#?
Inner exception is a property of exception class which will give you a brief insight of the exception i.e, parent exception and child exception details.
Explain String Builder class in C#?
This will represent the mutable string of characters and this class cannot be inherited. It allows us to Insert, Remove, Append and Replace the characters. The “ToString()” method can be used for the final string obtained from StringBuilder.
For example,
StringBuilder TestBuilder = new StringBuilder("Hello");
TestBuilder.Remove(2, 3); // result - "He"
TestBuilder.Insert(2, "lp"); // result - "Help"
TestBuilder.Replace('l', 'a'); // result - "Heap"
What is the difference between “StringBuilder” and “String” in C#?
StringBuilder is mutable, which means once object for stringbuilder is created, it later be modified either using Append, Remove or Replace. String is immutable and it means we cannot modify the string object and will always create new object in memory of string type.
What is the difference between methods – “System.Array.Clone()” and “System.Array.CopyTo()” in C#?
“CopyTo()” method can be used to copy the elements of one array to other. “Clone()” method is used to create a new array to contain all the elements which are in the original array.
How we can sort the array elements in descending order in C#?
“Sort()” method is used with “Reverse()” to sort the array in descending order.
List out some of the exceptions in C#?
NullReferenceException ArgumentNullException DivideByZeroException IndexOutOfRangeException InvalidOperationException StackOverflowException etc.
What you mean by delegate in C#?
Delegates are type safe pointers unlike function pointers as in C++. Delegate is used to represent the reference of the methods of some return type and parameters.
What are the types of delegates in C#?
Single Delegate Multicast Delegate Generic Delegate
What are the three types of Generic delegates in C#?
Func Action Predicate
What are the differences between events and delegates in C#?
Main difference between event and delegate is event will provide one more of encapsulation over delegates. So when you are using events destination will listen to it but delegates are naked, which works in subscriber/destination model.
Can we use delegates for asynchronous method calls in C#?
Yes. We can use delegates for asynchronous method calls.
What are the uses of delegates in C#?
Callback Mechanism Asynchronous Processing Abstract and Encapsulate method Multicasting
What is Nullable Types in C#?
Variable types does not hold null values so to hold the null values we have to use nullable types. So nullable types can have values either null or other values as well. Eg: Int? mynullablevar = null;
Why to use “Nullable Coalescing Operator” (??) in C#?
Nullable Coalescing Operator can be used with reference types and nullable value types. So if the first operand of the expression is null then the value of second operand is assigned to the variable. For example, double? myFirstno = null; double mySecno; mySecno = myFirstno ?? 10.11;
What is the difference between “as” and “is” operators in C#?
“as” operator is used for casting object to type or class. “is” operator is used for checking the object with type and this will return a Boolean value.
What is the difference between CType and Directcast in C#?
CType is used for conversion between type and the expression. Directcast is used for converting the object type which requires run time type to be the same as specified type.
Why to use lock statement in C#?
Lock will make sure one thread will not intercept the other thread which is running the part of code. So lock statement will make the thread wait, block till the object is being released.
Explain Hashtable in C#?
It is used to store the key/value pairs based on hash code of the key. Key will be used to access the element in the collection. For example, Hashtable myHashtbl = new Hashtable(); myHashtbl.Add("1", "TestValue1"); myHashtbl.Add("2", "TestValue2");
How to check whether hash table contains specific key in C#?
Method – “ContainsKey” can be used to check the key in hash table. Below is the sample code for the same – Eg: myHashtbl.ContainsKey("1");
Which are the loop types available in C#?
For While Do.. While
What is the difference between “continue” and “break” statements in C#?
“continue” statement is used to pass the control to next iteration. This statement can be used with – “while”, “for”, “foreach” loops. “break” statement is used to exit the loop.
Explain the types of unit test cases?
Positive Test cases Negative Test cases Exception Test cases
Which string method is used for concatenation of two strings in c#?
“Concat” method of String class is used to concatenate two strings. For example, string.Concat(firstStr, secStr)
Explain Indexers in C#?
Indexers are used for allowing the classes to be indexed like arrays. Indexers will resemble the property structure but only difference is indexer’s accessors will take parameters. For example,
What are the collection types can be used in C#?
ArrayList Stack Queue SortedList HashTable Bit Array
List out the pre defined attributes in C#?
Attributes are used to convey the info for runtime about the behavior of elements like – “methods”, “classes”, “enums” etc. Attributes can be used to add metadata like – comments, classes, compiler instruction etc.
What is Thread in C#?
Thread is an execution path of a program. Thread is used to define the different or unique flow of control. If our application involves some time consuming processes then it’s better to use Multithreading., which involves multiple threads.
List out the states of a thread in C#?
Unstarted State Ready State Not Runnable State Dead State
Explain the methods and properties of Thread class in C#?
CurrentCulture CurrentThread CurrentContext IsAlive IsThreadPoolThread IsBackground Priority
What are the Access Modifiers in C# ?
Different Access Modifier are - Public, Private, Protected, Internal, Protected Internal Public – When a method or attribute is defined as Public, it can be accessed from any code in the project. For example, in the above Class “Employee” getName() and setName() are public. Private - When a method or attribute is defined as Private, It can be accessed by any code within the containing class only. For example, in the above Class “Employee” attributes name and salary can be accessed within the Class Employee Only. If an attribute or class is defined without access modifiers, it's default access modifier will be private. Protected - When attribute and methods are defined as protected, it can be accessed by any method in the inherited classes and any method within the same class. The protected access modifier cannot be applied to classes and interfaces. Methods and fields in a interface can't be declared protected. Internal – If an attribute or method is defined as Internal, access is restricted to classes within the current project assembly. Protected Internal – If an attribute or method is defined as Protected Internal, access is restricted to classes within the current project assembly and types derived from the containing class.
Define Property in C# ?
Properties are a type of class member, that are exposed to the outside world as a pair of Methods. For example, for the static field Minsalary, we will Create a property as shown below.
Explain Overloading in C# ?
When methods are created with the same name, but with different signature its called overloading. For example, WriteLine method in console class is an example of overloading. In the first instance, it takes one variable. In the second instance, “WriteLine” method takes two variable.
) What is Constructor Overloading in C# .net ?
In Constructor overloading, n number of constructors can be created for the same class. But the signatures of each constructor should vary. For example public class Employee { public Employee() { } public Employee(String Name) { } }
Explain Inheritance in C# ?
In object-oriented programming (OOP), inheritance is a way to reuse code of existing objects. In inheritance, there will be two classes - base class and derived classes. A class can inherit attributes and methods from existing class called base class or parent class. The class which inherits from a base class is called derived classes or child class. For more clarity on this topic, let us have a look at 2 classes shown below. Here Class Car is Base Class and Class Ford is derived class.
What is Polymorphism in C# ?
The ability of a programming language to process objects in different ways depending on their data type or class is known as Polymorphism. There are two types of polymorphism Compile time polymorphism. Best example is Overloading Runtime polymorphism. Best example is Overriding
What is Abstract Class in C#?
If we don't want a class to be instantiated, define the class as abstract. An abstract class can have abstract and non-abstract classes. If a method is defined as abstract, it must be implemented in a derived class. Abstract classes are declared using the abstract keyword. Objects cannot be created for abstract classes. If you want to use it then it must be inherited in a subclass. You can easily define abstract or non-abstract methods within an Abstract class. The methods inside the abstract class can either have an implementation or no implementation.
Describe the Events in the Life Cycle of a Web Application ?
A web application starts, when a browser requests a page of the application for the first time. The request will be received by the IIS which then starts ASP.NET worker process. The worker process then allocates a process space to the assembly and loads it. An Application_Start() event will fire on start of the application and it’s followed by Session_Start(). ASP.NET engine then processes the request and sends back response in the form of HTML to the user and user receives the response in the form of page.
What are the Web Form Events available in ASP.NET ?
Page_Init Page_Load Page_PreRender Page_Unload Page_Disposed Page_Error Page_AbortTransaction Page_CommitTransaction Page_DataBinding
What is the execution entry point for a C# console application?
The Main method.
Why to use “using” in C#?
“Using” statement calls – “dispose” method internally, whenever any exception occurred in any method call and in “Using” statement objects are read only and cannot be reassignable or modifiable.
.Explain namespaces in C#?
Namespaces are containers for the classes. We will use namespaces for grouping the related classes in C#. “Using” keyword can be used for using the namespace in other namespace.
What is a singleton?
A singleton is a design pattern used when only one instance of an object is created and shared; that is, it only allows one instance of itself to be created. Any attempt to create another instance simply returns a reference to the first one. Singleton classes are created by defining all class constructors as private. In addition, 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. Here is a basic example:
Explain “static” keyword in C#?
“Static” keyword can be used for declaring a static member. If the class is made static then all the members of the class are also made static. If the variable is made static then it will have a single instance and the value change is updated in this instance.
What is Version Control?
Version Control means keeping the copies of your code or files from every stage in its lifecycle. The version control system allows us to manage all versions of our code by representing a single version at a time. Sometimes we write code or make changes to the code but later, we realize it was a mistake and want to revert back to the last code, Version Control will do that for you.
What is the difference between IEnumerable and Enumerable?
IEnumerable is an interface and Enumerable is a class that is used to implement IEnumerable. The Enumerable class is part of the Linq library and contains many extension methods written for the IEnumerable interface. (like Any(), Count()
What is singleton?
1) A singleton is a class that only allows one instance of itself to be created - and gives simple, easy access to such instance. Unlike static classes, Singleton classes can be inherited, can have base class, can be serialized, and can implement interfaces. You can implement the Dispose method in your Singleton class. ... 1b) Interface is nothing but a collection of method and property declarations and has a signature, not the implementation.
What is Static class?
Static classes can only have static members are these classes cannot be inherited -- these classes are sealed implicitly. It is a type of class that cannot be instantiated, in other words, we cannot create an object of that class using the new keyword and the class members can be called directly using their class name.
What is data injection or data insertion?
Data injection (or data insertion) occurs when input fields are populated with control or command sequences embedded in various ways that are nevertheless accepted by the application, or possibly passed to the operating system, that allows privileged malicious and unauthorized programs to be run on the remote system. . eg cross-site scripting.
What is finally Block?
The finally block is an optional block and should come after a try or catch block. The finally block will always be executed whether or not an exception occurred. The finally block generally used for cleaning-up code e.g., disposing of unmanaged objects.
What is try block?
Any suspected code that may raise exceptions should be put inside a try{ } block. During the execution, if an exception occurs, the flow of the control jumps to the first matching catch block.
What is catch block?
The catch block is an exception handler block where you can perform some action such as logging and auditing an exception with display messages when there is an exceptions.
hat is CI/CD? (Continuous integration and continuous delivery explained)
The CI/CD pipeline is one of the best practices for devops teams to implement, for delivering code changes more frequently and reliably.
What is the difference between abstract class and an interface?
Both have declaration but... An abstract class allows you to create functionality that subclasses can implement or override. An interface only allows you to declare functionality, not implement it. And whereas a class can extend only one abstract class, it can take advantage of multiple interfaces.
What is lambda expressions in c#?
A lambda expression is a convenient way of defining an anonymous (unnamed) function that can be passed around as a variable or as a parameter to a method call. Many LINQ methods take a function (called a delegate) as a parameter. ... The => operator is called the "lambda operator"
What is a delegates in C#?
A delegate is a type that represents references to methods with a particular parameter list and return type. When you instantiate a delegate, you can associate its instance with any method with a compatible signature and return type
What is callback method in C#?
A "callback" is a term that refers to a coding design pattern. In this design pattern executable code is passed as an argument to other code and it is expected to call back at some time. To create a Callback in C#, function address will be passed inside a variable. So, this can be achieved by using Delegate.
What are the generics in C#?
Generics allow you to write a class or method that can work with any data type. Generics allow you to define the specification of the data type of programming elements in a class or a method, until it is actually used in the program.
Why ref is used in C#?
The ref keyword in C# is used for passing or returning references of values to or from Methods.
How do you call a method in C#?
After creating function, you need to call it in Main() method to execute. In order to call method, you need to create object of containing class, then followed bydot(.) operator you can call the method. If method is static, then there is no need to create object and you can directly call it followed by class name.
What is out keyword in C#?
The out is a keyword in C# which is used for the passing the arguments to methods as a reference type. It is generally used when a method returns multiple values. Important Points: It is similar to ref keyword. ... But before it returns a value to the calling method, the variable must be initialized in the called method
What is Access modifiers in C#
Access modifiers in C# are used to specify the scope of accessibility of a member of a class. Ex. public, private, internal etc.
What is Main() method in C#?
It is an entry point into your program. A static method can be called without instantiating an object. Therefore main() needs to be static in order to allow it to be the entry to your program.
What is Nullable type in C#?
Nullable type is new concept introduced in C#2.0 which allow user to assign null value to primitive data types of C# language. It is important to note that Nullable type is Structure type.
What is managed/unmanaged code?
Managed code is not directly compiled to machine code but to an intermediate language which is interpreted and executed by some service on a machine and is therefore operating within a secure framework which handles things like memory and threads for you. Unmanaged code is compiled directly to machine code and therefore executed by the OS directly. So, it has the ability to do damaging/powerful things Managed code does not. C# is managed code because Common language runtime can compile C# code to Intermediate language.
Managed code is not directly compiled to machine code but to an intermediate language which is interpreted and executed by some service on a machine and is therefore operating within a secure framework which handles things like memory and threads for you. Unmanaged code is compiled directly to machine code and therefore executed by the OS directly. So, it has the ability to do damaging/powerful things Managed code does not. C# is managed code because Common language runtime can compile C# code to Intermediate language. Can I override a static methods in C#?
No. You can't override a static method. A static method can't be virtual, since it's not related to an instance of the class.
Can we call a non-static method from inside a static method in C#?
Yes. You have to create an instance of that class within the static method and then call it, but you ensure there is only one instance
Explain namespaces in C#? Namespaces are containe
Namespaces are containers for the classes. Namespaces are using for grouping the related classes in C#. "Using" keyword can be used for using the namespace in other namespace.
Difference between a break statement and a continue statement?
Break statement: If a particular condition is satisfied then the break statement exits you out from a particular loop or switch case etc. Continue statement: When the continue statement is encountered in a code, all the actions up till this statement are executed again without execution of any statement after the continue statement...
Can a private virtual method be overridden?
No, because they are not accessible outside the class.
How destructors are defined in C#?
C# destructors are special methods that contains clean up code for the object. You cannot call them explicitly in your code as they are called implicitly by GC. In C# they have same name as the class name preceded by the ~ sign.
What is a structure in C#?
In C#, a structure is a value type data type. It helps you to make a single variable hold related data of various data types. The struct keyword is used for creating a structure.
What is the difference between == and quals() in C#?
The "==" compares object references and .Equals method compares object content
Can we create abstract classes without any abstract methods?
Yes, you can. There is no requirement that abstract classes must have abstract methods. An Abstract class means the definition of the class is not complete and hence cannot be instantiated.
Explain object pool in C#?
Object pool is used to track the objects which are being used in the code. So object pool reduces the object creation overhead
Difference between this and base ?
"this" represents the current class instance while "base" the parent.
What's the base class of all exception classes?
System.Exception class is the base class for all exceptions.
How the exception handling is done in C#? In
In C# there is a "try… catch" block to handle the exceptions.
Why to use "using" in C#?
The reason for the "using" statement is to ensure that the object is disposed as soon as it goes out of scope, and it doesn't require explicit code to ensure that this happens. Using calls Dispose() after the using-block is left, even if the code throws an exception. It also used to call the library resources.
What is a collection?
A collection works as a container for instances of other classes. All classes implement ICollection interface.
Can finally block be used without catch?
Yes, it is possible to have try block without catch block by using finally block. The "using" statement is equivalent try-finally.
How do you initiate a string without escaping each backslash?
You put an @ sign in front of the double-quoted string.
What does the term immutable mean?
The data value may not be changed.
What is Reflection?
Reflection allows us to get metadata and assemblies of an object at runtime.
What namespaces are necessary to create a localized application?
System.Globalization, System.Resources.
Can you return multiple values from a function in C#?
Yes, you can return multiple values from a function using the following approaches: ref / out parameters Struct / Class Tuple
What is the difference between ref and out parameters?
"ref" tells the compiler that the object is initialized before entering the function, while "out" tells the compiler that the object will be initialized inside the function.
What is the difference between "constant" and "readonly" variables in C#?
Constants Can be assigned values only at the time of declaration Static by default Known at compile time Read only Must have set value, by the time constructor exits Are evaluated when instance is created Known at run time
Mention the assembly name where System namespace lies in C#?
mscorlib.dll
What is the .NET datatype that allows the retrieval of data by a unique key?
HashTable
hich method do you use to enforce garbage collection in .NET?
System.GC.Collect() forces garbage collector to run. This is not recommended but can be used if situations arise.
How can I stop my code being reverse-engineered from IL?
Obfuscate your code. Dotfuscator has a free edition and comes with Visual Studio. These tools work by "optimising" the IL in such a way that reverse-engineering becomes much more difficult. Also host your service in any cloud service provider that will protect your IL from reverse-engineering.
How do you convert a string into an integer in .NET?
Int32.Parse(string) Convert.ToIn32
What is a formatter?
A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and decoding messages into data on the other end.
How many classes can a single .NET DLL contain?
One DLL can contains Unlimited classes.
What is manifest?
It is the metadata that describes the assemblies
Difference between int and int32 ?
Both are same. System.Int32 is a .NET class. Int is an alias name for System.Int32.
What is code access security (CAS)?
Code Access Security (CAS) is the security sandbox for .NET. Local apps typically have full trust which means they can do anything. The .NET apps that are hosted in the browser can't do much. In between, just about any security setting can be fine-tuned using CAS.
What is the smallest unit of execution in .NET?
An assembly is the smallest unit of execution in .Net
What does the keyword "virtual" declare for a method or property?
The virtual keyword is used to modify a method, property, indexer or event declaration, and allow it to be overridden in a derived class. By default a method cannot be overridden in a derived class unless it is declared virtual, or abstract.
How do you prevent a class from being inherited?
In C# you use the "sealed" keyword in order to prevent a class from being inherited. In VB.NET you use the "NotInheritable" keyword.
What is the difference between bool and Boolean types in C#?
Both are same, bool is an alias for System.Boolean. You can assign a Boolean value to a bool variable.
What is the difference between bool and Boolean types in C#?
Both are same, bool is an alias for System.Boolean. You can assign a Boolean value to a bool variable.
Array is reference type or value type ?
Array in .net is of reference type. All array types are implicitly derived from System.Array, which itself is derived from System.Object. This means that all arrays are always reference types
Can finally bock have return statement?
You can't return from finally block. You will get compiler error: "Control cannot leave the body of a finally clause"
Does C# have a throws clause?
No, because there are no checked exceptions in C#.
What is the difference between Interface and a class?
A Class has both definition and an implementation whereas Interface only has a definition. A Class can be instantiated but an Interface cannot be instantiated You can create an instance of an Object that implements the Interface. A Class is a full body entity with members, methods along with there definition and implementation. An Interface is just a set of definition that you must implement in your Class inheriting that Interface.
Difference between a Value Type and a Reference Type?
A Value Type stores its contents in memory allocated on the stack. When you created a Value Type, a single space in memory is allocated to store the value and that variable directly holds a value. If you assign it to another variable, the value is copied directly and both variables work independently. Predefined datatypes, structures, enums are also value types, and work in the same way. Value types can be created at compile time and Stored in stack memory, because of this, Garbage collector can't access the stack. Reference Type: Reference Types are used by a reference which holds a reference (address) to the object but not the object itself. Because reference types represent the address of the variable rather than the data itself, assigning a reference variable to another doesn't copy the data. Instead it creates a second copy of the reference, which refers to the same location of the heap as the original value. Reference Type variables are stored in a different area of memory called the heap. This means that when a reference type variable is no longer used, it can be marked for garbage collection. Examples of reference types are Classes, Objects, Arrays, Indexers, Interfaces etc.
What is Stack and Heap?
Stack is used for static memory allocation and Heap for dynamic memory allocation, both stored in the computer's RAM
Difference between Exception and Error?
Difference between Exception and Error Exception and Error Exceptions are those which can be handled at the run time whereas errors cannot be handled. An exception is an Object of a type deriving from the System.Exception class. SystemException is thrown by the CLR (Common Language Runtime) when errors occur that are nonfatal and recoverable by user programs. It is meant to give you an opportunity to do something with throw statement to transfer control to a catch clause in a try block.
What is .Net Delegates?
In the .NET environment, a delegate is a type that defines a method signature and it can pass a function as a parameter. In simple words we can say delegate is a .NET object which points to a method that matches its specific signature. A delegate is a form of type-safe function pointer used by the Common Language Infrastructure.
Difference between a Debug and Release build?
debug-release Debug mode and Release mode are different configurations for building your .Net project. Programmers generally use the Debug mode for debugging step by step their .Net project and select the Release mode for the final build of Assembly file (.dll or .exe).
Difference between Clone and Copy?
Clone will copy the structure of a data where as Copy will copy the complete structure as well as data.
What is Access modifiers in C#
Access Modifiers (Access Specifiers) describes as the scope of accessibility of an Object and its members. We can control the scope of the member object of a class using access specifiers. The following five accessibility levels can be specified using the access modifiers: public, private , protected , internal and protected internal
What is partial class ?
Partial classes allow for a single Class file to be split up across multiple physical files, and all parts are combined when the application is compiled.
Early Binding and Late binding?
The compiler performs a process called binding when an object is assigned to an object variable. The early binding (static binding) refers to compile time binding and late binding (dynamic binding) refers to runtime binding.
What is Delegates in C#?
Delegates pass a function as a parameter, handles the callback functions or event handler and also defines the method signature. There are three steps involved while working with delegates: Declare a delegate, Set a target method, Invoke a delegate,
What is yield in C#?
The yield keyword performs custom and stateful iteration and returns each element of a collection one at a time sans the need of creating temporary collections. The yield keyword, first introduced in C# 2.0, T returns an object that implements the IEnumerable interface.
What is lambda expressions in c#?
A lambda expression is a short block of code which takes in parameters and returns a value. Lambda expressions are similar to methods, but they do not need a name and they can be implemented right in the body of a method.
1. What is a generic method and when should it be used?
Generics are commonly used to create type-safe collections for both reference and value types. ex. structures, interfaces, When a generic class is instantiated without specifying an actual type argument, the generic class is being used. as a raw type. Only $2.99/month. When a generic method is called, the compiler determines the actual types to use for the type parameters from the context.
2. Can you explain the factory pattern?
Factory method is a creational design pattern which solves the problem of creating product objects without specifying their concrete classes. Factory Method defines a method, which should be used for creating objects instead of direct constructor call ( new operator).
3. What is a lambda expression? How when do you use it?
Lambda expression is an anonymous function that provides a very concise and functional syntax which is further used for writing anonymous methods. The programming of a function is a body concept, and it's used for creating expression tree types or delegates.
How do you make a code block thread safe?
There are basically four ways to make variable access safe in shared-memory concurrency: 1. Confinement. Don't share the variable between threads. ... 2. Immutability. Make the shared data immutable. ... 3. Threadsafe data type. ... 4. Synchronization.
What is the async/await pattern in C#?
The async keyword turns a method into an async method, which allows you to use the await keyword in its body. When the await keyword is applied, it suspends the calling method and yields control back to its caller until the awaited task is complete. await can only be used inside an async method.
What is polymorphism?
The word polymorphism means having many forms. ... Real-life example of polymorphism: A person at the same time can have different characteristics. Like a man at the same time is a father, a husband, an employee. So the same person posses different behavior in different situations. This is called polymorphism
What is Abstraction?
Abstraction is a mechanism to hide irrelevant details and represent only the essential features so that one can focus on important things at a time; It allows managing complex systems by concentrating on the essential features only. For example, while driving a car, a driver only knows the essential features to drive a car such as how to use the clutch, brake, accelerator, gears, steering, etc., and least bothers about the internal details of the car like motor, engine, wiring, etc.
What is constructor?
Constructor is a block of codes similar to the method. It is called when an instance of the object is created, and memory is allocated for the object. It is a special type of method which is used to initialize the object.
When is a constructor called?
When an object is created, the compiler makes sure that constructors for all of its subobjects (its member and inherited objects) are called. If members have default constructors or constructors without parameters then these constructors are called automatically, otherwise, parameterized constructors can be called using an initializer list. Note: It is called a constructor because it constructs the values at the time of object creation. It is not necessary to write a constructor for a class. It is because the compiler creates a default constructor if your class doesn't have any.
What is the Rule to remember while creating a constructor?
There are three rules defined for the constructor. Constructor name must be the same as its class name A Constructor must have no explicit return type A constructor cannot be abstract, static, final, and synchronized
Types of constructors?
Default Constructor Parameterized Constructor
What is default constructor ?
The default constructor is a no-args constructor that the compiler inserts on your behalf; it contains a default call to super(); which is the default behavior. If you implement any constructor then you no longer receive a default constructor. Note: If there is no constructor in the class, the compiler adds a default constructor
What is parameterized constructor?
Parameterized Constructor A constructor which has a specific number of parameters is called a parameterized constructor. The parameterized constructor is used to provide different values to distinct objects. However, you can provide the same values also. class Student4{ int id; String name; Student4(int i,String n){ id = i; name = n; } void display(){System.out.println(id+" "+name);} public static void main(String args[]){ Student4 s1 = new Student4(111,"Karan"); Student4 s2 = new Student4(222,"Aryan"); s1.display(); s2.display(); } }
What is Constructor Overloading?
Constructor Overloading is a technique to create multiple constructors with a different set of parameters and a different number of parameters. It allows us to use a class in a different manner. The same class may behave in different types based on constructors overloading.
What is Constructor Overloading?
In Java, a constructor is just like a method but without return type. It can also be overloaded like Java methods. Constructor overloading in Java is a technique of having more than one constructor with different parameter lists. They are arranged in a way that each constructor performs a different task. They are differentiated by the compiler by the number of parameters in the list and their types. class Student5{ int id; String name; int age; //creating two argument constructor Student5(int i,String n){ id = i; name = n; } //creating three argument constructor Student5(int i,String n,int a){ id = i; name = n; age=a; } void display(){System.out.println(id+" "+name+" "+age);} public static void main(String args[]){ Student5 s1 = new Student5(111,"Karan"); Student5 s2 = new Student5(222,"Aryan",25); s1.display(); s2.display(); }
Difference between Constructor vs Method
Constructor : A constructor is used to initialize the state of an object. A constructor must not have a return type. The constructor is invoked implicitly. The Java compiler provides a default constructor if you don't have any constructor in a class. The constructor name must be the same as the class name. Method : ............................................................................................................................................................ A method is used to expose the behavior of an object. A method must have a return type. The method is invoked explicitly. The method is not provided by the compiler in any case.
What is Object?
Any entity that has a state and behavior is known as an object. For example a chair, pen, table, keyboard, bike, etc. It can be physical or logical. An Object can be defined as an instance of a class. An object contains an address and takes up some space in memory. Objects can communicate without knowing the details of each other's data or code. The only necessary thing is the type of message accepted and the type of response returned by the objects. Example: A dog is an object because it has states like color, name, breed, etc. as well as behaviors like wagging the tail, barking, eating, etc.
what is a Class?
A class can be used to create objects and to define object data types and methods. Core properties include the data types and methods that may be used by the object A class can also be defined as a blueprint from which you can create an individual object. Class doesn't consume any space.
Advantages of OOPs over Procedure Oriented Programming
Advantages of OOPs over Procedure Oriented Programming OOPs makes development and maintenance easier whereas in a procedure-oriented programming language it is not easy to manage if code grows as project size increases. OOPs provides data hiding whereas in a procedure-oriented programming language a global data can be accessed from anywhere. public class Dog { String breed; int age; String color; void barking() { } void hungry() { } void sleeping() { } } A class is a blueprint from which individual objects are created. The code above is a sample of a class Dog with attributes and behavior.
What is JavaScript?
JavaScript? JavaScript is the Programming Language for the Web JavaScript can update and change both HTML and CSS JavaScript can calculate, manipulate and validate data Syntax : var x, y; // How to declare variables x = 5; y = 6; // How to assign values z = x + y; // How to compute values Strings are text, written within double or single quotes: "John Doe" 'John Doe'
What is using In C# means
the using keyword is used to include the System namespace in the program. A program generally has multiple using statements.
What is namespace in C#?
A namespace is a collection of classes. Example: The HelloWorldApplication namespace contains the class HelloWorld.
Let us break each line and understand the significance :
The first line of the program using System; - the using keyword is used to include the System namespace in the program. A program generally has multiple using statements. The next line has the namespace declaration. A namespace is a collection of classes. The HelloWorldApplication namespace contains the class HelloWorld. The next line has a class declaration, the class HelloWorld contains the data and method definitions that your program uses. Classes generally contain multiple methods. Methods define the behavior of the class. However, the HelloWorld class has only one method Main. The next line defines the Main method, which is the entry point for all C# programs. The Main method states what the class does when executed. The next line /*...*/ is ignored by the compiler and it is put to add comments in the program. The Main method specifies its behavior with the statement Console.WriteLine("Hello World"); WriteLine is a method of the Console class defined in the System namespace. This statement causes the message "Hello, World!" to be displayed on the screen. The last line Console.ReadKey(); is for the VS.NET Users. This makes the program wait for a key press and it prevents the screen from running and closing quickly when the program is launched from Visual Studio .NET.
Points to Remember
C# is case sensitive. All statements and expression must end with a semicolon (;). The program execution starts at the Main method. Unlike Java, program file name could be different from the class name.
Waht is Loops?
A loop statement allows us to execute a statement or a group of statements multiple times and the following is the general form of a loop statement in most the programming languages C# provides the following types of loop to handle looping requirements : While Loop For Loop Do...While Loop
What is While Loop?
While Loop A while loop statement in C# repeatedly executes a target statement as long as a given condition is true.
While Loop
A while loop statement in C# repeatedly executes a target statement as long as a given condition is true. Example using System; namespace Loops { class Program { static void Main(string[] args) { /* local variable definition */ int a = 10; /* while loop execution */ while (a < 20) { Console.WriteLine("value of a: {0}", a); a++; } Console.ReadLine(); } } }
What is For Loop?
A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times. Example using System; namespace Loops { class Program { static void Main(string[] args) { /* for loop execution */ for (int a = 10; a < 20; a = a + 1) { Console.WriteLine("value of a: {0}", a); } Console.ReadLine(); } } }
Difference between Virtual Function and Abstract Method
An abstract function cannot have functionality. Any child class MUST give their own version of this method, however, it's too general to even try to implement in the parent class. A virtual function has the functionality that may or may not be good enough for the child class. So if it is good enough, use this method, if not, then override it, and provide your own functionality.
What are The Phases of SDLC?
.Investigation .System Analysis .Design Testing .Operations and Maintenance
What are SDLC STAGES?
Investigation The 1st stage of SDLC is the investigation phase. During this stage, business opportunities and problems are identified, and information technology solutions are discussed. Multiple alternative projects may be suggested and their feasibility analyzed. Operational feasibility is assessed, and it is determined whether or not the project fits with the current business environment, and to what degree it addresses business objects. In addition, an economic feasibility investigation is conducted to judge the costs and benefits of the project. Technical feasibility must also be analyzed to determine if the available hardware and software resources are sufficient to meet expected specifications The results of the feasibility study can then be compiled into a report, along with preliminary specifications. When the investigation stage ends, a decision whether or not to move forward with the project should be made. System Analysis The goal of system analysis is to determine where the problem is in an attempt to fix the system.This step involves breaking down the system in different pieces to analyze the situation, analyzing project goals, breaking down what needs to be created and attempting to engage users so that definite requirements can be defined. Design In systems design the design functions and operations are described in detail, including screen layouts, business rules, process diagrams and other documentation. The output of this stage will describe the new system as a collection of modules or subsystems. The design stage takes as its initial input the requirements identified in the approved requirements document. For each requirement, a set of one or more design elements will be produced as a result of interviews, workshops, and/or prototype efforts. Design elements describe the desired software features in detail, and generally include functional hierarchy diagrams, screen layout diagrams, tables of business rules, business process diagrams, pseudo-code, and a complete entity-relationship diagram with a full data dictionary. These design elements are intended to describe the software in sufficient detail that skilled programmers may develop the software with minimal additional input design. Testing The code is tested at various levels in software testing. Unit, system and user acceptance testings are often performed. Some testing methods : Defect testing the failed scenarios, including defect tracking Path testing Data set testing Unit testing System testing Integration testing Black-box testing White-box testing Regression testing Automation testing User acceptance testing Software performance testing Operations and Maintenance The deployment of the system includes changes and enhancements before the decommissioning or sunset of the
SDLC STAGES
Investigation The 1st stage of SDLC is the investigation phase. During this stage, business opportunities and problems are identified, and information technology solutions are discussed. Multiple alternative projects may be suggested and their feasibility analyzed. Operational feasibility is assessed, and it is determined whether or not the project fits with the current business environment, and to what degree it addresses business objects. In addition, an economic feasibility investigation is conducted to judge the costs and benefits of the project. Technical feasibility must also be analyzed to determine if the available hardware and software resources are sufficient to meet expected specifications The results of the feasibility study can then be compiled into a report, along with preliminary specifications. When the investigation stage ends, a decision whether or not to move forward with the project should be made. ............................................................................................................................................................................................... System Analysis The goal of system analysis is to determine where the problem is in an attempt to fix the system.This step involves breaking down the system in different pieces to analyze the situation, analyzing project goals, breaking down what needs to be created and attempting to engage users so that definite requirements can be defined. ......................................................................................................................................................................................... Design In systems design the design functions and operations are described in detail, including screen layouts, business rules, process diagrams and other documentation. The output of this stage will describe the new system as a collection of modules or subsystems. The design stage takes as its initial input the requirements identified in the approved requirements document. For each requirement, a set of one or more design elements will be produced as a result of interviews, workshops, and/or prototype efforts. Design elements describe the desired software features in detail, and generally include functional hierarchy diagrams, screen layout diagrams, tables of business rules, business process diagrams, pseudo-code, and a complete entity-relationship diagram with a full data dictionary. These design elements are intended to describe the software in sufficient detail that skilled programmers may develop the software with minimal additional input design. .................................................................................................................................................................................. Testing The code is tested at various levels in software testing. Unit, system and user acceptance testings are often performed. Operations and Maintenanc .......
SDLC STAGES
Investigation The 1st stage of SDLC is the investigation phase. During this stage, business opportunities and problems are identified, and information technology solutions are discussed. Multiple alternative projects may be suggested and their feasibility analyzed. Operational feasibility is assessed, and it is determined whether or not the project fits with the current business environment, and to what degree it addresses business objects. In addition, an economic feasibility investigation is conducted to judge the costs and benefits of the project. Technical feasibility must also be analyzed to determine if the available hardware and software resources are sufficient to meet expected specifications The results of the feasibility study can then be compiled into a report, along with preliminary specifications. When the investigation stage ends, a decision whether or not to move forward with the project should be made. ............................................................................................................................................................................................... System Analysis The goal of system analysis is to determine where the problem is in an attempt to fix the system.This step involves breaking down the system in different pieces to analyze the situation, analyzing project goals, breaking down what needs to be created and attempting to engage users so that definite requirements can be defined. ...................................................................................................................................................................................................... Design In systems design the design functions and operations are described in detail, including screen layouts, business rules, process diagrams and other documentation. The output of this stage will describe the new system as a collection of modules or subsystems. The design stage takes as its initial input the requirements identified in the approved requirements document. For each requirement, a set of one or more design elements will be produced as a result of interviews, workshops, and/or prototype efforts. Design elements describe the desired software features in detail, and generally include functional hierarchy diagrams, screen layout diagrams, tables of business rules, business process diagrams, pseudo-code, and a complete entity-relationship diagram with a full data dictionary. These design elements are intended to describe the software in sufficient detail that skilled programmers may develop the software with minimal additional input design. .............................................................................................................................................................................................. Testing The code is tested at various levels in software testing. Unit, system and user acceptance testings are often performed. Operations and Maintenanc .......
SDLC STAGES
Investigation The 1st stage of SDLC is the investigation phase. During this stage, business opportunities and problems are identified, and information technology solutions are discussed. Multiple alternative projects may be suggested and their feasibility analyzed. Operational feasibility is assessed, and it is determined whether or not the project fits with the current business environment, and to what degree it addresses business objects. In addition, an economic feasibility investigation is conducted to judge the costs and benefits of the project. Technical feasibility must also be analyzed to determine if the available hardware and software resources are sufficient to meet expected specifications The results of the feasibility study can then be compiled into a report, along with preliminary specifications. When the investigation stage ends, a decision whether or not to move forward with the project should be made. ............................................................................................................................................................................................... System Analysis The goal of system analysis is to determine where the problem is in an attempt to fix the system.This step involves breaking down the system in different pieces to analyze the situation, analyzing project goals, breaking down what needs to be created and attempting to engage users so that definite requirements can be defined. ...................................................................................................................................................................................................... Design In systems design the design functions and operations are described in detail, including screen layouts, business rules, process diagrams and other documentation. The output of this stage will describe the new system as a collection of modules or subsystems. The design stage takes as its initial input the requirements identified in the approved requirements document. For each requirement, a set of one or more design elements will be produced as a result of interviews, workshops, and/or prototype efforts. Design elements describe the desired software features in detail, and generally include functional hierarchy diagrams, screen layout diagrams, tables of business rules, business process diagrams, pseudo-code, and a complete entity-relationship diagram with a full data dictionary. These design elements are intended to describe the software in sufficient detail that skilled programmers may develop the software with minimal additional input design. .................................................................................................................................................................................. Testing The code is tested at various levels in software testing. Unit, system and user acceptance testings are often performed. Operations and Maintenanc .......
SDLC STAGES
Investigation The 1st stage of SDLC is the investigation phase. During this stage, business opportunities and problems are identified, and information technology solutions are discussed. Multiple alternative projects may be suggested and their feasibility analyzed. Operational feasibility is assessed, and it is determined whether or not the project fits with the current business environment, and to what degree it addresses business objects. In addition, an economic feasibility investigation is conducted to judge the costs and benefits of the project. Technical feasibility must also be analyzed to determine if the available hardware and software resources are sufficient to meet expected specifications The results of the feasibility study can then be compiled into a report, along with preliminary specifications. When the investigation stage ends, a decision whether or not to move forward with the project should be made. ............................................................................................................................................................................................... System Analysis The goal of system analysis is to determine where the problem is in an attempt to fix the system.This step involves breaking down the system in different pieces to analyze the situation, analyzing project goals, breaking down what needs to be created and attempting to engage users so that definite requirements can be defined. ......................................................................................................................................................................................... Design In systems design the design functions and operations are described in detail, including screen layouts, business rules, process diagrams and other documentation. The output of this stage will describe the new system as a collection of modules or subsystems. The design stage takes as its initial input the requirements identified in the approved requirements document. For each requirement, a set of one or more design elements will be produced as a result of interviews, workshops, and/or prototype efforts. Design elements describe the desired software features in detail, and generally include functional hierarchy diagrams, screen layout diagrams, tables of business rules, business process diagrams, pseudo-code, and a complete entity-relationship diagram with a full data dictionary. These design elements are intended to describe the software in sufficient detail that skilled programmers may develop the software with minimal additional input design. .................................................................................................................................................................................. Testing The code is tested at various levels in software testing. Unit, system and user acceptance testings are often performed. Operations and Maintenanc .......
SDLC STAGES
Investigation The 1st stage of SDLC is the investigation phase. During this stage, business opportunities and problems are identified, and information technology solutions are discussed. Multiple alternative projects may be suggested and their feasibility analyzed. Operational feasibility is assessed, and it is determined whether or not the project fits with the current business environment, and to what degree it addresses business objects. In addition, an economic feasibility investigation is conducted to judge the costs and benefits of the project. Technical feasibility must also be analyzed to determine if the available hardware and software resources are sufficient to meet expected specifications The results of the feasibility study can then be compiled into a report, along with preliminary specifications. When the investigation stage ends, a decision whether or not to move forward with the project should be made. ............................................................................................................................................................................................... System Analysis The goal of system analysis is to determine where the problem is in an attempt to fix the system.This step involves breaking down the system in different pieces to analyze the situation, analyzing project goals, breaking down what needs to be created and attempting to engage users so that definite requirements can be defined. ...................................................................................................................................................................................................... Design In systems design the design functions and operations are described in detail, including screen layouts, business rules, process diagrams and other documentation. The output of this stage will describe the new system as a collection of modules or subsystems. The design stage takes as its initial input the requirements identified in the approved requirements document. For each requirement, a set of one or more design elements will be produced as a result of interviews, workshops, and/or prototype efforts. Design elements describe the desired software features in detail, and generally include functional hierarchy diagrams, screen layout diagrams, tables of business rules, business process diagrams, pseudo-code, and a complete entity-relationship diagram with a full data dictionary. These design elements are intended to describe the software in sufficient detail that skilled programmers may develop the software with minimal additional input design. .............................................................................................................................................................................................. Testing The code is tested at various levels in software testing. Unit, system and user acceptance testings are often performed. Operations and Maintenanc .......
SDLC STAGES
Investigation The 1st stage of SDLC is the investigation phase. During this stage, business opportunities and problems are identified, and information technology solutions are discussed. Multiple alternative projects may be suggested and their feasibility analyzed. Operational feasibility is assessed, and it is determined whether or not the project fits with the current business environment, and to what degree it addresses business objects. In addition, an economic feasibility investigation is conducted to judge the costs and benefits of the project. Technical feasibility must also be analyzed to determine if the available hardware and software resources are sufficient to meet expected specifications The results of the feasibility study can then be compiled into a report, along with preliminary specifications. When the investigation stage ends, a decision whether or not to move forward with the project should be made. ............................................................................................................................................................................................... System Analysis The goal of system analysis is to determine where the problem is in an attempt to fix the system.This step involves breaking down the system in different pieces to analyze the situation, analyzing project goals, breaking down what needs to be created and attempting to engage users so that definite requirements can be defined. ......................................................................................................................................................................................... Design In systems design the design functions and operations are described in detail, including screen layouts, business rules, process diagrams and other documentation. The output of this stage will describe the new system as a collection of modules or subsystems. The design stage takes as its initial input the requirements identified in the approved requirements document. For each requirement, a set of one or more design elements will be produced as a result of interviews, workshops, and/or prototype efforts. Design elements describe the desired software features in detail, and generally include functional hierarchy diagrams, screen layout diagrams, tables of business rules, business process diagrams, pseudo-code, and a complete entity-relationship diagram with a full data dictionary. These design elements are intended to describe the software in sufficient detail that skilled programmers may develop the software with minimal additional input design. .................................................................................................................................................................................. Testing The code is tested at various levels in software testing. Unit, system and user acceptance testings are often performed. Operations and Maintenanc .......
SDLC STAGES
Investigation The 1st stage of SDLC is the investigation phase. During this stage, business opportunities and problems are identified, and information technology solutions are discussed. Multiple alternative projects may be suggested and their feasibility analyzed. Operational feasibility is assessed, and it is determined whether or not the project fits with the current business environment, and to what degree it addresses business objects. In addition, an economic feasibility investigation is conducted to judge the costs and benefits of the project. Technical feasibility must also be analyzed to determine if the available hardware and software resources are sufficient to meet expected specifications The results of the feasibility study can then be compiled into a report, along with preliminary specifications. When the investigation stage ends, a decision whether or not to move forward with the project should be made. ............................................................................................................................................................................................... System Analysis The goal of system analysis is to determine where the problem is in an attempt to fix the system.This step involves breaking down the system in different pieces to analyze the situation, analyzing project goals, breaking down what needs to be created and attempting to engage users so that definite requirements can be defined. ...................................................................................................................................................................................................... Design In systems design the design functions and operations are described in detail, including screen layouts, business rules, process diagrams and other documentation. The output of this stage will describe the new system as a collection of modules or subsystems. The design stage takes as its initial input the requirements identified in the approved requirements document. For each requirement, a set of one or more design elements will be produced as a result of interviews, workshops, and/or prototype efforts. Design elements describe the desired software features in detail, and generally include functional hierarchy diagrams, screen layout diagrams, tables of business rules, business process diagrams, pseudo-code, and a complete entity-relationship diagram with a full data dictionary. These design elements are intended to describe the software in sufficient detail that skilled programmers may develop the software with minimal additional input design. .............................................................................................................................................................................................. Testing The code is tested at various levels in software testing. Unit, system and user acceptance testings are often performed. Operations and Maintenanc .......
What is use of tuple in C#?
A tuple is a generic static class that was added to C# 4.0 and it can hold any amount of elements, and they can be any type we want. So using a tuple, we can return multiple values. ... A tuple allows you to combine multiple values of possibly different types into a single object without having to create a custom class.
Explain how code gets compiled in C#?
It takes 4 steps to get a code to get compiled in C#. Below are the steps:
First, compile the source code in the managed code compatible with the C# compiler.
Second, combine the above newly created code into assemblies.
Third, load the CLR.
Last, execute the assembly by CLR to generate the output.
Describe the C# dispose of the method in detail.?
Dispose of the method: The disposeof() method releases the unused resources by an object of the class. The unused resources like files, data connections, etc. This method is declared in the interface called IDisposable which is implemented by the class by defining the interface IDisposable body. Dispose method is not called automatically, the programmer has to implement it manually for the efficient usage of the resources.
Definition of OOPS?
Object-oriented programming is an approach that modularizes programs by creating a partitioned memory area for both functions and data that can be used as templates for creating copies of such modules on demand. Features of OOPS Some features of object-oriented programming in java are: Emphasis is on data than procedures Programs are divided into objects Data Structures are designed to characterize objects. Methods operating on the data of an object are tied together in the data structure. Data is hidden, and external functions cannot access it. Objects communicate with each other through methods New methods and data can be easily added whenever necessary Follows the bottom-up approach in program design
What are theTypes of Inheritance in OOP?
Single , Multiple ,Multilevel , Hybrid inheritance
what is cors in web api?
Cross-origin resource sharing (CORS) is a browser security feature that restricts cross-origin HTTP requests that are initiated from scripts running in the browser. If your REST API's resources receive non-simple cross-origin HTTP requests, you need to enable CORS support.
What is solid Design Principle?
In Object-Oriented Programming (OOP), SOLID is one of the most popular sets of design principles that help developers write readable, reusable, maintainable, and scalable code. It's a mnemonic acronym for five design principles listed below:
1. Single Responsibility Principle (SRS)
2. Open/Closed Principle (OCP)
3. Liskov Substitution Principle (LSP)
4. Interface Segregation Principle (ISP)
5. Dependency Inversion Principle (DIP)
What’s three-layer architecture?
To simplify the coding process, we choose 3-layer architecture to implement this project. Our application includes three layers: API, Application, Entity, and Infrastructure (a.k.a. Data Access Layer).
What is Open/Closed Principle?
Open/Closed Principle “Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.” Modules that follow the Open/Closed Principle include two key attributes. "Open for extension." It means that the module’s behavior can be extended. When the requirements of the application change, you can extend the module with new behaviors that adapt to those changes. "Closed for modification." The source code of such a module is inviolate when you extend the module's behavior. You shouldn't refactor and modify the existing code for the module until bugs are detected. The reason is the source code has already passed the unit testing, so changing it can affect other existing functionalities.
What is State Management Techniques?
State-Management is a technique or Design Pattern, that can be used to synchronize the state of the application throughout all components of the application
State Management is based on client-side and server-side. Their functionality differs depending on the change in state, so here is the hierarchy:
Client-side Techniques: View, Hidden, Cookies, Control State, Query Strings
Server-side Techniques: Session State, Application State
Benefits of State-Management:
State-Management helps to centralize and made the maintenance of code very easy, also it improves the quality of code, by reducing the code size and making it more readable as well.
How many readers can simultaneously read data with ReaderWriterLock if there is no writer lock apply?
Options - 9 - 11 - 13 - No Limit CORRECT ANSWER: No Limit
Which of the following are value types?
Options - String - System .Value - System.Drawing - System.Drawing.Point CORRECT ANSWER : System.Drawing.Point
Which of the following are reference types?
Options - String - Exception - Class - All of the above CORRECT ANSWER: All of the above
Why should you write the cleanup code in Finally block?
Options - Compiler throws an error if you close the connection in try block. - Resource cannot be destroyed in catch block. - Finally blocks run whether or not exception occurs. - All of the above CORRECT ANSWER : Finally blocks run whether or not exception occurs.
1. Which of the following is dictionary object?
Options - HashTable - SortedList - NameValueCollection - All of the above CORRECT ANSWER : All of the above
You need to initialize some variable only when the first user accesses the application. What should you do?
Options - Add code to the Application_OnStart event handler in the Global.asax file. - Add code to the Application_BeginRequest event handler in the Global.asax - Add code to the Session_OnStart event handler in the Global.asax file - None CORRECT ANSWER : Add code to the Application_OnStart event handler in the Global.asax file.
You want to configure the application to use the following authorization rules in web.config file: -Anonymous users must not be allowed to access the application. -All employees except ABC must be allowed to access the application.
Options - < authorization> < deny users=”ABC”> < allow users=”*”> < deny users=”?”> < /authorization> - < authorization> < allow users=”*”> < deny users=”ABC”> < deny users=”?”> < /authorization> - < authorization> < allow users=”ABC”> < allow users=”*”> < /authorization> - < authorization> < deny users=”ABC”> < deny users=”?”> < allow users=”*”> < /authorization> CORRECT ANSWER : < authorization> < deny users=”ABC”> < deny users=”?”> < allow users=”*”> < /authorization>
What are the element of code access security?
Options - Evidence,Permission - SQLSecurity - UserInterface - SQL Injection CORRECT ANSWER : Evidence,Permission
What is Caspol?
Options - Command line tool - Code access security policy tool - Case Tool - a,b CORRECT ANSWER : a,b
An assembly must have an permission to connect with web server is ?
Options - socketPermission - DnsPermission - WebPermission - TCPPermission CORRECT ANSWER : WebPermission
Thread class has the following property. 1)ManagedThreadID,2 IsBackground 3) IsBackgroundColor,4)Abort
Options - 1,2 - 1,4 - 4 - 1,2,4 CORRECT ANSWER : 1,2
Which delegate is required to start a thread with one parameter?
Options - ThreadStart - ParameterizedThreadStart - ThreadStartWithOneParameter - None CORRECT ANSWER : ThreadStart
For locking the data with synchronization which class will be used?
Options - Lock - Moniter - SyncLock - Deadlock CORRECT ANSWER : Moniter
Which of the following are reference types?
Options - String - Exception - Class - All of the above CORRECT ANSWER : All of the above
Why should you write the cleanup code in Finally block?
Options - Compiler throws an error if you close the connection in try block. - Resource cannot be destroyed in catch block. - Finally blocks run whether or not exception occurs. - All of the above CORRECT ANSWER : Finally blocks run whether or not exception occurs.
How do we ensure encrypted communication over the internet in ASP.NET?
Options - Using windows authentication - By installing a server certificate and using HTTPS CORRECT ANSWER : By installing a server certificate and using HTTPS
Which element is used to allow or deny access to users under windows authentication?
Options - authorization - credentials - forms - users CORRECT ANSWER : authorization
Which element of form authentication settings allows storing your user list in the web.config file?
Options - Users - Credentials - Forms - Authentication CORRECT ANSWER : Credentials
Which element is used to allow or deny access to users under windows authentication?
Options - authorization - credentials - forms - users CORRECT ANSWER : authorization
The uniqueId that gets generated at the start of the Session is stored in?
Options - Client computer as a cookie - Server machine - Passed to and fro on each and every request and response - Both a and b are correct CORRECT ANSWER : Server machine
1. What is the output of the code?
What is the output of the code public class B : A { } Options - Errors - It defines a class that inherits the public methods of A only. - It defines a class that inherits all the methods of A but the private members cannot be accessed. - b and c CORRECT ANSWER : It defines a class that inherits all the methods of A but the private members cannot be accessed.
What is the .NET collection class that allows an element to be accessed using a unique key?
Options - HashTable - ArrayList - SortedList CORRECT ANSWER : HashTable
What is accessibility modifier "protected internal"?
Options - It is available to classes that are within the same assembly or derived from the specified base class. - It is available within the class definition - It is the most permissive access level - It is the least permissive access level CORRECT ANSWER : It is available to classes that are within the same assembly or derived from the specified base class.
If you want to add an array in ArrayList then which method of ArrayList will be used?
Options - AddRange - Add - AddArray - None of the above CORRECT ANSWER : AddRange
Different ways a method can be overloaded in C#.NET
Options - Different parameter data types - Different number of parameters - Different order of parameters - a and b CORRECT ANSWER : a and b
Can you inherit multiple interfaces?
Options - Yes - No CORRECT ANSWER : Yes
Feature of a local variable?
Options - It can be used anywhere in the program - It must accept a class - It must be declared within a method - It represent a class object CORRECT ANSWER : It must be declared within a method
int keyword targets to which .Net type?
Options - System.Int8 - System.Int16 - System.Int32 - System.Int64 CORRECT ANSWER : System.Int32
Can you store multiple data types in System.Array?
Options - No - Yes CORRECT ANSWER : Yes
Sealed Classes cannot be a base class.?
Options - True - False CORRECT ANSWER : True Discussion Board True Sealed class cannot be a baseclass as sealed keyword is used to make the class not be inherited by any other class.
_____________ represents a drawing surface and provides methods for rendering to that drawing surface.
Options - Graphic object - Pens object - Brushes object - Colors object CORRECT ANSWER : Graphic object
A variable which is declared inside a method is called a________variable
Options - Serial - Local - Private - Static CORRECT ANSWER : Local
An Event has _____ as default return type
Options - No return type for events - Double - Integer - String CORRECT ANSWER : No return type for events
Features of readonly variables
Options - It is allocated at compile time - Declaration and initialization can be separated - It is initialized at run time - all of these CORRECT ANSWER : all of these
If a class is using an interface, it must
Options - inherit the properties of the interface - contain the same method definitions as the interface - a and b CORRECT ANSWER : a and b
Is there any error in the following code? If yes, identify the error.
EmployeeMgmt constructor: public int EmployeeMgmt() { emp_id = 100; } Options - Return type - No errors - Formal parameters - Name CORRECT ANSWER : Return type
What does the keyword virtual mean in the method definition?
The method is public The method can be derived The method is static The method can be over-ridden CORRECT ANSWER : The method can be over-ridden
While updating, which method of the SqlCommand is best to use?
Options - ExecuteQuery - ExecuteUpdate - ExecuteNonQuery - ExecuteCommand CORRECT ANSWER : ExecuteNonQuery
The page class file is generated when:
Options - Every time a page is accessed - Whenever the assembly is recompiled and deployed - Whenever the configuration settings are changed - None of the above CORRECT ANSWER : Whenever the assembly is recompiled and deployed
What is lazy loading in C #?
What is meant by lazy loading? Image result for what is lazy loading in c# Lazy loading is the practice of delaying load or initialization of resources or objects until they're actually needed to improve performance and save system resources. ... Reduces initial load time – Lazy loading a webpage reduces page weight, allowing for a quicker page load time.
What is Globalization and Localization?
Globalization is the process of designing the application in such a way that it can be used by users from across the globe (multiple cultures). Localization, on the other hand, is the process of customization to make our application behave as per the current culture and locale. These two things go together.
How many types of action results are there in MVC?
As you can see, there are three categories of data types of ActionResult, Content Returning Results. Redirection Results.
How many types of action methods are there in MVC?
There are two methods in Action Result. One is ActionResult() and another one is ExecuteResult()
What means localization?
Localization is the adaptation of a product or service to meet the needs of a particular language, culture or desired population's "look-and-feel." ... In some business contexts, the word localization may be shortened to L10n
What does Cookies are mainly used for? three purposes:
Session management Logins, shopping carts, game scores, or anything else the server should remember Personalization User preferences, themes, and other settings Tracking Recording and analyzing user behavior Cookies were once used for general client-side storage. While this made sense when they were the only way to store data on the client, modern storage APIs are now recommended. Cookies are sent with every request, so they can worsen performance (especially for mobile data connections). Modern APIs for client storage are the Web Storage API (localStorage and sessionStorage) and IndexedDB.
Define the lifetime of a cookie?
The lifetime of a cookie can be defined in two ways: Session cookies are deleted when the current session ends. The browser defines when the "current session" ends, and some browsers use session restoring when restarting. This can cause session cookies to last indefinitely. Permanent cookies are deleted at a date specified by the Expires attribute, or after a period of time specified by the Max-Age attribute.
What are the three major lifetimes In dependency injection in NET's
AddSingleton creates a single instance of request throughout the application. It creates the instance for the first time and reuses or share the same object in the all calls.
AddScoped creates once per request and allow you to share the state throught out to the user without worrrying of creating a ne one. It is equivalent to a singleton in the current scope. For example, in MVC it creates one instance for each HTTP request, but it uses the same instance in the other calls within the same web request.
AddTransient lifetime services creates instances each time they are requested or new instance any time they are requeted but not sharedthe old one. Shorted life span. This lifetime works best for lightweight, stateless services.
what is the difference between static and private constructor in c#
1)A static constructor is called before the first instance is created. ... Whereas Private constructor is called after the instance of the class is created. 2)Static constructor will be called first time when the class is referenced. Static constructor is used to initialize static members of the class.
what is the difference between static and private constructor in c#
1)A static constructor is called before the first instance is created. Whereas Private constructor is called after the instance of the class is created. 2)Static constructor will be called first time when the class is referenced. Static constructor is used to initialize static members of the class.
What is an Exception in .NET?
What is an Exception in .NET? - Exceptions are errors that occur during the runtime of a program...
What are the four basic principles of OOPS?
The four principles of object-oriented-programming: Encapsulation, Abstraction, Inheritance, and Polymorphism.
The Four Principles of Object-Oriented-Programming (OOP):
Encapsulation
Encapsulation is accomplished when each object maintains a private state, inside a class. Other objects can not access this state directly, instead, they can only invoke a list of public functions.
Abstraction
Abstraction is an extension of encapsulation. It is the process of selecting data from a larger pool to show only the relevant details to the object. Suppose you want to create a dating application and you are asked to collect all the information about your users. You might receive the following data from your user: Full name, address, phone number, favorite food, favorite movie, hobbies, tax information, social security number, credit score. This amount of data is great however not all of it is required to create a dating profile.
Inheritance:
Inheritance is the ability of one object to acquire some/all properties of another object. For example, a child inherits the traits of his/her parents.
Polymorphism:
Polymorphism gives us a way to use a class exactly like its parent so there is no confusion with mixing types. This being said, each child sub-class keeps its own functions/methods as they are. If we had a superclass called Mammal that has a method called mammalSound(). The sub-classes of Mammals could be Dogs, whales, elephants, and horses. Each of these would have their own iteration of a mammal sound (dog-barks, whale-clicks).
what are different types of Inheritance?
Single Inheritance., Multiple Inheritance. Multi-Level Inheritance. Hierarchical Inheritance. Hybrid Inheritance.
What is a File structure?
File structures are not fixed entities, but rather build a framework that communicates the function and purpose of elements within a project by separating concerns into a hierarchy of folders and using consistent, chronological, and descriptive names. What are the 3 types of file structure? Image result for file structure Three types of files structure in OS: A text file: It is a series of characters that is organized in lines. An object file: It is a series of bytes that is organized into blocks. A source file: It is a series of functions and processes.
What is data structures?
Data Structures are a specialized means of organizing and storing data in computers in such a way that we can perform operations on the stored data more efficiently. Data structures have a wide and diverse scope of usage across the fields of Computer Science and Software Engineering
Test
Yes
What is stack and What is heap?
Primitive datatype(value type) and object references are stored on stack and object is stored on heaps
What is stack and What is heap?
In Primitive datatype, memory address point to actual value. In Object, its memory address point to other memory address.
Difference Between Errors, Defects, Bugs
Error: An action performed by a human that results in unexpected system behavior. E.g. incorrect syntax, improper calculation of values, misunderstanding of software requirements, etc. Defect: This is a term usually used by testers. If the tester finds a mistake or problem then it is referred to as Defect. Bug: Bug is the developer’s terminology. Once a defect found by a tester is accepted by the developer it is called a bug. The process of rectifying all bugs in the system is called Bug-Fixing.
Back to HomePage