JAVA WORKSHEET ANSWERS
QUESTION 1
a. Scanner class is used to accept input from user. Package: [Link]
b. Fill in the blanks:
I. Class
II. Object
III. true / false
IV. Object
V. Constants
VI. Data types
c. Output:
m = 20
d. Infinite loop
e. Nesting of loops means placing one loop inside another.
Example:
for(int i=1; i<=3; i++){
for(int j=1; j<=2; j++){
[Link](i+" "+j);
}
}
QUESTION 2
a. if → used for complex conditions
switch → used when same variable is compared with multiple values
b. Correct code:
switch(n){
case 1: a=11; b=22; break;
case 2: c=33; break;
default: d=44;
}
c. float range: -3.4 × 10^38 to +3.4 × 10^38
d. Class → blueprint
Object → instance of class
QUESTION 3
a. n = 14
b. byte < char < int < double
c. (i) 121.0
(ii) [Link]()
d. Output: a b c d