Question: 1. Consider the below code fragment. int [] data = {2,1,3,3,3,6}; int count = 0, item = 1; for (int j = 0; j =

1. Consider the below code fragment.

int [] data = {2,1,3,3,3,6}; int count = 0, item = 1; for (int j = 0; j <= data.length-1; j++)

if (data[j] != item) count++;

System.out.print(" ==> Count = " + count);

What the code is doing?

What is the output?

2. Consider the below code fragment.

int [] data = {2,1,3,3,3,6}; int count = 0, item = 1; for (int j = data.length-1; j >= 0; j--)

if (data[j] == item) count++;

System.out.print(" ==> Count = " + count);

What the code is doing?

What is the output?

3. Consider the below code fragment

push(10);

push(20);

push(30);

pop();

push(40);

Illustrate and show the current content of the array.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!