KnowledgeBoat Logo

Computer Applications

Find the error :

x = 3;	
y = 4;	
z = math.power(x*x, y/2);	

Java Math Lib Methods

3 Likes

Answer

The errors are as follows:

  1. The variables — x, y, z, are not declared. They need to be declared before they can be used.
  2. The letter 'm' in math should be in uppercase as Java is a case-sensitive language. Also, the correct name of the function is pow. Hence, it must be written as Math.pow().

The correct code snippet is as follows:

int x = 3;	
int y = 4;	
double z = Math.pow(x*x, y/2);

Answered By

2 Likes


Related Questions