This topic contains a solution. Click here to go to the answer

Author Question: Analyze the following code:public class Test { public static void main(String[] args) ... (Read 53 times)

abarnes

  • Hero Member
  • *****
  • Posts: 556

Question 1

Given the following method

static void nPrint(String message, int n) {
while (n > 0) {
System.out.print(message);
n--;
}
}

What is k after invoking nPrint("A message", k)?

int k = 2;
nPrint("A message", k);

◦ 0
◦ 1
◦ 2
◦ 3

Question 2

Analyze the following code:

public class Test {
public static void main(String[] args) {
System.out.println(xMethod(5, 500L));
}

public static int xMethod(int n, long l) {
System.out.println("int, long");
return n;
}

public static long xMethod(long n, long l) {
System.out.println("long, long");
return n;
}
}

◦ The program displays int, long followed by 5.
◦ The program runs fine but displays things other than 5.
◦ The program displays long, long followed by 5.
◦ The program does not compile because the compiler cannot distinguish which xmethod to invoke.


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by abarnes on May 6, 2020

TheDev123

  • Sr. Member
  • ****
  • Posts: 332
Lorsum iprem. Lorsus sur ipci. Lorsem sur iprem. Lorsum sur ipdi, lorsem sur ipci. Lorsum sur iprium, valum sur ipci et, vala sur ipci. Lorsem sur ipci, lorsa sur iprem. Valus sur ipdi. Lorsus sur iprium nunc, valem sur iprium. Valem sur ipdi. Lorsa sur iprium. Lorsum sur iprium. Valem sur ipdi. Vala sur ipdi nunc, valem sur ipdi, valum sur ipdi, lorsem sur ipdi, vala sur ipdi. Valem sur iprem nunc, lorsa sur iprium. Valum sur ipdi et, lorsus sur ipci. Valem sur iprem. Valem sur ipci. Lorsa sur iprium. Lorsem sur ipci, valus sur iprem. Lorsem sur iprem nunc, valus sur iprium.
Answer Preview
Only 25% of students answer this correctly




abarnes

  • Member
  • Posts: 556
Reply 2 on: May 6, 2020
:D TYSM


steff9894

  • Member
  • Posts: 337
Reply 3 on: Yesterday
YES! Correct, THANKS for helping me on my review

 

Did you know?

Approximately 500,000 babies are born each year in the United States to teenage mothers.

Did you know?

The shortest mature adult human of whom there is independent evidence was Gul Mohammed in India. In 1990, he was measured in New Delhi and stood 22.5 inches tall.

Did you know?

Everyone has one nostril that is larger than the other.

Did you know?

Cytomegalovirus affects nearly the same amount of newborns every year as Down syndrome.

Did you know?

More than 50% of American adults have oral herpes, which is commonly known as "cold sores" or "fever blisters." The herpes virus can be active on the skin surface without showing any signs or causing any symptoms.

For a complete list of videos, visit our video library