1. Given an integer variable count, write a statement that displays the value of count on the screen. Do not display anything else on the screen -- just the value of count.
2. What is the output of the following piece of code:
int n = 2;
n++;
System.out.println("n is " + n);
n--;
System.out.println("n is " + n);
3. What will be the value of ans after the following code has been executed?
int ans = 10;
int x = 65;
int y = 55;
if (x >= y)
ans = x + y;
4. What will be the value of x after the following code is executed?
int x = 10;
while (x < 100)
{
x += 10;
}
5. In the following code, what values could be read into number to terminate the while loop?
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter a number: ");
int number = keyboard.nextInt();
while (number < 100 && number > 500)
{
System.out.print("Enter another number: ");
number = keyboard.nextInt();
}