What is the resulting value of x after for-loop terminates

Assignment Help JAVA Programming
Reference no: EM131695259

Assignment

QUESTION 1
In Java, the symbol "=" and the symbol "==" are used synonymously (interchangeably).
True
False

QUESTION 2
Given the following code, where x = 0, what is the resulting value of x after the for-loop terminates?
for (int i=0;i<5;i++)
x += i;

A.0

B.4

C.5

D.10

QUESTION 3
The following loop is syntactically valid.
for (int j = 0; j < 1000; j++) j--;

True
False

QUESTION 4
It is possible to convert any type of loop (while, do, or for) into any other.
True
False

QUESTION 5
If x is an int where x = 0, what will x be after the following loop terminates?
while (x < 100)
x *= 2;
2

64

100

128

none of the above, this is an infinite loop

QUESTION 6
Consider the following switch statement where x is an int. If x is currently equal to 3, what will the value of x be after the switch statement executes?
switch (x)
{
case 3 : x += 1;
case 4 : x += 2;
case 5 : x += 3;
case 6 : x++;
case 7 : x += 2;
case 8 : x--;
case 9 : x++;
}

A- 6

B- 11

C- 10

D- 12

QUESTION 7
A switch statement must have a default clause.
True
False

QUESTION 8
How many times will the following loop iterate?
int x = 0;
do {
System.out.println(x);
x++;
} while (x > 0 && x<10);

A.1 timeB.9 timesC.10 timesD.11 times

QUESTION 9
Control in a switch statement jumps to the first matching case.
True
False

QUESTION 10
The following for-loop is an infinite loop.
int i; for (int j = 0; j < 1000; ) i++;

True
False

QUESTION 11
Assume that count is 0, total is 20 and max is 1. The following statement will do which of the following? if (count != 0 && total / count > max) max = total / count;
A- The condition short circuits and the assignment statement is not executed
B- The condition short circuits and the assignment statement is executed without problem
C- The condition does not short circuit causing a division by zero error
D- The condition short circuits so that there is no division by zero error when evaluating the condition, but the assignment statement causes a division by zero error

QUESTION 12
The break statement does which of the following?

A- ends the program

B- transfers control out of the current control structure such as a loop or switch statement

C- ends the current line of output, returning the cursor

D- denotes the ending of a switch statement

E- indicates the end of line when using System.out.print

QUESTION 13
The do loop differs from the while loop in that

A- the while loop will always execute the body of the loop at least once

B- the do loop will always execute the body of the loop at least once

C- the do loop will continue to loop while condition in the while statement is false and the while loop will continue to loop while the condition in the while statement is true

D- the while loop will continue to loop while condition in the while statement is false and the do loop will continue to loop while the condition in the while statement is true

E- none of the above, there is absolutely no difference between the two types of loops

QUESTION 14
Of the following if-statements, which one correctly executes three instructions if the condition is true?

if (x < 0)
a = b * 2;
y = x;
z = a - y;

{
if (x < 0)
a = b * 2;
y = x;
z = a - y;
}if { (x < 0)
a = b * 2;
y = x;
z = a - y ;
}

if (x < 0)
{
a = b * 2;
y = x;
z = a - y;
}

QUESTION 15
How many times will the following loop iterate?
int x = 0;
while (x > 0 && x<10)
{
System.out.println(x);
x++;
}

A.0 times

B.1 time

C.9 times

D.10 times

QUESTION 16
Which of the sets of statements below will add 1 to x if x is positive and subtract 1 from x if x is negative but leave x alone if x is 0?
if (x > 0) x++;
else x--;
if (x > 0) x++;

else if (x < 0) x--;

if (x > 0) x++;

if (x < 0) x--;

else x = 0;

if (x == 0) x = 0;

else x++;

x--;

E) x++;

x--;

QUESTION 17
Assume that x and y are int variables with x = 5, y = 3, and a and d are char variables with a = 'a' and d = 'A', and examine the following conditions:
Condition 1: (x < y && x > 0)
Condition 2: (a != d || x != 5)
Condition 3: !(true && false)
Condition 4: (x > y || a == 'A' || d != 'A')

All 4 Conditions are true, Only Condition 2 is true, Condition 2 and Condition 4 are true only, Conditions 2, 3 and 4 are all true, Condition 1 is not, All 4 Conditions are false

QUESTION 18
You might choose to use a switch statement instead of nested if-else statements ifthe variable being tested might equal one of several hundred int valuesthe variable being tested might equal one of only a few int valuesthere are two or more int variables being tested, each of which could be one of several hundred valuesthere are two or more int variables being tested, each of which could be one of only a few valuesnone of the above, you would never choose to use a switch statement in place of nested if-else statements under any circumstance.

QUESTION 19
The statement if (a >= b) a++; else b--; will do the same thing as the statement if (a < b) b--; else a++;.
True
False

QUESTION 20
Consider the following switch-statement where x is an int. If x is currently equal to 5, what will the value of x be after the switch statement executes?

switch (x)
{
case 3 : x += 1;
case 4 : x += 2;
case 5 : x += 3;
case 6 : x++;
case 7 : x += 2;
case 8 : x--;
case 9 : x++;
}

A.8

B.6

C.11

D.5

Reference no: EM131695259

Questions Cloud

Types of self-healing personalities : Briefly describe the two broad types of self-healing personalities. How do behaviors provide a link between personality and health?
Differences between fob shipping point and destination : Explain the differences between FOB shipping point and FOB destination. Be certain to address who pays for the shipping costs and who owns the goods
What is probability that a rises-b does not rise in price : Alison has all her money invested in two mutual funds, A and B. What is the probability that A rises and B does not rise in price?
Saving rate actually not good for an economy : Saving is a good thing, right? Under what circumstances is an increased saving rate actually not good for an economy?
What is the resulting value of x after for-loop terminates : Given the following code, where x = 0, what is the resulting value of x after the for-loop terminates? what will x be after the following loop terminates?
Estimate commission revenues for stubs-r-us for coming year : Stubs-R-Us is a local event ticket broker. Required: Estimate commission revenues for Stubs-R-Us for the coming year
What is the level of desired investment expenditure : a) What is the level of desired investment expenditure (I) and government purchases (G)?
Your own experiences with management initiative : Your Own Experiences with “Management Initiative”. Focus on the key concepts and lessons learned from Kirton’s Management Initiative
What are the reactions of the countries in the region : Why China has initiated the One Belt One Road project, what implications it has for the regional security. What are the reactions of the countries in the region

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd