Values and data types/Operators in Java
Output based worksheet
1) What will be the output of the following snippets
a) [Link](“My details :\n” + ”Name: Adharva \n”+”class : IX \n”+” Section: C”);
b) [Link](“Computer \t Applications”);
c) [Link](“Java is programming language \n developed \n by \t \'James
Gosling\' ");
2) Identify the variable data types
a) 9731456564
b) 460E4
c) 12.54
d) ‘a’
e) “computer”
f) 1234.567891
3) State whether the following identifiers are correct, if
not give reasons
a) _age
b) Total-marks
c) 45.
d) .78
e) ‘Yes’
f) “G”
g) “computer\’s login”
4) Convert the following mathematical expression to java statement
a)
b) √2as+u2
c) |ax5 + bx3 + c|
d) √(3x + x2) / (a + b)
e) a3+b3+2ab+2bc+2ca
5) Identify the statements listed below as assignment, increment,
method invocation or object creation statements.
(i) [Link](“Java”);
(ii) costPrice = 457.50;
(iii) Car hybrid = new Car();
(iv) petrolPrice++;
6) Name the operators listed below
i) < ii) ++ iii) && iv) ?:
7) Classify the following as primitive or non-primitive data types:
(i) char
(ii) arrays
(iii) int
(iv) classes
8) State the total size in bytes, of the arrays a [4] of char data type and p [4] of float data type.
9) Increment and decrement questions
a) If x= 8;find y = ++x +5;
b) If a=48; find a = a++ + ++a;
c) If m=12; Find n = m++ * 5 + --m;
d) If a = 12,b=8 Find a * = ++a/6 + b++ % 3;
e) int k = 5, j = 9;
k += k++ – ++j + k;
[Link]("k= " +k);
[Link]("j= " +j);
f) int x=4;
x+ = (x++) + (++x) +x;
g) int x = 5;
x = x++ * 2 + 3 * –x;
h) What is the value of x1 if x=5 ?
x1=++x – x++ + –x
i) y += ++y + y– + –y; when int y = 8.
j) a+=a++ + ++a + -–a + a-– ; when a = 7