You are on page 1of 2

PAWAR PUBLIC SCHOOL, PUNE

PRACTICE WORKSHEET
Std. : VIII SUBJECT- COMPUTER

Ch-4 Program coding


Unit I, II, III
Question 1
Write down the syntax for the following functions in Java programming:
(a) To find square root of a number.
(b)To find maximum among x and y

Question 2
Assign value 12.25 to a variable of suitable data type.

Question 3
If x=3.25 Calculate Math.abs(x);

Question 4
Correct the snippet:
int a =45.2;
b=2;
sum=a+b;

Question 5
Identify the type of literal for the following:
25.35
“a”
true

Question 6
Give an expression in Java for (a+b)2 = a2 +b2 +2ab

Question 7
What will be the value of k after evaluating the following expression?
int k=5, j=9;
k+=k++ - ++j +k;

Question 8
state the value of n and ch when
char c=’A’;
int n= c+1;
char ch= (char)n;

Question 9
What will be the output value of m if m=5, n=2;
m-=n;

Question 10
Predict the output of the given snippet, when executed:
int x= 1, y=20;
if(n>0)
{
x=x+3;
y=y-1;
}
What will be the value of x and y, if n assumes a value (i) 12 (ii) 0?

Question 11
Correct the errors of the given programs:
classABC
{
public void main( String args{} )
{
int a=45.34, b=7, c=65.45;
d = a+b;
e = c-b;
System.out.println(d+e);
}
}

Question 12
Write a program to input a number and check whether number input is even
number or odd number and display the message accordingly.

Question 13
Write a program to accept three sides of a triangle and check whether the
triangle is possible or not and display the message accordingly.

You might also like