0% found this document useful (0 votes)
99 views

Expression & Assignment Worksheet For Java: A Ac B B X

The document provides a worksheet with mathematical and programming assignments related to variables, data types, expressions, and conversions in Java. It includes questions about defining variables and constants, integer and floating point data types, operator precedence, and converting algebraic equations to Java code.

Uploaded by

Khanjan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views

Expression & Assignment Worksheet For Java: A Ac B B X

The document provides a worksheet with mathematical and programming assignments related to variables, data types, expressions, and conversions in Java. It includes questions about defining variables and constants, integer and floating point data types, operator precedence, and converting algebraic equations to Java code.

Uploaded by

Khanjan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Expression & Assignment Worksheet for Java

You may only use calculators for arithmetic. Do not enter entire expressions. There will be no calculators
permitted for the test/s.

1. Define a variable. 14. Given the following declarations, what is the


2. Define an identifier. result of each of the assignments?
3. A variable can store ____ value/s of its type. int w = 5, y = 9, z = 2;
4. Define a constant.
5. Define an expression. a. z = w * y;
6. Name the four integer data types. b. z += y;
How many bytes are allotted to each? c. y /= z;
7. Name the two floating point data types. d. y %= z;
How many bytes are allotted to each? e. y += y++;
8. What is an escape sequence? f. y += --y;
9. What is operator precedence? 15. Given the following declarations, what is the
10. Why are widening conversions safer than narrowing result of each of each output?
conversions? char a = 'a', b = 'B';
11. What does the new operator accomplish? char c = ' ', d;
12. Given the following declarations, what is the result string s = "This is fun.";
of each of the expressions? int e;
int w = 2, y = 7, z = 12;
System.out.println
a. w * z a. ("a = " + a);
b. w * z + y b. ("a = " + 'a');
c. w * -z c. (a + b);
d. w * --z + y++ d. (s);
e. w * z-- + ++y e. (s.length());
f. w + z * y
g. w – y + z 16. Convert the algebraic equations to Java
h. (w + y) * z equations.
i. y / w
j. y / z a. SA  4rr 2
k. w % y 4
b. V  rr 3
l. y % w 3
13. Given the following declarations, what is the result c. A  s s  a  s  b  s  c 
of each of the expressions? d. D  ( x2  x1 ) 2  ( y2  y1 ) 2
double w = 12.9, y = 3.2;
double z = 12.2;  b  b2  4ac
X
a. w / z
e. 2a
b. z / w
c. w / z – y Hint: Write two equations
d. w – z * y
e. (w – z) * y
f. z / y / w
g. z / (y / w)
h. y % z

/conversion/tmp/scratch/445606321.doc
© 2003, Louis A. Trentini. All rights reserved.

You might also like