0% found this document useful (0 votes)
4 views1 page

Java Worksheet Answers and Concepts

The document provides answers to a Java worksheet, covering topics such as the Scanner class, loops, conditional statements, and data types. It includes specific code examples and explanations of concepts like nesting loops and the differences between classes and objects. Additionally, it outlines the range of float data types and the order of primitive data types in Java.

Uploaded by

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

Java Worksheet Answers and Concepts

The document provides answers to a Java worksheet, covering topics such as the Scanner class, loops, conditional statements, and data types. It includes specific code examples and explanations of concepts like nesting loops and the differences between classes and objects. Additionally, it outlines the range of float data types and the order of primitive data types in Java.

Uploaded by

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

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

You might also like