What happens when you try to compile and run this code:

public class Main {
    public static void main( String[] args ) {
        byte i = 2;
        byte j = 2;
        byte k = i * j;
Before performing any arithmetic operations of the value of typebyte, short, char are automatically converted to the type int. Therefore, the result of the multiplication will also be of type int and then at compilation time the error of type mismatch will be found of variable byte k it's impossible to assign a value of type int.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Зарегистрируйся сейчас
или Подпишись на будущие тесты