Interview Questions (OOPS)

Tuesday, 22 June 2010 23:35 by harpreet

Read this article in your language IT | EN | DE | ES

What’s the top .NET class that everything is derived from?
System.Object.

System.String class vs System.Text.StringBuilder class?
System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed. 
Immutable: The data value may not be changed (The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory).

What is strong-typing versus weak-typing? Which is preferred? Why?
Strong type is checking the types of variables as soon as possible, usually at compile time. While weak typing is delaying checking the types of the system as late as possible, usually to run-time. Which is preferred depends on what you want. For scripts & quick stuff you’ll usually want weak typing, because you want to write as much code as possible. In big programs, strong typing can reduce errors at compile time.

Do Virtual method can be static or private?
Since virtual methods are used for achieving polymorphism and since polymorphism works only with objects, it is not possible to declare a static method as virtual in C#. Similarly the private methods are also not possible to declare virtual, since they can’t override inside a derived class.
Note: Polymorphism works only with objects.

Are private class-level variables inherited?
Yes, but they are not accessible.  Although they are not visible or accessible via the class interface, they are inherited. 

Name two ways that you can prevent a class from being instantiated?
A class cannot be instantiated if it is abstract or if it has a private constructor.

Boxing and Unboxing?
Boxing
is an implicit conversion of a value type to the type object
int i = 123; // A value type
Object box = i // Boxing

Unboxing is an explicit conversion from the type object to a value type
int i = 123; // A value type
object box = i; // Boxing
int j = (int)box; // Unboxing

What is a Property?
A Property is a special member constructor that is used like a field, but acts like a method. Properties are special kind of methods that generally are used to provide constrained access to Field.

Categories:   Interview
Actions:   E-mail | Permalink | Comments (1) | Comment RSSRSS comment feed

Comments

November 3. 2010 09:42

online casino slot machines

experimentative

online casino slot machines

About me

Chat with Admin

Gmail: dotnetcracknews@gmail.com
Mobile: +91-9871115233

Calendar

<<  May 2012  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar
Disclaimer

The articles documented here contain some material excerpted from net, I will try to make sure that I mention reference to those sites, but if I miss out on some areas it is not intentional.

© Copyright 2012