Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M92399497
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Java

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As