• Home
  • Textbooks
  • Introduction to Programming with Java: A Problem Solving Approach
  • Type Details and Alternate Coding Mechanisms

Introduction to Programming with Java: A Problem Solving Approach

John S. Dean, Raymond H. Dean

Chapter 11

Type Details and Alternate Coding Mechanisms - all with Video Answers

Educators


Chapter Questions

01:12

Problem 1

For each integer data type, how many bits of storage are used?

Shelby Mohamed
Shelby Mohamed
Numerade Educator
03:31

Problem 2

How would you write the decimal constant, $1.602 \times 10^{-19},$ as a double?

Ruby P
Ruby P
Numerade Educator
01:54

Problem 3

What is the approximate precision (number of accurate decimal digits) of each of the floating-point types?

Kim Trang Nguyen
Kim Trang Nguyen
Numerade Educator
03:58

Problem 4

How many distinct characters are identified by the basic ASCII character set?

Anthony Ramos
Anthony Ramos
Numerade Educator
01:13

Problem 5

What number can you add to an uppercase letter char variable to convert it to lowercase?

Ernest Castorena
Ernest Castorena
Numerade Educator
03:11

Problem 6

Assume the declaration:
public final double $\mathrm{C}=3.0 \mathrm{E} 10 ;$ // speed of light in $\mathrm{cm} / \mathrm{sec}$
Write a Java print statement that uses a cast operator to display the value of $c$ in this format:
\[30000000000\]

Ernest Castorena
Ernest Castorena
Numerade Educator
06:11

Problem 7

Will this statement be OK or will it generate a compile-time error? (OK / error)
float price $=66$

Anas Venkitta
Anas Venkitta
Numerade Educator
06:11

Problem 8

Will this statement be OK or will it generate a compile-time error? (OK / error) boolean done $=(\text { boolean }) \quad 0$

Anas Venkitta
Anas Venkitta
Numerade Educator
00:55

Problem 9

Will this statement be OK or will it generate a compile-time error? (OK / error)
float price $=98.1$

Aditya Sood
Aditya Sood
Numerade Educator
04:40

Problem 10

What is the value of $z$ after these statements execute?
\[\begin{array}{l}\ln t \quad z, \quad x=3 ; \\z=--x ; \\z+=x--i\end{array}\]

Victoria Dollar
Victoria Dollar
Numerade Educator
01:22

Problem 11

Write one Java statement that makes $w, x,$ and $y$ all equal to the current value of $z$.

Adriano Chikande
Adriano Chikande
Numerade Educator
01:05

Problem 12

Suppose x equals $0.43 .$ Given the following switch statement heading, what does the switch heading's controlling expression evaluate to?
\[\text { switch }\left(x>0.67 \quad ? \quad ' \mathrm{H}^{\prime} \quad: \quad\left(x>0.33 \quad ? \quad^{\prime} \mathrm{M}^{\prime} \quad: \quad \text { ' } \mathrm{L}^{\prime}\right)\text { ) }\right.\]

JH
J Hardin
Numerade Educator
01:07

Problem 13

Assume this:
\[\begin{array}{l}\text { int } a=2 ; \\\text { int } b=6 ; \\\text { float } x=8.0 f\end{array}\]
Evaluate each of the following expressions, using these guidelines:
As shown in Section $11.8,$ put each evaluation step on a separate line and use the $\Rightarrow$ symbol between steps.
Evaluate each expression independently of the other expressions; in other words, use the above assumed values for each expression evaluation.
: Expression evaluation problems can be tricky. We encourage you to check your work by running test code on a computer.
If there would be a compilation error, specify "compilation error."
$\begin{array}{llllll}\text { a) } a & + & 25 & / & (x+2)\end{array}$
b) $7+a *--b / 2$
$\mathbf{c}) a *--b \quad / 6$
d) $a+b++$
$\mathbf{e}) a-(b=4) 87$
f) $b=x=23$

Derek Follett
Derek Follett
Numerade Educator
01:21

Problem 14

Assume expr 1 and $e \times p r 2$ are expressions that evaluate to boolean values. Assume that expril evaluates to true. When the computer evaluates each of the following expressions, will it evaluate expr $2 ?$ If yes, just say "yes." If no, explain why, and use the term "short-circuit evaluation" in your explanation.
a) expri || expr 2
b) expri \&\& expr2

JH
J Hardin
Numerade Educator
01:21

Problem 15

Assume this:
\[\begin{array}{l}\text { int } a=2 ; \\\text { boolean flag = true }\end{array}\]
Evaluate the following expression:
\[a<3 \quad|| \text { flag } \delta \& \quad ! \text { flag }\]

JH
J Hardin
Numerade Educator
03:07

Problem 16

Assume that the following code fragment is inside of a program that compiles successfully. What does the code fragment print? Hint: This is a trick question. Study the code carefully.

SS
Sarvesh Somasundaram
Numerade Educator
01:26

Problem 17

Usually, you should avoid using break except in switch statements because using break statements forces readers to look for termination conditions inside loop bodies. (T / F).

Prashant Bana
Prashant Bana
Numerade Educator
03:07

Problem 18

Assume that the following code fragment is inside of a program that compiles successfully. What does the code fragment print?

SS
Sarvesh Somasundaram
Numerade Educator
00:59

Problem 19

What is the hexadecimal symbol for the decimal number $13 ?$

Ahmad Reda
Ahmad Reda
Numerade Educator
00:20

Problem 20

The Unicode values for characters are the same as the ASCII values in the range $0 \times 00$ to $0 x$ FF. $(T / F)$.

Mohamed Mohamed
Mohamed Mohamed
Numerade Educator