Practice Worksheet 2
Practice Worksheet 2
1. _________ are tokens that convey a special meaning to the java compiler.
a. operators
b. keywords
c. constants
d. identifiers
5. _______ are remarks written by the programmer and are ignored by the compiler.
a. escape sequence
b. comments
c. constants
d. identifiers
6. += is an unary operator
a. true
b. false
10. -127 is the smallest value that can stored in a byte datatype
a. true
b. false
a. 6
b. 5
c. 7
d. 4
a. -21
b. -18
c. -20
d. -19
4. Given a=5,b=6,c=7;
a %= a++ * ++b / c++ + ++c;
a. 3
b. 4
c. 5
d. 6
a. true
b. false
c. 4
d. 10
a. oneten11
oneten(1+10)
b. oneten110
oneten11
c. oneten110
onten110
d. oneten11
11oneten
8. Write the most appropriate datatype type for each of the following literals
1. True
2. T
a. 1. boolean 2. char
b. 1. String 2. int
c. 1. boolean 2. int
d. 1. String 2.char
9. Which is the most appropritate ternary operator to print the value of the biggest number out of 2
numbers
a. 2,4
b. 16,32
c. 8,64
d. 16,24
7. Write the output of the following , given that variable a is -99 initially
a. --a>a-- b. --a<-99
8. Correct the following java statements , given the following variable declaration int a, b; short s,t; float f,
double d;
a. t = a;
b. s = a/b;
c. f = f/d;
d. a=f*d
10. Given x=3 , y=-2 , z=5 , Write the values of x,y,z after the expression is executed.
a. x*=--y*z++;