I have a class declared as below
public class a
{
public void add()
{}
}



What is the diference between
a a1 =new a;
and simply
a a1;

Answers were Sorted based on User's Feedback



I have a class declared as below public class a { public void add() {} } What is th..

Answer / rahul maurya

in a a1=new a memory is allocated to the main function to execute

Is This Answer Correct ?    8 Yes 0 No

I have a class declared as below public class a { public void add() {} } What is th..

Answer / radhika

a a1;
At this stage, a1 is of type a, but it does not actually
contain the object data yet. For it to
contain the object data, you need to use the new keyword to
create a new instance of the a class,this
process is known as object instantiation :
a a1 = new a();

Is This Answer Correct ?    3 Yes 0 No

I have a class declared as below public class a { public void add() {} } What is th..

Answer / pritam kumar

in a a1
It only declares an object a1 of class a but no memory is
allocted to execute the main method

where as in a a1 = new a

It declares an object and also intiate it using the new key
word.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Sharp Interview Questions

What is an assembly loader?

0 Answers  


What are the methods in c#?

0 Answers  


What is an interface class? Give one example of it

0 Answers  


How many aware interfaces are there?

0 Answers  


Why do we need a singleton class?

0 Answers  


If we inherit a class do the private variables also get inherited ?

6 Answers   TCS,


What is marshalling in c#?

0 Answers  


can you overload a method of class A in Class B if it is derived class of A?If it is yes tell me how is it possible?

4 Answers   Mphasis, Ness Technologies,


List some of the basic string operation?

0 Answers  


Value Type and Reference Type Data type in C#?

0 Answers   HCL,


What is the namespace for the thread class?

0 Answers  


What is response redirect in c#?

0 Answers  


Categories