Submit Your Site To The Web's Top 50 Search Engines for Free! Java Tutorial: Learn Java Basics For Free | Learn Java

Tuesday, December 17, 2019

What is a method signature in Java? -Learn Java

What is a method signature in Java? -Learn Java


In java, method signature consists of name of the method followed by argument types.

Example:


https://cjavapoint.blogspot.com/
in java return type is not part of the method signature .Compiler will use method signature 
while resolving method calls.

   class Demo
  {
      public void m1(double d){ }
      public void m2(int i)    { }
      public static void main(String args[]){
         Demo d=new Demo();
         d.m1(11.2);
         d.m2(10);
         d.m3();  //CE
    }
  }

CE:cannot find symbol
symbol:method m3(double)
location:class Demo


Within  the same class we cant't take 2 method with the same signature otherwise we will 
get compile time error.

Example:

   public void methodOne() { }
   public int methodOne() { 
    
     return 10;
   }

Output:

Compile time error
methodOne() is already defined in Demo.










             

Monday, December 16, 2019

Aggregation in Java: Definition and Examples -Learn Java

Aggregation in Java: Definition and Examples -Learn Java

Without existing container object if there is a chance of existing contained objects
such type of relationship is called aggregation .
in aggregation objects have weak association.

Example:

Within a department there may be a chance of several professors will work whenever 
we are closing department still there may be a chance of existing department object the
 relationship between department and professor is called aggregation where the objects
 having weak association.

Example:

https://cjavapoint.blogspot.com/

Saturday, December 14, 2019

Composition in Java Example - Learn Java

Composition in Java Example - Learn Java

without existing container object if there is no chance of existing contained object
then the relation between container object and contained object is called composition 
which is a strong association.

Example:

Any university consists of several departments whenever university object destroys automatically 
all the department object will be destroys that is without existing dependent object hence there are associated and this relationship is called composition .



Learn Java online free and learn java programming this is the
best way to learn java. this is best java tutorial.in this tutorial          
all the programs start with hello java,hello world.Enterprise applications         
programming language

HAS-A relationship in Java - Learn java

HAS-A relationship in Java - Learn java

1.HAS-A Relationship is also knows as composition(or) aggregation.
2.There is no specific keyword to implement HAS-A relationship but mostly 
    we can use new operator.
3.The main advantage of  reusability.

Example:-

class Engine
{
 // engine functionality
}
class Car
{
   Engine e=new Engine();
  //------------------------------;
  //------------------------------;
  //------------------------------;
}

NOTE:-

class car has-a engine reference.
The main dis-advantage of has-a relationship increases dependency between the
components and creates maintains problems.


Learn Java online free and learn java programming this is the
best way to learn java. this is best java tutorial.in this tutorial          
all the programs start with hello java,hello world.Enterprise applications         
programming language

Java Inheritance Update 2023 With Program And Example

  Java Inheritance Update 2023 With Program And Example  nheritance is one of the essential concepts in object-orientated programming  (OOP)...