Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


will this code works fine? or will it gives error?

Object obj=5;
int i=6;
i=i+obj;

Answers were Sorted based on User's Feedback



will this code works fine? or will it gives error? Object obj=5; int i=6; i=i+obj; ..

Answer / naren

object obj=5 this is boxing

int i=6 this is initialization of variable.

i=i+obj; here we can't sum the value type and reference
type.


so,it gives the error.

Is This Answer Correct ?    10 Yes 0 No

will this code works fine? or will it gives error? Object obj=5; int i=6; i=i+obj; ..

Answer / amit kumar sharma

//can not applied this because i is value type and obj is
reference type so this will create error
//u can do this
Object obj = 5;
int i = 6;
i = i + Convert.ToInt32(obj);

Is This Answer Correct ?    8 Yes 1 No

will this code works fine? or will it gives error? Object obj=5; int i=6; i=i+obj; ..

Answer / sri4u_926

Defenitly it gives Error bcoz we cannot apply operators for
the type object.

Is This Answer Correct ?    6 Yes 1 No

will this code works fine? or will it gives error? Object obj=5; int i=6; i=i+obj; ..

Answer / somnath nanekar

it will give an error...(we hv to typecast object to int)

Is This Answer Correct ?    3 Yes 1 No

will this code works fine? or will it gives error? Object obj=5; int i=6; i=i+obj; ..

Answer / amre binnaz

Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click

Dim obj As Object
Dim i As Int16
obj = 5
i = 6
i = i + obj
MsgBox(i)


End Sub
its working fine the result shows 11
private void button1_Click(object sender, EventArgs e)
{
object obj;
obj = 5;
int i;
i =6;
i = i + Convert.ToInt16(obj);
MessageBox.Show(i.ToString());
}
when you convert the object to int then only working fine
and show result 11

Is This Answer Correct ?    1 Yes 0 No

will this code works fine? or will it gives error? Object obj=5; int i=6; i=i+obj; ..

Answer / deepika

It will give error: "Operator '+' cannot be applied to
operands of type 'int' and 'object'"

Is This Answer Correct ?    1 Yes 1 No

will this code works fine? or will it gives error? Object obj=5; int i=6; i=i+obj; ..

Answer / prakash kesharwani

this definitely work.
since obj as type integer. and also i as integer.
so the output will be 11.

its gives error when obj is type string.

Is This Answer Correct ?    1 Yes 3 No

will this code works fine? or will it gives error? Object obj=5; int i=6; i=i+obj; ..

Answer / sujata bastia

This code works fine

Is This Answer Correct ?    1 Yes 8 No

will this code works fine? or will it gives error? Object obj=5; int i=6; i=i+obj; ..

Answer / usha

YA it ll work fine

Is This Answer Correct ?    0 Yes 10 No

Post New Answer

More Dot Net Framework Interview Questions

Can you use Razor code in Javascript in ASP.Net MVC?

0 Answers  


How does assembly versioning work?

1 Answers  


How we can handle the exception at controller level in ASP.Net MVC?

0 Answers  


What is the .net framework and how does it work?

0 Answers  


Explain the new features added in version 4 of mvc (mvc4)?

0 Answers  


What is the meaning of unobtrusive javascript?

0 Answers  


Tell me about the internal working of Garbage collector?

3 Answers   Honeywell,


What is the CLR

1 Answers  


What are multicast delegates ? give me an example

1 Answers  


How you deploy .NET assemblies

1 Answers  


What are Resource Files ? How are they used in .NET

1 Answers  


what is an assembly?

11 Answers  


Categories