Pages

Thursday, 23 June 2011

OBJECT ORIENTED CONCEPTS

-::OBJECT ORIENTED CONCEPTS::-

Querry??    What is Object Oriented Programming?
Object Oriented Programming is an approach that Provides a way of Modularizing programs by creating Partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on Demand.
Querry??     What are the features of Object Oriented Programming?

1.Emphasis is on Data Rather than Procedure.
2.Data is hidden and can’t be accessed by external functions.
3.Programs are divided into what are known as Objects.
4.Objects may communicate with each other through methods.
Querry??    What are the Benefits of Object Oriented Programming?
1.Through Inheritance, we can eliminate redundant code and extend the use of existing classes.
2.We can build programs from the standard Working modules, rather than writing the code from scratch. This leads to savings of Development time and gives Higher productivity.
3.The principle of Data hiding helps from invades by code in other parts of the program.
4.Easy to partition work in a project based on Objects.
5.Object Oriented systems can be easily updated from small to large Systems.
6.Software Complexity can be easily managed.

Querry??     What are the Basic Concepts of Object Oriented Programming?
Basic Concepts of OOPs are
1.DataAbstraction and Encapsulation.
2.Inheritence
3.Polymorphism.
Querry??     What is Data Encapsulation?
The wrapping up of data and methods into a single unit is called Encapsulation.
So data is not accessible to outside world and only those methods can access it.
This insulation of data from direct access by programs is called Data Hiding.
Querry??     What is Inheritance?
Inheritance is the process by which Objects of one class acquire properties of another class. Inheritance Provides the idea of Reusability.
Querry??     What are different types of Inheritance?
1.Single Inheritance:- Only One Base class and One derived Class
2.Multiple Inheritance:- Several Base Classes and a single Derived class
But this possible only with Interfaces and not with Base classes as a class can atmost t extend a base class but can Implements more than one interfaces.
3.Hierarchical Inheritance:-One Base Class and many derived classes.
4.Multilevel Inheritance:-Derived from derived class.

Querry??     What is Polymorphism?
Polymorphism means the ability to take more than one form.
Polymorphism Plays an Important role in allowing Objects having different internal Structures to share the same external interface.
The benefit of Polymorphism is when the appropriate implementation is invoked automatically at runtime depending on the type of Object.
Querry??     What are different types of Polymorphisms that are available?
Operation Polymorphism or Compile Polymorphism(EarlyBinding/StaticBinding/StaticLinking)-Using OverLoaded Methods-The Compiler is able to select and bind the appropriate method to the object for a Particular call at Compiletime Itself.
Eg. Class Dog{}
Class Cat{}
Class Operation{
static void Call(Dog d){}
static void Call(Cat c){} }
Public static void Main(){
Dog d=new Dog();
Cat c=new Cat();
Call(d);
Call(c);
}

