Java-Private methods

Private methods Variables are generally declared with the access control modifier private. In such a case, they can be accessed only by methods of the class in which they are defined. Methods are rarely declared to be of type private. Such a method can be invoked only by the methods in the class in which … Read more…

Java-Method Overloading

Method Overloading Two or more methods in a class with the same name but different parameter. This technique is called method overloading. Method overloading is used when objects are required to perform similar tasks but using different input parameters. When we call a method in an object, Java matches up the method name first and … Read more…

Java-Method with Parameters

Method with Parameters The parameter list appears between the parentheses following the method name. Each parameter must have a unique name and a defined data type. The general form is: Parameters allow a method to be generalized. That is, a parameterized method can operate on a variety of data and/or be used in a number … Read more…

Java-Method Returns

Method Returns A method may be instructed to return a value after its execution is over. A special statement namely the return shall be used for this purpose. Program After a1.areaVolume( ) executes, the value of a1.areaVolume( ) is 187500. There are two important things to understand about returning values: 1. The type of data returned by … Read more…

Java-Class with Methods

Class with Methods A method is a block of statements that has a name and can be executed by calling it from some other place in your program. The general form is : The return_type is the type of the value that is returned by the method to its caller. If no value is returned by a … Read more…