JAVA PRACTICE WORKSHEET
Class 8 · ICSE Board · Computer Applications
Name: _____________________________ Class: 8 ____ Date: ______________
A. Fill in the Blanks
1. Java programs are compiled into __________ code by the compiler.
2. The __________ class is used to accept input from the keyboard in Java.
3. Every statement in Java must end with a __________.
4. The data type used to store a single character is __________.
5. The __________ method of the Scanner class is used to read a whole line of text.
6. A Java program execution always begins from the __________ method.
B. State True or False
(a) Java is a platform-dependent language.
(b) Variable names in Java can begin with a digit.
(c) Java is case-sensitive.
(d) The % operator gives the remainder after division.
(e) A char value is written using double quotes.
C. Short Answer Questions
7. What is the Java Virtual Machine (JVM)? Why is it important?
8. List any three features of Java.
9. What is the difference between a char and a String in Java? Give one example of each.
[Link] any four rules for naming a variable in Java.
[Link] between the following pairs: (a) / and % operators (b) == and =
[Link] is the purpose of the import [Link]; statement?
D. Predict the Output
Find the output of the following code fragments:
int a = 15, b = 4;
[Link](a / b);
[Link](a % b);
int x = 5;
int y = 10;
[Link](x > y);
[Link](x < y && y > 0);
String name = "Rohan";
int age = 13;
[Link](name + " is " + age + " years old.");
E. Programming Problems
Write complete Java programs (with the class, main method, and Scanner where needed) for the following:
[Link] two numbers from the user and display their sum, difference, product, and quotient.
[Link] the radius of a circle and calculate its area and circumference. (Use 3.14 for π)
[Link] the length, breadth, and height of a cuboid and find its volume.
[Link] marks in three subjects and calculate and print the total and percentage (out of 300).
[Link] a number and print whether it is positive, negative, or zero.
[Link] the principal, rate, and time and calculate the Simple Interest using the formula SI = (P × R × T) / 100.
[Link] temperature in Celsius and convert it to Fahrenheit using F = (C × 9/5) + 32.
[Link] a student's name and age, then display a message in the format: "<name> will turn 18 in <n> years."
All the best!