Java-Simple Class Construction

Simple Class Construction The class is nothing but a template for object you are going to create or it’s a blue print by using this we create an object. In simple word we can say it’s a specification or a pattern which we define and every object we define will follow that pattern. Here is … Read more…

Java-Declaring Objects

Declaring Objects An object is an instance of a class. The relationship is such that many objects can be created using one class. Each object has its own data but its underlying structure are defined by the class. There are two steps when creating an object from a class : Declaration A variable declaration with a … 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…

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-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 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…