Explain method overloading and overriding?
Answers were Sorted based on User's Feedback
Answer / janet
Method overloading: when a method in a class having the
same method name with different arguments is said to be
method overloading.
Method Overridding: when a method in a class having the
same method name with same arguments is said to be method
overridding.
Is This Answer Correct ? | 21 Yes | 5 No |
Answer / chittaranjan
Method overloading: when a method in a class having the
same method name with different number/type of arguments
with the existense of prevoius meaning also is called
method overloading.
Method Overridding: when a method in a class having the
same method name with same number & type of argument(s)
however there mus not be any existense of previous meaning
is said to be method
overridding.
Is This Answer Correct ? | 10 Yes | 3 No |
Answer / prasad
when we use method in a class hane same name with different
arguments are calles method overloading
when we use methodes with same class name and same
arguments called ovverriding
Is This Answer Correct ? | 7 Yes | 2 No |
Method overloading happens in class with same method name but by modifying below features
1> By changing number of parameters
2> By changing ordinal position of parameter , i mean to say here is by changing datatype place.
And method overriding happens in two or more than two class , i mean defining same method declaration without any modification within two class and among of that two class , one class must extend another class and further also you can override this method , and this procedure continues till one subclass leaves overriding this method.
Is This Answer Correct ? | 5 Yes | 0 No |
Answer / aburar yaseen
overloading:previous answers are correct.
overriding: overriding is possible only in inheritance.
we will have more than one methods in the same name with
same no. of arguments with same type in different classes.
Is This Answer Correct ? | 7 Yes | 4 No |
Answer / ravikiran(aptech mumbai)
method overloading is the type of polymorphism with a
different argument list and same method name and can takes
place inside the same class only
method overriding is the process of writing a different
functionality having the same method signature
Is This Answer Correct ? | 4 Yes | 2 No |
What is a super method?
What is static import?
When is finally block not called?
if num=687; U have to get num=6+8+7;
What are the two ways to create a thread?
Can we write multiple catch blocks under single try block?
class{ ... ... interface myinterface{ ... ... } abstract class{ .. .. } ... .. .. } is this possible to write "Interface and/ or Abstract class inside a class ? if possible whcich one is possible is only interface? is only abstract?
What is not thread safe?
These static constructors are correct ? class A { statc intA() { } static A(int x,int y) { } static A(int x) { } }
Difference between final and effectively final ?
Which of the following can be referenced by a variable? A. The instance variables of a class only B. The methods of a class only C. The instance variables and methods of a class
What are loops in java? What are three types of loops?