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

What's a method in programming?

552


Why is sizeof not a function?

556


What is meant by class loader? How many types are there?

678


What are advantages of using Java?s layout managers than windowing systems?

1870


What is an enumeration?

574






If I only change the return type, does the method become overloaded?

543


What are the main differences between notify and notifyAll in Java?

591


Why do we need strings in java?

532


What is a generic data type?

574


Does java allow default arguments?

592


What is local class in java?

529


How to perform quicksort in java?

573


How many types of assembly languages are there?

534


Using callable statement how can you pass out parameters, explain with example?

596


What is the range of the short type?

597