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?

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M92399368
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Java

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

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 ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

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 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 ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

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 ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

  • 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