Given class Feline public static void mainString args Long x 42L Long y 44L

# Given class feline public static void mainstring args

• Test Prep
• rachitkul0206
• 64
• 60% (5) 3 out of 5 people found this document helpful

This preview shows page 19 - 22 out of 64 pages.

38. Given:class Feline {public static void main(String[] args) {Long x = 42L;Long y = 44L;System.out.print(" " + 7 + 2 + " ");System.out.print(foo() + x + 5 + " ");System.out.println(x + y + foo());}static String foo() { return "foo"; }}What is the result?A. 9 foo47 86fooB. 9 foo47 4244fooC. 9 foo425 86fooD. 9 foo425 4244fooE. 72 foo47 86fooF. 72 foo47 4244fooG. 72 foo425 86fooH. 72 foo425 4244fooI. Compilation failsAnswer:G is correct. Concatenation runs from left to right, and if either operand is a Stringthe operands are concatenated. If both operands are numbers they are added together.Unboxing works in conjunction with concatenation.A, B, C, D, E, F, H, and I are incorrect based on the above. ,39. Place the fragments into the code to produce the output 33. Note, you must use each fragmentexactly once.CODE:class Incr {public static void main(String[] args) {Integer x = 7;int y = 2;x ___ ___;___ ___ ___;___ ___ ___;___ ___ ___;System.out.println(x);}}FRAGMENTS:y y y y
11. System.out.println(dd[index++][index++]);12. }13. }What is the result? (Choose all that apply.)