Chapter 6 (Web design tools) Methods 225 So far, the logical

Chapter 6 Methods 225 So far, the logical names of methods that have been used by the compiler have not mentioned the methods return types. This is because method calls cannot be distinguished by return type. The program in Fig. 6.19 illustrates the syntax error that is generated when two methods have the same signature and different return types. Overloaded methods with different parameter lists can have different return types. Overloaded methods need not have the same number of parameters. Common Programming Error 6.17 Creating overloaded methods with identical parameter lists and different return types is a syntax error. SUMMARY The best way to develop and maintain a large program is to construct it from small pieces, or modules. This technique is called divide and conquer. Modules can be created with methods and classes. Programs are written by combining new methods and classes that the programmer writes with prepackaged methods and classes in the .NET Framework Library, and in various other method and class libraries. The .NET Framework Library provides a rich collection of classes and methods for performing common mathematical calculations, string manipulations, character manipulations, input/output, error checking and other useful operations. 1 // Fig. 6.19: InvalidMethodOverload.cs 2 // Demonstrating incorrect method overloading. 3 4 public class InvalidMethodOverload 5 { 6 public int Square( double x ) 7 { 8 return x * x; 9 } 10 11 // ERROR! Second Square method takes same number, order 12 // and types of arguments. 13 public double Square( double y ) 14 { 15 return y * y; 16 } 17 } Fig. 6.19 Syntax error generated from overloaded methods with identical parameter lists and different return types.
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

Leave a Reply