byte a=5;
byte b=5;
byte c=a+b;
System.out.println(c);
whats the o/p?

Answers were Sorted based on User's Feedback



byte a=5; byte b=5; byte c=a+b; System.out.println(c); whats the o/p?..

Answer / ravi

It will show compile time error
possible loss of precision
found int
reqired byte

Is This Answer Correct ?    27 Yes 1 No

byte a=5; byte b=5; byte c=a+b; System.out.println(c); whats the o/p?..

Answer / amulkumar

CE:Type mismatch: cannot convert from int to byte
at byte c=a+b;

to avoid this typecast: byte c=(byte)a+b;
or
int c=a+b;

Is This Answer Correct ?    18 Yes 6 No

byte a=5; byte b=5; byte c=a+b; System.out.println(c); whats the o/p?..

Answer / ravikiran

compilation fails
possibl;e loss of precision
because results in an int

Is This Answer Correct ?    10 Yes 0 No

byte a=5; byte b=5; byte c=a+b; System.out.println(c); whats the o/p?..

Answer / g.prabha

compilation error.

Is This Answer Correct ?    6 Yes 0 No

byte a=5; byte b=5; byte c=a+b; System.out.println(c); whats the o/p?..

Answer / janardhan

Above code , there is compile time error will coming, because
ie type mismatch error from byte to int, instead of byte we
can replace int(before a+b), it will excuite succesfully

Is This Answer Correct ?    4 Yes 0 No

byte a=5; byte b=5; byte c=a+b; System.out.println(c); whats the o/p?..

Answer / kalyan

it will shows complie time error,to execute we typecast the
int to byte

Is This Answer Correct ?    5 Yes 1 No

byte a=5; byte b=5; byte c=a+b; System.out.println(c); whats the o/p?..

Answer / dinesh kumar

compilation fails
possibl;e loss of precision, because
ie type mismatch error from byte to int, instead of byte we
can replace int(before a+b), it will excuite succesfully

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is a map in java?

0 Answers  


Define reflection.

0 Answers  


a thread is runnable, how does that work? : Java thread

0 Answers  


Describe method overriding

0 Answers  


What are java packages? What is the significance of packages?

0 Answers  






What are the different types of multitasking?

0 Answers  


What is runtime locatable code?

0 Answers   Cognizant,


Does importing a package imports its sub-packages as well in java?

0 Answers  


Can we able to pass objects as an arguments in java?

0 Answers  


static inner classes means..?

1 Answers  


Which is faster string or stringbuilder?

0 Answers  


How java enabled high performance?

0 Answers  


Categories