solve this is my problem byte a=40,byte b=50 both add value is 90 this is with in range of byte... byte range is -128to 127....
why this pgm gives error like type mismatch....




package javapgms;




public class byte1 {

public static void main(String args[])
{
byte a=40,b=50;
byte c=a+b;

System.out.println(c);
}




}
note : dont use int k...
a,b,c are in byte range... mind it..

Answer Posted / siva

c=(byte)(a+b);

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the init method?

539


What is the purpose of sizeof operator?

526


What is numeric function?

537


How do you compare two objects?

519


what are three ways in which a thread can enter the waiting state? Or what are different ways in which a thread can enter the waiting state? : Java thread

521






How to disable caching on back button of the browser?

525


What programs use java?

470


What is a generic code?

526


Is nullpointerexception checked or unchecked?

549


Explain spliterator in java8?

597


In a container there are 5 components. I want to display the all the components names, how will you do that one?

604


What checkbox method allows you to tell if a checkbox is checked?

537


What is string pool in java?

559


Explain importance of finally block in java?

580


Can singleton class be inherited in java?

513