.Net Generics Interview Questions

.Net Generics Interview Questions

Get list of .Net Interview Questions and Answers on Generics

 

What are Generics?

  • The System.Collections.Generics namespace contains the generics collections.
  • Generics can be a method, class, structure, or an interface to which it acts upon
  • Generics  can be refer to a method ,class, structure or an interface in a type – safe manner
  • Generics provide the ability to create type-safe collections in .NET.
  • Generics.Net is a well organized class which contains data structures, algorithms, design patterns and other utilities in generic form.
  • Generics are used to make the code more reusable.
  • Generics can act like any data type means there is no need to write any internal code.

 

What are Constraints in Generics?

  • Constraints are represented in C# using the where keyword
  • Constraints is something restriction the way doing that in generics
  • There are 3 types of Constraints

1.       Constructor constraint

2.       Derivation constraint

3.       Reference / value type constraints

 

What are Generics and Casting?

  • The C# compiler only lets you implicitly cast generic type parameters to Object, or to constraint-specified types
  • The compiler explicitly cast generic type parameters to only an interface but not a class.

 

How to use I Dispose of a Generic Type?

  • Just pass value of generic type parameter to the using statement then compiler will allow you to specify any instance of generic type

 

How to declare Generic Methods?

  • Generic method is defined by specifying the type parameter after the method name but before the parameter list.
  • Doe Example public string Add<T>(T val1, T val2).

 

What is use of Generic List?

  • Generic List is an efficient method of storing a collection of variables
  • Generic List is strongly typed and casting.
  • Name space to declare generics is using System.Collections.Generic.

Difference between Generics and Array List?

  • Array List is not type safe because it faces problems of boxing and UN boxing.
  • List generics are type safe and do not require boxing and UN boxing situations.
  • In terms of performance of application List generics is better than array list.
  • Array List can save different type data types.
  • List generics we can save only specific data type.
  • Array List consumes lots of memory compare to list generics/

Leave a Comment

Top 10 Interview Questions on OOPS

Top 10 .Net Interview Questions and Answers on OOPS

1. What is an Object in OOPS?

An object is a software bundle of variables and related methods. Objects are related to real life scenario. Class is the general thing and object is the specialization of general thingObjects is instance of classes.

Declaration of an Object in OOPs

ClassName objectName=new ClassName();

E.g.: Person objPerson= new Person();

An object is characterized by concepts like:

•            Attribute

•             Behavior

•             Identity

2.            What is an Attribute in OOPs?

•        Attributes define the characteristics of a class.

•        The set of values of an attribute of a particular object is called its state.

•        In Class Program attribute can be a string or it can be a integer

3.            What is a Behavior in OOPS?

•        Every object has behavior

•        In C#, behaviors of objects are written in methods.

•        If a behavior of an object needs to be performed, then the corresponding method is called.

4.            What is an Identity in OOPS?

•        Each time an object is created the object identity is been defined.

•        This identity is usually created using an identifier which is derived from the type of item

5.           What is Encapsulation in OOPS?

•        Encapsulation is one of the fundamental principles of object-oriented programming.

•        Encapsulation is a process of hiding all the internal details of an object from the outside world

•        Encapsulation is the ability to hide its data and methods from outside the world and only expose data and methods that are required

•        Encapsulation is a protective barrier that prevents the code and data being randomly accessed by other code or by outside the class

•        Encapsulation gives us maintainability, flexibility and extensibility to our code.

•        Encapsulation makes implementation inaccessible to other parts of the program and protect from whatever actions might be taken outside the function or class.

•        Encapsulation provides a way to protect data from accidental corruption

•        Encapsulation hides information within an object

•        Encapsulation is the technique or process of making the fields in a class private and providing access to the fields using public methods

•        Encapsulation gives you the ability to validate the values before the object user change or obtain the value

•        Encapsulation allows us to create a “black box” and protects an objects internal state from corruption by its clients.

There are two ways to create a validation process.

1.            Using Assessors and Mutators

2.            Using properties

Benefits of Encapsulation

•        In Encapsulation fields of a class can be read-only or can be write-only

•        A class can have control over in its fields

•        A class can change data type of its fields anytime but users of this class do not need to change any code

6.  What is Inheritance in OOPS?

•                    Inheritance, together with encapsulation and polymorphism, is one of the three primary characteristics (concept) of object-oriented programming

•                    Inheritance enables you to create new classes that reuse, extend, and modify the behavior that is defined in other classes

•                    The Class whose methods and variables are defined is called super class or base class

•                    The Class that inherits methods and variables are defined is called sub class or derived class

•                    Sometimes base class known as generalized class and derived class known as specialized class

•                    Keyword to declare inheritance is “:” (colon) in visual c#

Benefits of using Inheritance

•                    Once a behavior (method) or property is defined in a super class(base class),that behavior  or property is automatically inherited by all subclasses (derived class).

•                    Code reusability increased through inheritance

•                    Inheritance provide a clear model structure which is easy to understand without much complexity

•                    Using inheritance, classes become grouped together in a hierarchical tree structure

•                    Code are easy to manage and divided into parent and child classes

7. What is Polymorphism in OOPS?

•                    Polymorphism is one of the primary characteristics (concept) of object-oriented programming

•                    Poly means many and morph means form. Thus, polymorphism refers to being able to use many forms of a type without regard to the details

•                    Polymorphism is the characteristic of being able to assign a different meaning specifically, to allow an entity such as a variable, a function, or an object to have more than one form

•                    Polymorphism is the ability to process objects differently depending on their data types

•                    Polymorphism is the ability to redefine methods for derived classes.

Types of Polymorphism

•                    Compile time Polymorphism

•                    Run time Polymorphism

8. What is Compile Time Polymorphism in OOPS?

•                    Compile time Polymorphism also known as method overloading

•                    Method overloading means having two or more methods with the same name but with different signatures

9. What is Run Time Polymorphism in OOPS?

•                    Run time Polymorphism also known as method overriding

•                    Method overriding means having two or more methods with the same name , same signature but with different implementation

10. What is Access Modifier in OOPS?

Access modifiers determine the extent to which a variable or method can be accessed from another class or object

The following five accessibility levels can be specified using the access modifiers

•                            Private

•                            Protected

•                            Internal

•                            Protected internal

•                            Public

Leave a Comment

What is an Object in OOPS

What is an Object in OOPS?

An object is a software bundle of variables and related methods. Objects are related to real life scenario. Class is the general thing and object is the specialization of general thingObjects is instance of classes.

.Net Interview Questions and Answers

Declaration of an Object in OOPs

ClassName objectName=new ClassName();

E.g.: Person objPerson= new Person();

An object is characterized by concepts like:

•            Attribute

•             Behavior

•             Identity

 

What is an Attribute in OOPs?

•        Attributes define the characteristics of a class.

•        The set of values of an attribute of a particular object is called its state.

•        In Class Program attribute can be a string or it can be a integer

 

 

What is a Behavior in OOPS?

•        Every object has behavior

•        In C#, behaviors of objects are written in methods.

•        If a behavior of an object needs to be performed, then the corresponding method is called.

 

 

 

4.            What is an Identity in OOPS?

•        Each time an object is created the object identity is been defined.

•        This identity is usually created using an identifier which is derived from the type of item

Leave a Comment

.Net Interview Questions on Garbage Collection

Garbage Collection in .Net

.Net Framework’s -Memory Management Garbage Collector which manages allocation and release of memory from application.Now developers no need to worry about memory allocated for each object which is created on application . garbage collector automatically manages memory on application

Garbage Collection Interview Questions

I would like share this horrible experience which I faced in one of the big IT multinational company. Even though I have 8 years of experience, I flunked very badly and I flunked due to 1 topic “Garbage collector“. I hope the below discussion will help some one down the line when facing c sharp and dot net interviews. I just hope dot net interviews get more matured down the line and ask practical questions rather than asking questions which we do not use on day to day to basis.

The interviewer started with a basic question which I knew pretty well

.NET Interview Questions and answers on Garbage Collector

What is a garbage collector?

Garbage collector is a background process which checks for unused objects in the application and cleans them up.

After that answer my guess was the interviewer will not probe more….but fate turned me down , came the bouncer.

What are generations in garbage collector?

Generation define the age of the object.

Well i did not answer the question , i have just written down by searching in google….

How many types of Generations are there in GC garbage collector?

There are 3 generations gen 0 , gen 1 and gen 2.

Then came a solid tweak questions which i just slipped by saying Yes…

Does garbage collector clean unmanaged objects ?

No.

Then came the terror question…which i never knew…

When we define clean up destructor , how does it affect garbage collector?

If you define clean up in destructor garbage collector will take more time to clean up the objects and more and more objects are created in Gen 2..

How can we overcome the destructor problem ?

By implementing “Idisposable” interface.

The above question was tricky , you can search in google for finalize and dispose patterns.

Where do we normally put unmanaged code clean up?.

In finalize a.k.a destructor.

