Home / Programming MCQs / JAVA MCQs / Question

M

Q. What is the value of k after the following code fragment?~~~int k = 0;~~~int n = 12~~~while (k < n)~~~{~~~k = k + 1;~~~}

You might wonder that how this value will be 12. Since k is initialised with 0 and n with 12. Now while loop checks whether value of k is smaller than n or not. So this condition will be true unless te value of k becomes 11. Now the value of k is 11 and the condition is true to while loop will be executed and now k will become 12. So the final value of k will be 12.

You must be Logged in to update hint/solution

Predict the output of following Java program

'this' keyword in java is ___.

Which method of System class is used to copy array?

Which is the Microsoft solution for providing dynamic Web content?

Which class is a library of functions to perform arithmetic operations of BigInteger and BigDecimal?

How to compile java code in command prompt?

When you divide a number of type double by zero then the result will be __________.

## Discusssion

Login to discuss.