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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started