Class 8 JAVA Revision Worksheet
*MCQ:
1. Which one is not a type of comment in JAVA?
a. Single b. Double c. Multiline d. Documentation
2. Which of the following is not a primitive data type?
a. int b. Float c. char d. String
3. Which of the following is not a token?
a. Keyword b. Operator c. Variable d. Separators
4. If int a=27,b=4,c=0; then c = a%b; results in:
a. 2 b. 3 c. 4 d. 6
5. It indicates that the main method is invoked directly without creating an object of the class
containing the main method.
a. public b. static c. void d. none
*True/False:
1. The output of a++ will be 1, if int a = -1. ( )
2. The relational operators always result in terms of 'True' or 'False'. ( )
3. Given: int m=5; m*=5 then the value stored in m results in 55. ( )
4. The statement (a>b)&&(a>c) uses a logical operator. ( )
5. The statement p+=5 means p=p*5. ( )
*Write the Java expressions for the following:
1. z = 5x2 + 2yx + y ______________________________________________________
2. m = a2 + b2 / (a + b) ______________________________________________________
3. s = ut + (1/2)at2 ______________________________________________________
*Predict the output with an explanation:
1. int c = (3<4)? 3*4:3+4; __________________
2. int a = 18; int b = 12;
boolean t = (a > 20 && b < 15)? true : false; __________________
3. int k=5,j=9;
k+= k++ - ++j + k;
System.out.println("k="+k);
System.out.println("j="+j); __________________
4. What is the value of y after the execution?
y+= ++y + y-- + --y; when int y=8 __________________
*Write the full form for:
a. JDK: __________________________________________________________
b. JRE: __________________________________________________________
c. JCL: __________________________________________________________
d. JVM: __________________________________________________________
*Differentiate between:
1. && and || operator:
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
2. Constant and Variable:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
3. Runtime and Logical error:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
*Write the program for the following questions in notebook :
1. The average height of 6 boys is 158 cm. When the seventh boy joins the group the
average height changes to 159 cm. Find the height of the seventh boy in the group.
Write a program to store the above data and find and display the height of the seventh
boy.
2. Write a program in java to input two integer numbers. If the first number is greater than the
2nd number, then print the greater number and its square, otherwise print the smaller number
and its cube.
3. A whole-seller gives incentives in the form of discounts on the net bill. Write a program to
input the net bill and calculate the discount as follows:
Net Bill in Rupees Discount %
<5000 5
>=5000 and <10000 10
>=10000 15
Display Discount %, Discount Amount and Amount Payable.
*************************************************************************