🎴 Flashcard Mode
Java and ABAP Programming Fundamentals
Card1 / 20
Mastered0
Review0
QuestionClick to flip
Given: class Alien { String invade(short ships) { return "a few"; } String invade(short... ships) { return "many"; } } class Defender { public static void main(String [] args) { System.out.println(new Alien().invade(7)); } } What is the result?
AnswerClick to flip back
A
Compilation fails.
💡 Explanation:
The literal 7 is of type int. Java does not perform implicit narrowing of integer arguments to match method parameters of type short or short.... Since there is no matching method that accepts int arguments, the compiler cannot resolve the call, resulting in a compilation failure.