What will be the value of x

Assignment Help JAVA Programming
Reference no: EM131590784

1.Consider the following loop which is an inefficient (at best) attempt to increment count 200 times:
for ( k = 0; k < 200; k++);
count++;
Check all true statements (there will be more than one).
Remember: all variables are assumed to be declared prior to the loop, as needed.
A.It has a compiler error because of the extra semicolon.
B.It has a logic error because of the extra semicolon.
C.It has no compiler errors.
D.It has both compiler and run-time errors.

2.At the end of the third (3rd) loop pass of the following loop:
int count = -2;
for (int k = 3; k < 10; k++)
count++;
what is the value of count?
5
3
1
9

3.Consider the statement:
if ( (ans == 'Y' || errors < 5) &&numTries< 10 ) // note uppercase 'Y'
count++;
Which combinations of values results in count being incremented after the statement is complete?
(Select all that apply.)
A.ans = 'N'
errors = 3
numTries = 10
B.ans = 'y' (lower case)
errors = 4
numTries = 5
C.ans = 'Y' (upper case)
errors = 6
numTries = 5
D.ans = 'N'
errors = 5
numTries = 5
E.ans = 'Y' (upper case)
errors = 100
numTries = -1

4.For the two code segments below:
Segment A
int q = 5;
switch(q)
{
case 1:
System.out.println(1);
case 2:
System.out.println(2);
case 3:
System.out.println(3);
case 4:
System.out.println(4);
case 5:
System.out.println(5);
default:
System.out.println("default");
}
Segment B
q = 4;
switch(q)
{
case 1:
System.out.println(1);
case 2:
System.out.println(2);
case 3:
System.out.println(3);
case 4:
System.out.println(4);
case 5:
System.out.println(5);
default:
System.out.println("default");
}

Which of the following statements is true?

A.The output for Segment A is:
default

B.The output for Segment B is:
4

C.The output for Segment B is:
45default

D.The output for Segment A is:
5
default

5. What will be the value of x after the following code is executed?
int x = 10;
while (x < 50)
{
x -= 10;
}

A.40
B.50
C.60
D.10

6. What output will be produced by the following code?

intevenNumber = 2;
do
{
System.out.println(evenNumber);
evenNumber += 2;
}while(evenNumber< 10);

A. 2,4,6,8,10

B.2,4,6,8

C.2,4,6

D.0,2,4,6,8,10

7. Consider the following snippet of code:
intfirstNum = 5;
intsecondNum = firstNum++;
intthirdNum = 6 * (++firstNum);

What values are stored in firstNum and secondNum after these lines are executed

A.secondNum will contain 6 and firstNum will contain 5.

B.secondNum will contain 5 and firstNum will contain 6.

C.secondNum will contain 4 and firstNum will contain 5.

D.secondNum will contain 5 and firstNum will contain 4.

Reference no: EM131590784

Questions Cloud

What is wrong with the given snippet of code : What is wrong with the given snippet of code? Rewrite it so it produces the correct output - How many times might the following code print out grape?
Journalize transactions and closing entries for net income : Journalize the transactions and the closing entries for net income and dividends. (Credit account titles are automatically indented when amount is entered
Define the investigative effort against terrorism : What contrary arguments can be made that this approach may narrow the investigative effort against terrorism, resulting in more missed cases
Cost of capital estimate to leave the decision unchanged : Calculate the IRR and use it to determine the maximum deviation allowable in the cost of capital estimate to leave the decision unchanged.
What will be the value of x : Consider the following loop which is an inefficient (at best) attempt to increment count 200 times - What will be the value of x after the following code is exe
Apply the principles of multiple intelligences : If you were to assign multiple intelligences to yourself, what would it be, would you assign yourself more than one area, and why?
What is the firms market value of equity : What is the firms Market Value of Equity (in Millions of $ rounding to 1 decimal)?
Calculate the average binding energy : Photons of blue light are emitted when hydrogen's electron drops from the fifth energy level to a lower energy level. What is the lower energy level?
Prepare and submit a form 1040 for norman and leslie beber : Prepare and submit a Form 1040 for Norman and Leslie Beber for 2014. The Bebers do not donate to the presidential election campaign

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