ICSE Class 10 Computer Applications
Question 57 of 76
Revising Basic Java Concepts — Question 61
Back to all questions 61
Question Question 38
Find the error :
x = 3;
y = 4;
z = math.power(x*x, y/2); The errors are as follows:
- The variables — x, y, z, are not declared. They need to be declared before they can be used.
- The letter 'm' in
mathshould be in uppercase as Java is a case-sensitive language. Also, the correct name of the function ispow. Hence, it must be written asMath.pow().
The correct code snippet is as follows:
int x = 3;
int y = 4;
double z = Math.pow(x*x, y/2);