Monday, 17 April 2017

.Net interview questions.

Following are some basic programming questions often asked during interview. Check these out.


1. Write an algorithm and program to determine whether or not a word is a palindrome.
Answer:
static void Main(string[] args)
        {
            string str, revstr;
            Console.WriteLine("Enter Any String to Know It is Palindrome or not");
            str = Console.ReadLine();
            char[] tempstr = str.ToCharArray();
            Array.Reverse(tempstr);
            revstr = new string(tempstr);
            if (revstr == str)
            {
                Console.WriteLine("............" + str + " Is a Palindrome..........");
            }
            else
            {
                Console.WriteLine("............" + str + " Is Not a Palindrome........");
            }
            Console.Read();
        }

2. What is Authentication and Authorization
Answer: Authentication: In ASP.NET authentication means to identify the user or in other words its nothing but to validate that he exists in your database and he is the proper user.
Authorization: Authorization means does he have access to a particular resource on the IIS website. A resource can be an ASP.NET web page, media files (MP4, GIF, JPEG etc), compressed file (ZIP, RAR) etc.

3. Describe authentication, types, differences?
Answer: Windows authentication: - In this methodology ASP.NET web pages will use local windows users and groups to authenticate and authorize resources.
 Forms Authentication: - This is a cookie based authentication where username and password are stored on client machines as cookie files or they are sent through URL for every request. Form-based authentication presents the user with an HTML-based Web page that prompts the user for credentials.
 Passport authentication: Passport authentication can be used when ever u are using a single username password combination to authenticate in to a group of website. The simplest example that i can give is that of a google gmail account. with a single emailid password combination u are able to access youtube,gmail,google+,blogger and most of the google web appplications.
 Anonymous access: - If you do not want any kind of authentication then you will go for Anonymous access.

4. Why DBMS? Why don't we save data in separate files? 
Answer: Because DBMS provides database normalization. Database Normalization, or simply normalization, is the process of organizing the columns (attributes) and tables (relations) of a relational database to reduce data redundancy and improve data integrity. Normalization is also the process of simplifying the design of a database so that it achieves the optimum structure. It reduces and eliminates redundant data. In normalization, data integrity is assured.
Find more reasons here http://courses.cs.washington.edu/courses/cse544/99sp/lectures/intro/sld010.htm.

5. What is the differences between a Primary key and a Unique key?
Answer. Primary key doesn't allow NULL, a unique key does.

6. What exactly is happening when we make a field a primary key?
Answer. A clustered index will be created for that specific field.

7.What is the difference between a clustered and a non-clustered index?
Answer:  Clustered Index: The primary key created for the column will create a clustered index for that column. A table can have only one clustered index on it. When creating the clustered index, SQL server 2005 reads the primary key column and forms a Binary tree on it. This binary tree information is then stored separately in the disc. Expand the table and then expand the Indexes.
  Non Clustered Index: A non-clustered index is useful for columns that have some repeated values. Say for example, AccountType column of a bank database may have 10 million rows. But, the distinct values of account type may be 10-15. A clustered index is automatically created when we create the primary key for the table. We need to take care of the creation of the non-clustered index.

Check more here: https://www.codeproject.com/articles/173275/clustered-and-non-clustered-index-in-sql

8. What is a Distributed System?
Answer:. A collection of autonomous computers
a) linked by a network
b) using software to produce an integrated computing facility

9. What are Abstract Classes?
Answer:The purpose of an abstract class is to define some common behavior that can be inherited by multiple subclasses, without implementing the entire class. In C#, the abstract keyword designates both an abstract class and a pure virtual method.
Properties:
1. An abstract class cannot be instantiated.
2. It can be inherited.
3. It can have method implementations, class members.
4. Only abstract classes can have abstract methods.

10. What are Abstract methods?Give an example?
Answer: Abstract methods have no implementation, so the method definition is followed by a semicolon instead of a normal method block. Derived classes of the abstract class must implement all abstract methods.
Properties:
1. It can be declared only inside abstract class.
2. It contains only method definition not the implementation.
3. It must be overridden.

11. What are virtual methods?
Answer: A class can have a virtual method. The virtual method has an implementation. When you inherit from a class that has a virtual method, you can override the virtual method and provide additional logic, or replace the logic with your own implementation.
Properties:
1. It can be declared inside abstract as well as non abstract class.
2. It contains method implementation.
3. It may be overridden.

12. Explain The Difference Between Abstract Class and Interface ?
Answer: Following are some diffrences:
1. An Abstract class doesn’t provide full abstraction but an interface does provide full abstraction; i.e. both a declaration and a definition is given in an abstract class but not so in an interface.
2. Using Abstract we cannot achieve multiple inheritance but using an Interface we can achieve multiple inheritance.
3. We cannot declare a member field in an Interface.
4. We cannot use any access modifier i.e. public , private , protected , internal etc. because within an interface by default everything is public.
5. An Interface member cannot be defined using the keyword static, virtual, abstract or sealed.

13. Explain Generic Collections & Array Lists ?
Answer: Generics allow you to write a class or method that can work with any data type. Generic Collections helps us to create flexible type-safe, strong type collections at compile time.
Syntax:
List<int> myInts = new List<int>();
Namespace:
System.Collections.Generic

ArrayList: They are ordered collection of objects, that can be resized automatically, that has dynamic memory allocation and which can contain different types of data.
Arraylist stores its members as objects, so in order to retrieve it we must type cast it.
Syntax and Example:
ArrayList intlist = new ArrayList();
 intlist.Add(34);
 intlist.Add("sasi");
Namespace:
System.Collections;

No comments:

Post a Comment