One thing i learnt from this interview experience is one thing but we also should know core concepts in detail to crack Dot net interviews .

By ShivPrasad Koirala

For more Queries please visit : http://www.questpond.com

Leave a Comment

C# and .NET interview questions and answers around global assembly cache (GAC)

C# and .NET interview questions and answers around global assembly cache (GAC)

for more visit :www.questpond.com

 

 

One of the most asked questions in .NET interviews are around assembly and GAC. Most of the times .NET developers get confused with these questions. Below are some of the question which keeps coming from GAC perspective.

 

Interviewer normally starts with what is GAC?

GAC is a central repository folder where you can share your DLL among different applications running in the same computer. So for example you have accounting and invoicing application running in the same computer and both these application need some common utility like the logging DLL then you need to register them in GAC and share them.

 

If you are able to answer the top interview questions the next question can be on versioning.

If we have different versions of DLL in GAC how can the application identify them?

 

This is done by using binding redirect and specifying older version and new version value. So which ever version you put in the new version will be used by the application.

The other question can come from the perspective of how you can register a DLL in GAC. Interviewer expectation is that you do not just talk about GACUTIL but you need talk more realistic.

 

What are the various ways by which you can register a DLL in GAC?

 

We can use the GACUTIL tool to register the DLL in GAC.

 

But when we talk about application they have 100 of DLL’s so how feasible is GACUTIL tool?

 

We need to create installation package which will register the DLL in GAC.

 

If we do not have strong name can assembly be registered in GAC?

This is again a catchy question which is testing do you know the pre-requisites to register DLL in GAC. No, you cannot register DLL in GAC without strong names.

 

How do we create strong named DLL?

 

By using SN.EXE or by going to the project properties and making the assembly string named.

 

So next time you face a question in GAC in C# and .NET interviews understand the above twist and twirls. Happy job hunting.

Leave a Comment

Questpond – .Net Interview Questions and Answers

.Net Interview Questions and Answers

for more please visit http://www.questpond.com

 

 

 

 

What is .Net?

 

 

.Net is software which is developed by Microsoft.

 

From .Net we can create softwares, application, web portals, web services, silver light application, and web sites

 

.Net provides tools for programmer or developers  to create all software related application (tools like ajax,grid,sql connection,html button , textbox, hyperlink and lots more).It enables to create stable and secure software development application

 

 

 

 

1      What is .Net Framework?

 

 

.Net Framework which includes base class libraries which provides user interface, database connectivity, web application tools etc

 

 

.Net Framework also includes CLR (Common Language Runtime) on which .Net program executes and provides functionality

 

 

2      What is .Net Architecture?

 

.Net Architecture is a Combination of

 

CLR (Common Language Runtime)

 

CTS (Common Type Specification)

 

Base Class Libraries

 

.Net tools

 

3      What is view state?

 

View State is a state management in .net. Its help to store information of data type and objects

 

 

 

 

4      What is Session State?

 

Session state is also state management but it helps to store and retrieves information for particular session.

 

 

5      What is Design Pattern?

 

 

Design patterns are reusable solution to software design problems you find again and again in real-world application development. A design pattern is not a finished design that can be transformed directly into code

 

 

Types of Design Pattern

 

 

1. Adapter Pattern

2. Flyweight Pattern

3. Facade Pattern

4. Decorator Pattern

5. Iterator Pattern

6. Bridge Pattern

7. Template Pattern

8. Proxy Pattern

9. Prototype Pattern

10. Builder Pattern

11. Observer Pattern

12. Strategy Pattern

13. Command Pattern

14. Interpreter  Pattern

15. Mediator Pattern

16. Memento Pattern

 

Structural Pattern

 

Structural Pattern uses object composition. Structural Pattern uses inheritance to define new functionality of object

 

Behavioral Patterns

 

This Pattern deals with object communication

 

6      . What is Global Assembly Cache (GAC)?

 

 

GAC stores assemblies that stores assemblies specifically designated to be shared by several applications on the computer.

 

 

7.   What is an ADO.NET?

 

ADO.Net is a .Net software component used by developers to able to access database through sql server

 

 

7      . What are Generics?

 

Generics which is introduced in .Net Framework 2.0 which has ability to create list type safe collections

 

 

8.  Modes of Authentication in Web config file

 

 

 

1 .Form

 

2. Passport

 

3. Windows

 

 

9.  What is three tier architecture?

 

Three tier architecture is basically divided into three parts 1st is UI or user interface 2nd is Business Login where you write only your application login 3rd is a datalayer for database

 

 

10. What is Dataset?

 

Dataset is disconnected architecture.  It usually loads data in tabular form or xml form

Leave a Comment

Questpond – Design pattern training and interview questions

Design pattern training and interview questions

visit http://www.questpond.com

Design patterns are reusable solution to software design problems you find again and again in real-world application development.A design pattern is not a finished design that can be transformed directly into code

Types of Design Pattern

  1. Adapter Pattern
  2. Flyweight Pattern
  3. Facade Pattern
  4. Decorator Pattern
  5. Iterator Pattern
  6. Bridge Pattern
  7. Template Pattern
  8. Proxy Pattern
  9. Prototype Pattern
  10. Builder Pattern
  11. Observer Pattern
  12. Strategy Pattern
  13. Command Pattern
  14. Interpreter  Pattern
  15. Mediator Pattern
  16. Memento Pattern

Structural Pattern

Structural Pattern uses object composition . Structural Pattern uses inheritance to define new functionality of object

Behavioral Patterns

This Pattern deals with object communication

For More Information on visit http://www.questpond.com

Leave a Comment

SEO on page optimization

What is SEO (Search Engine Optimization?)

1.       SEO as term implies “Search” “Engine” “Optimization”

What people searches

Engine means algorithm

Optimization optimizing a page according to algorithm

 

2.       SEO considers how search engines work and what people search for

3.       SEO is the process of improving the visibility of a web site or a web page on a different search engines.

4.       SEO can also be also called as web site marketing. Higher the optimization of a page more frequently a site appears in the search results list.

To know more of SEO in details you can visit http://en.wikipedia.org/wiki/Search_engine_optimization

 

On Page Optimization Tips

1.       Every page should have a unique title, unique description, and unique keyword

2.       Don’t use hidden text or hidden links

3.       Website Should have SiteMap for more info visit : http://www.xml-sitemaps.com/

4.       Website Page Title normally 3-9 words or 60-80 characters maximum

5.       Website should have meta keywords and meta description

6.       Use heading tags <h1>..<.h1>,<h2>..</h2> only once per page

7.       Make sure for images use alt tag

8.       Updating Content once in a week

9.       URLs should have keywords for E.g.: http://www.propertyokplease.com/builders~1~1~builder-projects-in-Mumbai~Mumbai.html

10.   Server optimization use gzip compression mode or mode_deflate in apache  for fast loading of a website or webpage page

11.   Optimize CSS and JavaScript best including external CSS

12.   To improve Keyword density use Jquery , Ajax XMLhttprequest to hide some unwanted content

13.   Use <b>…bold tags for keywords

14.   Rewrite URLs  to seo-Friendly URLS.

15.   For best result please check Keyword analyzer tool and keyword density tool

16.   Submit Sitemap visit : http://www.xml-sitemaps.com/

17.   Add your website to different search engine

18.   For Google : webmaster tools for google

19.   Webmaster tools for bing

20.   Site Explorer for yahoo

21.   Have robot.txt file

Leave a Comment

List of Top Search Engines on Internet

List of Top Search Engines on Internet

1.       http://www.google.com

2.       http://www.yahoo.com

3.       http://www.bing.com or http://www.msn.com

4.       http://www.technorati.com

5.       http://www.20search.com/

6.       http://www.alltheweb.com/

7.       http://www.altavista.com/

8.       http://search.aol.com/aol/webhome

9.       http://www.ask.com/

10.   http://www.dogpile.com/

11.   http://www.ebay.com/

12.   http://www.excite.com/

13.   http://www.lycos.com/

14.   http://www.joeant.com/

15.   http://www.msn.com/

16.   http://www.dmoz.org/

17.   http://www.webcrawler.com/

18.   http://www.wikipedia.org/

These are famous search engine on Internet

Every Search engine has its own spider and has own search policies (Search Algorithm)

Leave a Comment

SEO Indexing or Web site Indexing

What is SEO Indexing

SEO page indexing means how your web page is indexed on search engine

Want to check index pages on

1.       http://www.google.com : site:yourdomain.com

2.       http://siteexplorer.search.yahoo.com/ :  in Explore URL type http://www.yourdomain.com

Pages indexed means search engine is crawled your web page depending upon page unique content and proper optimization means using proper HTML tags and relevant content it will through in search result

Update your site on every 3days or 4days for best results

Don’t keep any broken links because it will count as negative rank

Keep Unique content, keywords tag, description tag, title tag for best results (In short every HTML page should have its own different content don’t keep same content)

For more information visit http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=35291

Here you will get a nice explained Google seo pdf

Leave a Comment

« Newer Posts · Older Posts »