What will be the value of x after the following code is executed?
int x = 5;
while (x <50)
{
x += 5;
}
a) 50
b) 45
c) Infiniteloop
d) 55
Given the following code segment: Scanner in = new Scanner (System.in);
boolean done = false;
while (!done)
{
int input = in.next();
if(input.equalsIgnoreCase("q"))
done = false;
}
What will cause the loop to terminate?
a) When the user enters -1
b) The loop will never terminate
c) When the user enters q or Q
d) When the user enters done
How many times will this for loop execute?
for (int i = 2; i < 10; i +=3)
{
...
}
a) 6
b) 3
c) 5
d) 4
A package is any program with two or more classes: True or False
Que1: What will be the value of x after the following code is executed?
int x = 5;
while (x <50)
{
x += 5;
}
a) 50
b) 45
c) Infiniteloo
Answer -: Option A - 50
![1 public class Main 3 public static void main(String[] args) f 4 int x = 5; while (x <50) 7 8 9 10 x += 5; System , .out.println(x); 12 inp 50 Program finished with exit code 0 Press ENTER to exit console.L](http://img.homeworklib.com/questions/bbe19000-bc5a-11ea-bcc1-8f003d8ff917.png?x-oss-process=image/resize,w_560)
Question 2 : Given the following code segment: Scanner in = new Scanner (System.in);
boolean done = false;
while (!done)
{
int input = in.next();
if(input.equalsIgnoreCase("q"))
done = false;
}
What will cause the loop to terminate?
a) When the user enters -1
b) The loop will never terminate
c) When the user enters q or Q
d) When the user enters done
Answer : Option B - The loop will never terminate

Question 3 : How many times will this for loop execute?
for (int i = 2; i < 10; i +=3)
{
...
}
a) 6
b) 3
c) 5
d) 4
Answer : Option B - 3 times

Question 4: A package is any program with two or more classes:
True or False
Answer : True
Package is a collection of related classes that we are using in our programming by reusability of the oops concepts.
What will be the value of x after the following code is executed? int x =...
1. What will be the value of x after the following code is executed? int x = 10, y = 20; while (y < 100) { x += y; } A. 90 B. 110 C. 210 D. This is an infinite loop 2. If a superclass has constructor(s): A. then its subclass must initialize the superclass fields (attributes). B. then its subclass must call one of the constructors that the superclass does have. C. then its subclass does not inherit...
What will be the value of ans after the following code has been executed? int x = 90, y = 55, ans = 10; if ( x == y); a. 10 b. No value, no syntax error c. 145 d. ans *= 2;
What is the value of y after the following code is executed? int x = 20, y = 30; do { int z; z = 3 * ( y
What will be the value of x after the following code is executed? How many times will the following do-while loop be executed?
Which of the following verifies that the user enters a positive integer value? A. int num = 0: Scanner s = new Scanner(System.in): do { System.out.print("Enter a positive integer: "): num = s.nextlnt(): } while (num = = 0): B. int num=0: Scanner s = new Scanner(System.in): do { System.out.print("Enter a positive integer: "): num = s.nextlnt(): } while (num % 2 ! = 0): C. int num=0: Scanner s = new Scanner(System.in): do { System.out.print("Enter a positive integer: "):...
What is printed when the following code is executed? #include <stdio.h> int main() { for (int i=3, j=5; i>=0; i-=2, j+=j*i) { printf("%d", j); منم }
Question 9 (1 point) Given that the following code has executed, what is the value of mystery? If your answer is a string, surround it with single quotes. If it is a number, just write the number. If it is a Boolean, write either True or False with no quotes. If this code won't work (crashes or infinite loop), write error with no quotes. string1 = 'I heart mathematics.' mystery' i=0 while True: 130 mysterystringl [i] if ilen (stringl)1: break
2. What is the value of x alter the following code is executed # include<iostream> using namespace std; int main int t-0, c- 0,x-3; while (c < 4) t=t+x; cout << x return 0; a) 3 b) 21 c) 24 d) 48 3. What is the output of the following code? # include<iostream> using namespace std; int main0 int a- 3; for (int i 5; i >0; i) a a+i cout << a << “ “ return 0; d) 8...
What is the output, to the console, once the following code has executed? int collatz(int value) { if(value % 2 ==0) return value /2; else return value * 3+1; } int main() { int currentValue=1; int i; for (i=0; i<5; i++) { printf("%d\n", currentValue); currentValue= collatz(currentValue); } return 0; }
Complete the following code snippet using java so that it finds the sum of doubles the user inputs. Your answer should be a while loop with a condition that needs to be true if the user inputs a double. Your answer should be a single while loop. Scanner scnr = new Scanner(System.in); int sum = 0;