And Inclusion Polymorphism or Runtime Polymorphism(LateBinding)-Using Virtual Methods –The decision of which method to call is delayed until Runtime.
Class Maruthi{public virtual void Display(){}}
Class Esteem:Maruthi{public override void Display(){}}
Class Zen:Maruthi{public override void Display(){}}
Class Inclusion{
Public static void Main(){
Maruthi m=new Maruthi();
m=new Esteem();
m.Display();
m=new Zen();
m.Display();
}
Querry??     What are different types of Polymorphisms that are available
?
Runtime Polymorphism and Compile Polymorphism

Querry??     What is Class?
Class is a template of class.
Querry??     What is Object?
Object is an instance of a class.
Querry??     What is Interface?
Like class Interface contains, properties, methods, but interfaces doesn’t contain implementation of those methods.
Interface defines only Abstract Methods and Final fields.
An Interface represents a contract and a class that implements an Interface must implement every aspect of that interface exactly as it is defined.
An Interface is implemented and not extended.
1.A class can implement multiple interfaces.
2.An Interface can’t contain data declarations but you can declare properties.
3.All method declarations in an Interface are Public.
4.There can be no implementation in an Interface.
5.A class implementing the interface must provide implementation code.
6.An Interface can be derived from another Interface.
Querry??     What is an Abstract Class?
An Abstract class is a class that contains methods that have no implementation(i.e abstract methods).
An abstract method is simply a shell or place-marker for a method that will be defined later in a derived class.
The intention of abstract methods is to force every derivation of the class to implement those methods. If a derived class does not implement an abstract method , then that class must also be declared as abstract.

An Abstract class is the class that can’t be instantiated(i.e no direct instances), but must be inherited from. (but whose descendents may have direct instances)
An Abstract class is usually partially implemented or not implemented at all, there by encapsulating common functionality for inherited classes.
NB:-Derived class is also called Concrete class. And Implementation of Abstract class is optional, unlike interface.
MustInherit-Class/MustOverridable-Method-vb.net
Abstract(Class&Method) –C#
Querry??     Differences between an Abstract Class and Interface?


Abstract Class Interface
1.May or maynot have abstract
methods. use virtual attribute in class to implement Partial Implementation. 1.Can only have abstract methods, but abstract Key word is not allowed.
2.Methods can have access modifiers.(except Private Members.) 2.no access modifiers are allowed, implicitly Public..`
3.can have fields, Properties and Methods. 3.can have only final constants, Properties and
Methods.
4.Can Extend a single class and implement one
or more Interfaces. 4.Can’t Extend a Class and can extend a single or multiple interfaces.
*5.Abstract classes form part of the
Inheritance schema. 5.Interfaces do not .we can use same interface in two projects that are not related interms of Inheritance.
6.Can Have Constructor. 6.Can’t Have Constructor.
*7.Its Speed and Fast at Execution. 7.Slow at Execution.
*8.If you are Designing Large Functional units
use an Abstract Class. 8.If you are designing small,Consise bits of Functionality use Interfaces.
*9.If you want provide Common, Implemented functionality among all implementations of
your Component, use an Abstract Class. 9.If the Functionality you are creating will be useful across a wide range of Disperate objects,use an Interface.

Querry??    What are Delegates?
Delegate is a Type defining a method signature, so that delegate instances can hold and Invoke method or list of methods that match its signature.
Delegates Provides Callback behavior in an jectOrientedType Safe Manner.
A delegate is a type safe reference to a function or method.
It is useful when you want to register a callback function that gets called when the user selects a menu or when an un handled exception is thrown or you may want a function to be called when an asynchronous operation completes its execution.
Using of Delegate Invoke 4 steps as follows.
a)Delegate Declaration:-modifier delegate return_type delegate_name(parameters)
Modifier -?new/static/override/abstract/sealed
eg. delegate void Mathop(double a, double b)
b)Delagate Method Defination:-
public static double Multiply(double a,double b)
{ return (a*b);}
public double Divide(double a,double b)
{return (a/b);}
c)Delegate Instantiation:-
new delegate_type(expression)
Mathop m=new Mathop(multiply);
d)Delegate Invocation:-
delegate_object(paramers list)
double d=Mathop(12.23,34.44);
Querry??    What is Event - Delegate?
An event is a Delegate type class member that is used by the Object or class to provide a notification to other objects that an event has occurred.
Modifier event type event_name
Modifier -?new/static/override/abstract/sealed
Public event Eventhandler click;---here type eventhandler is the delegate type.
When button is clicked the following code will be added in Initailized Component.
This.Button1.Click+=new System.EventHandler(this.Button1_Click)
The event keyword lets you specify a delegate that will be called upon the occurrence of some "event" in your code. The delegate can have one or more associated methods that will be called when your code indicates that the event has occurred. An event in one program can be made available to other programs that target the .NET Framework Common Language Runtime.
Querry??    What is new Modifier?
New modifier is used to hide the base class method from derived class method. It allows to reDefine some methods contained in Derived class.
Querry??    What is Enum?
Enums specify a group of named numeric Constants.
An Enum can be of Type byte, short, int or long.
Public enum Direction: byte{Northe=1,Easr=2,West=4,South=8}
Querry??    What is Structure?
Structures can be think as Light weight, memory efficient Classes.
Structure is a User defined Structure, similar to Class. It’s a Class of Value Type. It can have one or more Attributes, of any of other Datatypes.It can also have methods. A Struct object is created using new Keyword, just like a Class.
Querry??    What is the difference between a Struct and a Class?
• The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color. Although it is possible to represent a point as a class, a struct is more efficient in some scenarios. For example, if you declare an array of 1000 Point objects, you will allocate additional memory for referencing each object. In this case, the struct is less expensive.
• When you create a struct object using the new operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the new operator. If you do not use new, the fields will remain unassigned and the object cannot be used until all of the fields are initialized.
• It is an error to declare a default (parameterless) constructor for a struct. A default constructor is always provided to initialize the struct members to their default values.
• It is an error to initialize an instance field in a struct.
• There is no inheritance for structs as there is for classes. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Structs, however, inherit from the base class Object. A struct can implement interfaces, and it does that exactly as classes do.
A struct is a value type, while a class is a reference type.


Querry??    What is Shadowing?
Shadowed members are used to create the Local version of members that have broader scope.
Shadowing is used when two programmers come up with same method in the same class , one of the methods get shadowed by scope or inheritance.
Querry??    What is Virtual method?
The Concept of Virtual method is such that the bottom-most implementation of the method is always used in favor of the Parent implementation-regardless of the data type of variable being used in the client code.
Virtual method has an implementation and Provide the derived class with the option of overriding it. The class which contains Virtual methods is known as Virtual Class.
Override modifier is used while overriding an Virtual method.
Querry??    What are Constructors?
Constructors are Procedures that control Initialization of new instances of a class.
Querry??    What are Destructors?
Destructors are Procedures that are used to free System Resources when a class leaves a scope or is set to nothing.
VB.NET—Finalizer;C#- Destructor
Querry??    What are References?
References allows you to use objects defined in Other Assemblies.
Querry??    What are Shared Members (VB)/Static Members(C#)?
Shared Members are Properties, Methods and Fields that are shared by all instances of the class.
Sharing single instance of a data member or function among all instances of a class is useful in applications that use Inheritance.
Querry??    What is Namespace?
Namespaces prevent naming conflicts by organizing classes, Interfaces and Methods into hierarchies.
An assembly can contain one ore more namespaces.
?Anyalternativeto avoid name collisions other then Namespaces.
A scenario that two namespaces named N1 and N2 are there both having the same class say A. now in another class i ve written
using1;
usingN2;
and i am instantiating class A in this class. Then how will u avoid name collisions?
Ans:usingalias
Eg: using MyAlias = MyCompany.Proj.Nested;

Querry??    What are attributes?
Attributes enable you to provide additional Information about Program elements.
Eg. Access Modifiers .these can be used on class and members in the class like variable,property,methods.
Method signature:
Attributes(opt) method_modifier(opt) return_type member_name(parameter_list opt)

1.Public:-Entries that are declared as Public, have public access. There is no Restriction on the accessibility of Public Entries.
2.Protected:- Entries that are declared as Protected, have protected access. They are accessible only from their own classes or from a Derived class.
3.Friend(Internal):- Entries that are declared as Friend, have friend access. They can be accessible from within the program that contains the Declaration and within the Assembly.
4.Private:- Entries that are declared as private, have private access. They can be accessible only within the Class.
5.Protected Friend/Protected Internal:- Entries that are declared as Protected Friend, have Protected Friend. They can be accessible from within the program that contains the Declaration and within the Assembly and in the Derived Classes also.


Querry??    What are Me/MyBase/MyClass keywords?
Me keyword is used any time we want to refer to methods within the Current Object.
(this in C#)
Mybase keyword is used to call Parent Class method within the Subclass.
MyClass is used in a scenario , where the code Calls your own implementation of the method instead of an overridden method in the derived class
Querry??    What is Over Loading?
Over Loading is the ability to define Properties, Methods that have the same name but use different type of data types and different type of Parameters.
Overloading Procedures allow you to provide as many implementations as necessary to handle different kinds of data while giving the appearance of a single Versatile procedure.
Functions of Same name but with different Parameters.
Simply by Changing return type we can’t Overload a method.
Overloads---Keyword-VB
NoKeyword-C#

Querry??    What is Overriding?
Overriding is Defining a method in Derived class that has the same name ,same arguments and same return type as a method in Base Class.
Overridable/Overrides/NotOverridable(sealed)/MustOverride(abstract)---vb
Virtual/Override---C#

Querry??    What is Distributed Computing?
It is a Programming Model in which processing occurs in Many Different Places around the network eg. On a server, Personal Computer ,Hand held device.
This is contrast to the two node system prevalent today(The client and Centralized server).
Querry??    Which namespace is the base class for .net Class library?
system.object
Querry??   using directive vs using statement?
You create an instance in a using statement to ensure that Dispose is called on the object when the using statement is exited. A using statement can be exited either when the end of the using statement is reached or if, for example, an exception is thrown and control leaves the statement block before the end of the statement.
The using directive has two uses:
• Create an alias for a namespace (a using alias).
• Permit the use of types in a namespace, such that, you do not have to qualify the use of a type in that namespace (a using directive).
Querry??    What is the difference between CONST and READONLY?

Both are meant for constant values. A const field can only be initialized at the declaration of the field. A readonly field can be initialized either at the declaration or in a constructor. Therefore, readonly fields can have different values depending on the constructor used.
readonly int b;
public X()
{
b=1;
}
public X(string s)
{
b=5;
}
public X(string s, int i)
{
b=i;
}
Also, while a const field is a compile-time constant, the readonly field can be used for runtime constants, as in the following example:
public static readonly uint l1 = (uint) DateTime.Now.Ticks; (this can't be possible with const)
Querry??    What is the difference between ref & out parameters?
An argument passed to a ref parameter must first be initialized. Compare this to an out parameter, whose argument does not have to be explicitly initialized before being passed to an out parameter.
Querry??    What is the difference between Array and Arraylist?
As elements are added to an ArrayList, the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling TrimToSize or by setting the Capacity property explicitly.
Querry??    What is Jagged Arrays?
A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an "array-of-arrays."
Querry??    What are indexers?
Indexers are Location indicators and are used to access class objects, just like elements in an array. They are useful in cases where a class is a container for other objects.
An Indexer looks like a Property with two following differences.
1.Indexer takes an Index argument and looks like an Array.
2.Indexer is declared using the name this.
Indexers are similar to properties, except that the get and set accessors of indexers take parameters, while property accessors do not.
Public double this [int idx]{get{}set{}}
Eg.class List{ArrayList array=new ArrayList();
Public object this[int index]
{get{return(array[index])}}
set{array[index]=value;}}}
class IndexerTest{public static void main()
{List list=new List();list[0]=”123”;list[1]=”abc”;
for(int I=0;I
Console.writeline(list[I])}}
Querry??    What are indexers?
Indexers are Location indicators and are used to access class objects, just like elements in an array. They are useful in cases where a class is a container for other objects.
An Indexer looks like a Property with two following differences.
1.Indexer takes an Index argument and looks like an Array.
2.Indexer is declared using the name this.
Indexers are similar to properties, except that the get and set accessors of indexers take parameters, while property accessors do not.
Public double this [int idx]{get{}set{}}
Eg.class List{ArrayList array=new ArrayList();
Public object this[int index]
{get{return(array[index])}}
set{array[index]=value;}}}
class IndexerTest{public static void main()
{List list=new List();list[0]=”123”;list[1]=”abc”;
for(int I=0;I
Console.writeline(list[I])}}
Querry??    What are Different DataTypes available in .NET?
1.In Value Type, the variable stores the Data directly in the Stack Memory. i.e Structures,Enumerations.
2.In Reference Type,the Variable stores the Address of the Data and the Data is Stored in the Heap Memory. and Garbage collector take care of freeing of memory resources.

i.e Class,Arrays,Interfaces,Delegate.


Querry??    What are Data Types available in .NET?

Data Type is an attribute that specifies the type of data that object can hold.
System.Boolean ( 1 byte
System.Byte ( 1 byte
System.Char ( 2 bytes
System.Int16 ( 2 bytes
System.Int32 ( 4 bytes
System.Int64 ( 8bytes
System.Object ( 4bytes
System.Single ( 4bytes
System.Double ( 8bytes
System.Decimal ( 12bytes
System.DateTime ( 8bytes
System.String ( 10bytes +(2*string length)
System.ValueType ( Sum of Member sizes(User Defined Type)

?Value type & reference types difference? Example from .NET. Integer & struct are value types or reference types in .NET?
Most programming languages provide built-in data types, such as integers and floating-point numbers, that are copied when they are passed as arguments (that is, they are passed by value). In the .NET Framework, these are called value types. The runtime supports two kinds of value types:
• Built-in value types
The .NET Framework defines built-in value types, such as System.Int32 and System.Boolean, which correspond and are identical to primitive data types used by programming languages.
• User-defined value types
Your language will provide ways to define your own value types, which derive from System.ValueType. If you want to define a type representing a value that is small, such as a complex number (using two floating-point numbers), you might choose to define it as a value type because you can pass the value type efficiently by value. If the type you are defining would be more efficiently passed by reference, you should define it as a class instead.
Variables of reference types, referred to as objects, store references to the actual data. This following are the reference types:
• class
• interface
• delegate
This following are the built-in reference types:
• object
• string
Querry??    What is Boxing and Unboxing?
Boxing is a mechanism of converting a value type to reference type.
Un Boxing is a mechanism of Converting reference type to value type.
Querry??    What are Different Object types offered by CLR?
There are two types of Object types that are offered by CLR. They are
a) Value Types
b) Reference Types
Reference Types are always allocated from the managed heap and the new operator returns the memory address of object and Garbage collector take care of freeing of memory resources.
Eg: Strings,objects etc
Value Types are allocated on a thread’s stack and variable representing the object does not contain a pointer to an object. Value types are lightweight than reference types because they are not allocated in managed heap, not garbage collected and not referenced to by pointers. Value type is referred as structure. value type is primitive type and type does not inherit from another type.
Eg: int32,Boolean,decimal etc.
NB:-Heap is Temporary Memory i.e RAM and Stack is Permanent Memory i.e HardDisk.
Querry??    What are Custom Attributes?
Custom Attributes are used to adorn type,methods,fields etc.
When compiled the compiler emits these method attributes into the managed module’s metadata. At runtime, this metadata can be examined and based on the presence of these attributes the behaviour of the application changes.

Querry??    What is Custom attribute? How to create? If I'm having custom attribute in an assembly, how to say that name in the code?
A: The primary steps to properly design custom attribute classes are as follows:
o. Applying the AttributeUsageAttribute ([AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)])
p. Declaring the attribute. (class public class MyAttribute : System.Attribute { // . . . })
q. Declaring constructors (public MyAttribute(bool myvalue) { this.myvalue = myvalue; })
r. Declaring properties
public bool MyProperty
{
get {return this.myvalue;}
set {this.myvalue = value;}
}
The following example demonstrates the basic way of using reflection to get access to custom attributes.
class MainClass
{
public static void Main()
{
System.Reflection.MemberInfo info = typeof(MyClass);
object[] attributes = info.GetCustomAttributes();
for (int i = 0; i < attributes.Length; i ++)
{
System.Console.WriteLine(attributes[i]);
}
}
}

Querry??     What are Attributes?    What are different types of Attributes?
Attributes are used to adorn type,methods,fields etc.
There are at least two types of .NET Attributes. They are
a) Metadata Attributes:-It allows some data to attached to a class or method. This data becomes part of metadata for the class and can be accessed via reflection. Eg [serializable]
NB:-System.Attribute class
b) Context Attributes:-This also uses same syntax as Metadata Attributes but they are fundamentally different. Context Attributes provide an interception mechanism whereby instance activation and method calls can be pre and /or post processed.
Querry??     What is early binding and late binding?
Early binding means that the compiler has knowledge about an object at compile time  
? Late binding means that compiler do not have any knowledge about an object
Late Binding uses Create Object to create and instance of the application object, which you can then control.
Eg: Dim oXL as Object
Set oXL=CreateObject(“Excel.Application”)
NB: -Regardless of whether you are using early or late binding use GetObject to manipulate an existing object.

To use Early binding you need to set a reference in your project to the application you want to manipulate.
Eg. Dim oXL as Object
Set oXL=New Excel.Application
Querry??     What are the advantages of early binding and late binding?
Advantages of Early Binding: -
1.Code will run considerably faster, because it can all be compiled up front, but in late binding the code is compiled as it runs.
2.As code is compiled up front, debugging is far easier and compiler will able to spot syntax errors which would have been missed had you used late binding.
3.We can have full access to Intellisense in the project.
4.We can access the application’s built-in constants.
Eg. .windowState=wdWindowStateMaximize
In LateBinding, we use it like the following
.windowState=1

Advantages of Late Binding:-
1.The main Advantage to use late binding is that the code is more certain to be version –Independent.
2.In Early binding, the more references your project contains , the larger the file size and the longer it takes to compile.
3.Some Programming environments don’t allow you to create references to another application.

?In which cases you use override and new base?
Use the new modifier to explicitly hide a member inherited from a base class. To hide an inherited member, declare it in the derived class using the same name, and modify it with the new modifier.
Querry??    What are Sealed Classes in C#?
The sealed modifier is used to prevent derivation from a class. A compile-time error occurs if a sealed class is specified as the base class of another class. (A sealed class cannot also be an abstract class)
Querry??     In which Scenario you will go for Interface or Abstract Class?

Interfaces vs. Abstract Classes
Feature Interface Abstract class
Multiple inheritance A class may implement several interfaces. A class may extend only one abstract class.
Default implementation An interface cannot provide any code at all, much less default code. An abstract class can provide complete code, default code, and/or just stubs that have to be overridden.
Constants Static final constants only, can use them without qualification in classes that implement the interface. On the other paw, these unqualified names pollute the namespace. You can use them and it is not obvious where they are coming from since the qualification is optional. Both instance and static constants are possible. Both static and instance intialiser code are also possible to compute the constants.
Third party convenience An interface implementation may be added to any existing third party class. A third party class must be rewritten to extend only from the abstract class.
is-a vs -able or can-do Interfaces are often used to describe the peripheral abilities of a class, not its central identity, e.g. an Automobile class might implement the Recyclable interface, which could apply to many otherwise totally unrelated objects. An abstract class defines the core identity of its descendants. If you defined a Dog abstract class then Damamation descendants are Dogs, they are not merely dogable. Implemented interfaces enumerate the general things a class can do, not the things a class is.
Plug-in You can write a new replacement module for an interface that contains not one stick of code in common with the existing implementations. When you implement the interface, you start from scratch without any default implementation. You have to obtain your tools from other classes; nothing comes with the interface other than a few constants. This gives you freedom to implement a radically different internal design. You must use the abstract class as-is for the code base, with all its attendant baggage, good or bad. The abstract class author has imposed structure on you. Depending on the cleverness of the author of the abstract class, this may be good or bad. Another issue that's important is what I call "heterogeneous vs. homogeneous." If implementors/subclasses are homogeneous, tend towards an abstract base class. If they are heterogeneous, use an interface. (Now all I have to do is come up with a good definition of hetero/homogeneous in this context.) If the various objects are all of-a-kind, and share a common state and behavior, then tend towards a common base class. If all they share is a set of method signatures, then tend towards an interface.
Homogeneity If all the various implementations share is the method signatures, then an interface works best. If the various implementations are all of a kind and share a common status and behavior, usually an abstract class works best.
Maintenance If your client code talks only in terms of an interface, you can easily change the concrete implementation behind it, using a factory method. Just like an interface, if your client code talks only in terms of an abstract class, you can easily change the concrete implementation behind it, using a factory method.
Speed Slow, requires extra indirection to find the corresponding method in the actual class. Modern JVMs are discovering ways to reduce this speed penalty. Fast
Terseness The constant declarations in an interface are all presumed public static final, so you may leave that part out. You can't call any methods to compute the initial values of your constants. You need not declare individual methods of an interface abstract. They are all presumed so. You can put shared code into an abstract class, where you cannot into an interface. If interfaces want to share code, you will have to write other bubblegum to arrange that. You may use methods to compute the initial values of your constants and variables, both instance and static. You must declare all the individual methods of an abstract class abstract.
Adding functionality If you add a new method to an interface, you must track down all implementations of that interface in the universe and provide them with a concrete implementation of that method. If you add a new method to an abstract class, you have the option of providing a default implementation of it. Then all existing code will continue to work without change.
Querry??     Write one code example for compile time binding and one for run time bindingQuerry??    What is early/late binding?
An object is early bound when it is assigned to a variable declared to be of a specific object type. Early bound objects allow the compiler to allocate memory and perform other optimizations before an application executes.
' Create a variable to hold a new object.
Dim FS As FileStream
' Assign a new object to the variable.
FS = New FileStream("C:\tmp.txt", FileMode.Open)
By contrast, an object is late bound when it is assigned to a variable declared to be of type Object. Objects of this type can hold references to any object, but lack many of the advantages of early-bound objects.
Dim xlApp As Object
xlApp = CreateObject("Excel.Application")
Querry??     How can you write a class to restrict that only one object of this class can be created (Singleton class)?
Use the private access modifier for default constructor and use static getinstance method to create an intenace, if already one is not present.
Querry??     Difference between type constructor and instance constructor ? What is static constructor, when it will be fired? And what is its use?
(Class constructor method is also known as type constructor or type initializer)
Instance constructor is executed when a new instance of type is created and the class constructor is executed after the type is loaded and before any one of the type members is accessed. (It will get executed only 1st time, when we call any static methods/fields in the same class.) Class constructors are used for static field initialization. Only one class constructor per type is permitted, and it cannot use the vararg (variable argument) calling convention.
A static constructor is used to initialize a class. It is called automatically to initialize the class before the first instance is created or any static members are referenced.
Querry??    What is Private Constructor? and it’s use? Can you create instance of a class which has Private Constructor?
A: When a class declares only private instance constructors, it is not possible for classes outside the program to derive from the class or to directly create instances of it. (Except Nested classes)
Make a constructor private if:
- You want it to be available only to the class itself. For example, you might have a special constructor used only in the implementation of your class' Clone method.
- You do not want instances of your component to be created. For example, you may have a class containing nothing but Shared utility functions, and no instance data. Creating instances of the class would waste memory.
? I have 3 overloaded constructors in my class. In order to avoid making instance of the class do I need to make all constructors to private?
(yes)
? Overloaded constructor will call default constructor internally?
(no)
Querry??    What is check/uncheck?
Querry??    What is Asynchronous call and how it can be implemented using delegates?
Querry??     How to create events for a control?? What is custom events? How to create it?
Querry??     without modifying source code if we compile again, will it be generated MSIL again?
Querry??    What is Params/Ref/Out parameters?-Method Parameters
The params keyword lets you specify a method parameter that takes an argument where the number of arguments is variable.
No additional parameters are permitted after the params keyword in a method declaration, and only one params keyword is permitted in a method declaration.

No comments:

Post a Comment

Thanks For your Comments Please Continue with your precious Time and greate Knowladge will be benificial for learner like me thanks a lot...........