What output will be produced by the code

Assignment Help JAVA Programming
Reference no: EM131590655

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?

int evenNumber = 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:
int firstNum = 5;
int secondNum = firstNum++;
int thirdNum = 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: EM131590655

Questions Cloud

What fairness has to do with performance management systems : Explain what fairness (i.e., organizational justice) has to do with performance management systems. How the function of performance management can affect goals.
Find elements of the existing network : Scenario: In analyzing the network performance at the Bedford Campus, one issue that has come to light is the insufficient network and server infrastructure.
Point between the two charge : Draw Electric vectors for both charges at a point between the two charge, and also at a point outside of the two charges on the right side.
The impact multiculturalism has on globalization : The difference between cultural diversity and racial diversity, The impact multiculturalism has on globalization
What output will be produced by the code : Consider the loop which is an inefficient (at best) attempt to increment count 200 times - What values are stored in firstNum
Average force on the core to reduce : The average force on the core to reduce the air gap will be?
What is the amount of income tax provision : What is the amount of income tax provision in the two most recent years on the income statement?
Discuss the nature of electromagnetic radiation : Discuss the nature of electromagnetic radiation, and tell how that radiation transfers energy and information through interstellar space.
Describe some of the change the criminal justice system : Describe some of the change(s) the criminal justice system as a whole has made in response to the issue you selected.

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