153k views
2 votes
In the code segment below, assume that the int variable n has been properly declared and initialized. The code segment is intended to print a value that is 1 more than twice the value of n.

/* missing code */

System.out.print(result);

Which of the following can be used to replace /* missing code */ so that the code segment works as intended?

int result = 2 * n;
result = result + 1;
int result = n + 1;
result = result * 2;
int result = (n + 1) * 2;


I only
A


II only
B


III only
C


I and III
D


II and III
E

























































Submit

User Hadvig
by
5.2k points

1 Answer

6 votes

Answer:

A. I only

Step-by-step explanation:

int result = 2 * n;

result = result + 1;

User Jdscolam
by
4.7k points