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 69 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
Wow, this really help


kusterl

  • Member
  • Posts: 315
Reply 3 on: Yesterday
Great answer, keep it coming :)

 

Did you know?

Approximately one in four people diagnosed with diabetes will develop foot problems. Of these, about one-third will require lower extremity amputation.

Did you know?

After 5 years of being diagnosed with rheumatoid arthritis, one every three patients will no longer be able to work.

Did you know?

After a vasectomy, it takes about 12 ejaculations to clear out sperm that were already beyond the blocked area.

Did you know?

Pubic lice (crabs) are usually spread through sexual contact. You cannot catch them by using a public toilet.

Did you know?

There are immediate benefits of chiropractic adjustments that are visible via magnetic resonance imaging (MRI). It shows that spinal manipulation therapy is effective in decreasing pain and increasing the gaps between the vertebrae, reducing pressure that leads to pain.

For a complete list of videos, visit our video library