Abstract

double*Speed divide (double*Length, double*Time); The original Java language specification defines: The signature of a method consists of the name of the method and the number and types of formal parameters to the method.. This definition does not change; hence a method signature does not contain dimension specifiers of the formal parameters. Instead the dimension specifiers constitute a rather independent dimension signature for the method. An unchanged rule from the Java language specification is: A class may not declare two methods with the same signature, or a compile-time error occurs. So adding another divide method with different dimensions would cause a function already defined error: abstract double*Acceleration divide(double*Speed, double*Time);//errordouble*Acceleration divide(double*Speed, double*Time);//error Instance methods may override others in superclasses and interfaces that have equal method signatures. A notable restriction is that the return types are equal. An extra restriction is now that the dimension signatures are equal, as well as the dimension specifiers of the return types. Java’s original resolution rules for method calls involve the following compile-time steps: 1. Determine Class or Interface to Search 2. Determine Method Signature 2.1 Find Methods that are Applicable and Accessible 2.2 Choose the Most Specific Method 3. Is the Chosen Method Appropriate Step 2 involves only parameter types, not the return types, and not the dimension specifiers. Step 3 has checks dealing with staticness; it also requires that a void method may only be called in a top level expression. In this step, an extra requirement is now that the dimensions of the formal and actual parameters match. Expressions Expressions must be dimensionally consistent. Both sides of assignments, additions and subtractions must have equal dimensions. Multiplications and divisions result in appropriate dimensions: double * Time t; double * Length s; double * Speed v; t = 18.3*second; // t = 18.3; would be a compile error s = 26.4*meter; // s = 26.4; would be a compile error v = t/s;

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call