• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Adding bytes and getting int

 
Ranch Hand
Posts: 107
MyEclipse IDE Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Q1. If we are adding byte and byte then it should also result byte but it is int. Why?
 
Greenhorn
Posts: 17
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Somprakash Rai
First,
Next time, Whenever you want to ask new question, start in new topic.

Second,answer to above question,Whenever the byte ,short and char type variables used in the expression like above one ,addition , those variables are promoted to int type
 
Prakash Rai
Ranch Hand
Posts: 107
MyEclipse IDE Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Abhijeet Sutar wrote:@Somprakash Rai "I think I have started Java Basic topic and all these question comes under this topic so I have posted . "
First,
Next time, Whenever you want to ask new question, start in new topic.


Second,answer to above question,Whenever the byte ,short and char type variables used in the expression like above one ,addition , those variables are promoted to int type

 
Marshal
Posts: 76885
366
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Abhijeet Sutar wrote: . . . Whenever you want to ask new question, start in new topic. . . .

Agree. We have a relatively new feature, which allows me to make the new posts into a new topic.

Voilà!

And I think you have given a sufficient answer.
 
F is for finger. Can you stick your finger in your nose? Doesn't that feel nice? Now try this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic