What is y after the given switch statement is executed

Assignment Help C/C++ Programming
Reference no: EM131097945

1. _____ is interpreted.

Pascal
Java
C++
Ada
C

2. What is the printout of the following code?

double x = 5.5;
int y = (int)x;
System.out.println("x is " + x + " and y is " + y);

x is 5.5 and y is 5.0
x is 5.5 and y is 5
x is 5 and y is 6
x is 6 and y is 6
x is 6.0 and y is 6.0

3. What is the value of (double)(5/2)?

2.0
2
3.0
2.5
3

4. Suppose x=10 and y=10, what is x after evaluating the expression (y >= 10) || (x++ > 10)?

9
11
10
Illegal expression

5. What is y after the following switch statement is executed?

x = 3;
switch (x + 3) {
case 6: y = 0;
case 7: y = 1;
default: y += 1;
}

1
4
2
3

6. Analyze the following statement.

double sum = 0;
for (double d = 0; d<10;) {
d += 0.1;
sum += sum + d;
}

The program compiles and runs fine.
The program runs in an infinite loop because d<10 would always be true.
The program has a compile error because the control variable in the for loop cannot be of the double type.
The program has a compile error because the adjustment is missing in the for
loop.

7. What is the value in count after the following loop is executed?

int count = 0;
do {
System.out.println("Welcome to Java");
} while (count++ < 9);
System.out.println(count);

10
9
0
8
11

8. (char)('a' + Math.random() * ('z' - 'a' + 1)) returns a random character _____

between 'b' and 'z'.
between 'a' and 'y'.
between 'a' and 'z'.
between 'b' and 'y'.

9. What is the output of the following code?

public class Test {
public static void main(String[ ] args) {
int[ ] x = {120, 200, 016};
for (int i = 0; i < x.length; i++)
System.out.print(x[i] + " ");
}
}

120 200 16
120 200 20
120 200 14
016 is a compile error. It should be written as 16.

10. Analyze the following code.

public class Test {
public static void main(String[ ] args) {
int[ ] x = new int[5];
int i;
for (i = 0; i < x.length; i++)
x[i] = i;
System.out.println(x[i]);
}
}

The program displays 4.
The program displays 0 1 2 3 4.
The program has a runtime error because the last statement in the main method causes ArrayIndexOutOfBoundsException.
The program has a compile error because i is not defined in the last statement in the main method.

Reference no: EM131097945

Questions Cloud

Consumes no more calories than his calorie limit : Quincy lives on ding dongs and seafood salads. The price of ding dongs is 1 dollar per bag and the price of seafood salads is 4 dollars each. Quincy allows himself to spend no more than 23 dollars a day on food. He also restricts his consumption to 3..
Second city bank account : If you made a $67,000 deposit in each bank, how much more money would you earn from your Second City Bank account at the end of 9 years? (Do not round intermediate calculations and round your answer to 2 decimal places, e.g., 32.16.)
Determine what the equivalent annual benefits : In 2012, Brazil began construction of the Belo Monte hydroelectric dam on the Xingu River (which feeds the Amazon River). The project is funded by a consortium of investors and is expected to cost $11 billion. It will begin producing electricity in 2..
Difintions of moral and natural evil from muslim concept : 1- what are the difintions of moral and natural evil from Muslim concept? 2- describe how blam and our emotional responses are diffrent when confronted with moral evil and natural evil respective ?
What is y after the given switch statement is executed : What is y after the following switch statement is executed? What is the value in count after the following loop is executed? What is the printout of the following code?
When long-run average costs are rising : When long-run average costs are rising, short-run and long-run marginal costs: (a) Intersect above average costs; (b) Intersect below average costs; (c) Intersect at the level of average costs; (d) Never intersect.
Find and present a specific example of impact : Find and present a specific example of the impact of each type of investment risk. In each case, how did the type of risk affect investment performance?
Cigarette consumption and consumer spending on cigarettes : According to studies undertaken by the US Department of Agriculture, the price elasticity of demand for cigarettes is between – 0.3 and – 0.4 and the income elasticity is about + 0.5. Suppose Congress, influenced by studies linking cigarette smoking ..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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