Provide the definition of an if-else statement identify


Assignment

1) In Java, a data structure is a particular way of organizing data so that it can be used efficiently. An array is a Java data structure. Define an Array and why you would use one. Provide an example that is not from the text.

What is the output of the following array code fragment:

int[] egArray = { 2, 4, 6, 8, 10, 1, 3, 5, 7, 9 };
for ( int index= 0 ; index < 5 ; index++ )
System.out.print( egArray[ index ] + " " );

• 2 4 6 8
• 2 4 6 8 10
• 2 4 6 8 10 1
• 2 4 6 8 10 1 3 5 7 9

2) Java provides three repetitions structures: while, do while and for. These statements are also known as loops. When would you use a looping statement? Share an example where a looping statement is needed.

Consider the Java code below, indicate the output that will be produced:

final int MIN = 10, MAX = 20; int num = 15;
while (num < MAX)
{
num = num + 1;
System.out.println (num):
}

3) Provide the definition of an If-Else statement. Identify when you would you use an If-Else statement in programming.

Consider the Java code below:
if (x > 5)
{
System.out.println("A");
if (x < 10)
System.out.println("B");
}
else
System.out.println("C");
What is displayed if x is:
• 4;
• 5;
• 6;
• 9;
• 10;
• 11.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Provide the definition of an if-else statement identify
Reference No:- TGS02726363

Now Priced at $45 (50% Discount)

Recommended (91%)

Rated (4.3/5)