Interview Questions

ASP.NET Interview Questions

Practical Questions :
1: Check Palindrome :
    class Palindrome
{
        static void Main()
{
string checkStr, sampleStr;
char[] temp;
System.Console.Write("Enter your String: ");
sampleStr = System.Console.ReadLine();
checkStr = sampleStr.Replace(" ", "");
checkStr = checkStr.ToLower();
temp = checkStr.ToCharArray();
System.Array.Reverse(temp);
if(checkStr== new string(temp))
{
System.Console.WriteLine("{0} is a palindrome.",sampleStr);
}
else
{
System.Console.WriteLine("{0} is NOT a palindrome.",sampleStr);
}
Console.ReadLine();
}      
    }


2: Reversing Name :

class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter name");
string a = Console.ReadLine();
char[] c = a.ToCharArray();// Convert.ToChar(a);
Array.Reverse(c);
Console.WriteLine(c);
Console.ReadKey();

}

3: Printing Triangle Using C#

class Program
{
public static void Main()
{
int number = 12;

for (int i = 1; i <= number; i++) // for limits 
{
for (int j = 1; j <= number - i; j++) // for spaces
Console.Write(" ");
for (int k = 1; k <= i; k++) // for printing * 
Console.Write(" *");
Console.WriteLine("");
}
Console.ReadLine();
}
}


4: Character Count in a String 

class Program
{
static void Main(string[] args)
{

string abc = "aaddaaddd";
int Count = 0;
int Counta = 0;
foreach (char c in abc)
{
if (c == 'd')
{
Count++;
}
if (c == 'a')
{
Counta++;
}
}
int k = Count;
int a = Counta++;
Console.WriteLine("count of d is {0}:a is {1}", k, a);

Console.ReadKey();


}
}

5: Reversing Complete String Name :

namespace test
{

class ReverseString
{
public static void Main(string[] args)
{
//string text = "manoj sagoi";
string text = Console.ReadLine();
string[] test = text.Split( );
for (int i = test.Length - 1; i >= 0; i--)
{
string s = test[i];
Console.WriteLine(s);
}
Console.ReadKey();
}
}


}


6: Virtual Methods in C#.NET 

When you want to allow a derived class to override a method of the base class, within the base class method must be created as virtual method and within the derived class method must be created using the keyword override.

When a method declared as virtual in base class, then that method can be defined in base class and it is optional for the derived class to override that method.

When it needs same definition as base class, then no need to override the method and if it needs different definition than provided by base class then it must override the method.

Method overriding also provides more than one form for a method. Hence it is also an example for polymorphism.


7: Abstract Classes and Abstract Methods in C#.NET

The purpose of abstract class is to provide default functionality to its sub classes.

When a method is declared as abstract in the base class then every derived class of that class must provide its own definition for that method.

 An abstract class can also contain methods with complete implementation, besides abstract methods.

When a class contains at least one abstract method, then the class must be declared as abstract class

It is mandatory to override abstract method in the derived class.

When a class is declared as abstract class, then it is not possible to create an instance for that class. But it can be used as a parameter in a method.
8: Sealed classes and Sealed methods in C#.NET


Sealed Classes


When you want to restrict your classes from being inherited by others you can create the class as sealed class.

To create a class as sealed class, create the class using the keyword sealed.

[Access Modifier] sealed class classname
{
}
Sealed Methods 
The virtual nature of a method persists for any number of levels of inheritance.

For example there is a class “A” that contains a virtual method “M1”. Another class “B” is inherited from “A” and another class “C” is inherited from “B”. In this situation class “C” can override the method “M1” regardless of whether class “B” overrides the method “M1”.

At any level of inheritance, if you want to restrict next level of derived classes from overriding a virtual method, then create the method using the keyword sealed along with the keywordoverride.

[Access Modifier] sealed override returntype methodname([Params])
{
}




Important Questions must Prepare for Interview

A. SQL
1. truncate and delete diffrence
2. magic table
3. function and procedure
4. type of trigger
5. identy and scope identy and another one
6. primary and uniqe key
7. if unique Key then create foreign key
8. foren key allow NULL?
9. CTS (running total,duplicate,parent child query)
10.DBcheck constatnt
11. diffrece between sql 2005 and sql 2008
12.rollup,cube
13. self join
14 merge statement

.net
1. Isolation Level
2. default class type
3. session and type
4. abstract class 
5. abstract methods and virtual method
6. static class and scope
7. static class constructor used? or not if yes then scope
8. clone and copy 
9. statemanagement
10. view state and (page life cycle which event has beenload)
11. page life cycle
12. view state and hidden field
13.persistent cookies
14. interface and abstract class
15. collection type and name space
15. name space and physical library.





No comments:

Post a Comment