explain method overridding method overloding with examples?

Answers were Sorted based on User's Feedback



explain method overridding method overloding with examples?..

Answer / manoj jain

overriding and overloading both are type polymorphism.
overloading:-more then one functions or constructors have
same name but different signature is called overloading.
this is also called compile time polymorphism or static
polymorphism.

overriding:-method in child class has same name as in
parent class(function name and signature will be same in
parent and child class)that is called overriding.
child class method hides parent class method it is also
called bynamic binding or runtime polymprphism

Is This Answer Correct ?    11 Yes 0 No

explain method overridding method overloding with examples?..

Answer / muthusenthil

method overloading is to load some extra features in
existing method eg: a method takes string as an arguments
but overloaded method may take int along with String
trapPerson(String name)- pre-existing method
trapPerson(String name,int age)- overloaded method
(irrespective of return type)
this may take place in same class or derived clas

method overridding is to override a method from parentclass
to change its behaviour.name should be same as parentclass
method, behaviour may change
it should takes place between derived class
eg: class man extends superman
int walk() be one among characterstics of man overridden by
superman.

Is This Answer Correct ?    8 Yes 0 No

explain method overridding method overloding with examples?..

Answer / esha prasad

Overriding:: It's not any two classes will do to study this
scnario, because overriding will come in a scenario
involving parent child relationship.



public class Parent{

public void sum(int a, int b)
{
System.out.println(a+b);
}
class Child extends Parent
{


public void sum(int a, int b)
{
System.out.println("Sum of the integers = "+a+b);
}
}

}

class MainClass
{
public static void main(String[] args) {


}

}

Is This Answer Correct ?    8 Yes 0 No

explain method overridding method overloding with examples?..

Answer / zurreyab ahmad

Ovloding:in overloding case same method name and different
parameter and different return type
public class overlo {

public void add(int a, int b)
{
System.out.println(a+b);
}
public float add(float c, float d)
{
return c+d;
}
}

class main1
{
public static void main(String[] args) {


}

}
Overriding:: in overriding case the same method name and
same parameter and same return type and in overriding case
at least two class must have



public class overri {

public void add(int a, int b)
{
System.out.println(a+b);
}
class overri1
{


public void add(int a, int b)
{
System.out.println(a+b);
}
}}

class main1
{
public static void main(String[] args) {


}

}

Is This Answer Correct ?    7 Yes 1 No

explain method overridding method overloding with examples?..

Answer / senthamil kumaran

polymorphism can be divided into two tyes:-

Dynamic polymorphism or Run time polymorphism
Static polymorphism or Compile time polymorphism

Example for Static polymorphism
Method Overloading

Example for Dynamic polymorphism

Method Overriding



overloading: same method name but different argument list
is called as overloading

overriding:-same methodis redefined in the following
Derived classes with the same arugument list

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Struts Interview Questions

What are Struts properties?

2 Answers   VI eTrans,


What is the default suffix for struts2 action uri ?

0 Answers  


What is the purpose of @doublerangefieldvalidator?

0 Answers  


I will explain the scenario now i have a form1 having some fields and i made it extends DynaActionForm. in struts config how can i specify another form form2 which has to extend the form1 please specify is it better to use actionform or dyna action form in applations. is dyna action form is comfortable in declaring form variables of type 'ArrayList<somegenerics>' extend the

0 Answers   Techno Solutions,


Even though Servlets and JSP are web based concepts .wht is the use of using Struts using then

8 Answers   TCS,






Who makes the struts?

0 Answers  


What are the core components of a struct2 based application?

0 Answers  


What is the differnce between 2-tier architecture and 3- tier architecture in java?

3 Answers  


Can we handle exceptions in Struts programmatically?

0 Answers  


What is struts2 in java?

0 Answers  


What is struts2 namespace?

0 Answers  


Briefly tell the two kinds of form beans.

0 Answers  


Categories