go to previous page   go to home page   go to next page

Answer:

Point  A = new Point();

short  a = 93,    b = 92;
int    i = 12,    j = 13;
long   x =  0,    y = 44;
double u = 13.45, v = 99.2;

A.move( i, b );   // OK --- b can be converted to int without loss 
A.move( a, x );   // NOT OK --- converting x to int may lose magnitude and precision 
A.move( u, b );   // NOT OK --- converting u to int may lose magnitude and precision 

Method using a double Parameter

class CosEg
{

  public static void main ( String arg[] )
  {
    double x = 0.0;
 
    System.out.println( "cos is:" + Math.cos( x ) );
  }
}

The cos() method is a static method of the Math class. (Remember that a static method is a method that belongs to the definition of the class; you do not need an object to use it.) Here is how the method looks in the documentation for the Math class:

public static double cos( double num )

The method requires a parameter of type double. It evaluates to (returns) a double, the cosine of the parameter. The parameter is in radians (not degrees.)


QUESTION 10:

Is the parameter in the method call in the program the correct type?