What will be the result of the following code execution?

class Alien {
  String invade(short ships) { return "a few"; }
  String invade(short... ships) { return "many"; }
public class Defender {
  public static void main(String [] args) {
    System.out.println(new Alien().invade(7));
Constant 7 has an int type by default. When the function is called an implicit narrowing conversion int → short is not performed, so the compilation error will occur.

Следи за CodeGalaxy

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

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