Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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

Java, Programming

  • Category:- Java
  • Reference No.:- M92503956
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Java

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

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

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

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

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

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

  • 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