How Can I Trace A Java Program . Please Give Me Step by Step
Process
//consider the follwing program part
for(int k = 0; k < 10; k++);
System.out.println("hi");
int k = 9
while(k < 10)
{
System.out.println("world");
k++;
}
//now lets trace the program as follows
start, at the for loop, k is initialized to 0 with a scope
local to the for loop itself.
k = 0
Is it less than 10? yup, so we enter the loop.
Next, we have output,
hi.
Since there is no brackets, the for loop applies only to the
very next line. In this case, the output. So, return to the
top of the loop, k increments by 1
k = 1
and we proceed again since 1 < 10.
The output "hi" is printed again.
Go back to the top of the loop, increment k, and recheck the
loop condition of k < 10. The above cycle repeats until k is
incremented and equals 10. Since 10 is not less than 10,
exit the for loop.
:
k = 10
next
Now, declare an integer k to be equal to 9.
k = 9
Note it has local scope to this part of the program but,
since the for for loop previous one is gone from memory, so
too is the integer k that it (the loop) declared.
Thus, there is no conflict. So, an integer variable k (one
different from the last) is now = 9
Check the while boolean condition and k is less than 10 so
enter the while loop.
Next, print the output
"world"
Next, increment k by 1 ("k++") so
k = 10
Check the while loop conditional again but, this time, it's
false. k is not less than 10 anymore. So, exit the while loop.
| Is This Answer Correct ? | 3 Yes | 5 No |
1+(2*3)+(4*5*6)+(7*8*9*10)+... specified input value
Is there any static classes are in java give some examples
Program to print map of India in java.
Bubble Sort. java thereafter the user will be asked to inpout the size of the list,sort the list in ascending order and display the sorted list in a horizontal manner???
Write a program to convert a decimal number to binary form?
I am trying to pass the string firstName from a Servlet called SampleServet. I am running this on eclipse and it tells me that "the value for annotation attribute must be a constant expression. I don't understand why it is giving me this error. @PersonAnnotation(name = SampleServlet.firstName) public class AnnotationClass{
Why we r using String args[] in main() even though v r not passing any arguments in command line?
write a program that will ask the user to enter a number n and display the product of all numbers from 1 to n.
How Can I Trace A Java Program . Please Give Me Step by Step Process
How to create and run runnable jar file of a Java Project.
4 Answers HCL, TCS, Tech Mahindra, US Consulate, Wipro,
How can we get the details for printing the employee details at run time using JDBC connectivity? can u provide the coding for that? Its urgent?
Design a program using one-dimensional array that determines the highest value among the eight input values from a user. Display the difference of each value from the highest to the lowest.