ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
what is the purpose of method overriding in java where v r
completely re-defining a  inherited method instead y can't v
create a new method and define.If the question is very silly
plz excuse me and do reply.Thank U!
 Question Submitted By :: AnithaBabu1
I also faced this Question!!     Rank Answer Posted By  
 
  Re: what is the purpose of method overriding in java where v r completely re-defining a inherited method instead y can't v create a new method and define.If the question is very silly plz excuse me and do reply.Thank U!
Answer
# 1
The answer lies in Object Oriented concept. When you are
overriding a method, you overriding the internal details of
default behavior.  But your interface to external world is
not changed. Example, Base class employee has a method
commuteToWork(). All the manager in the company has given
the company car and a driver. Their implementation of
commuteToWork will be different from the non manager
employees.  If you add a new method saying
commuteToWorkByCar(), every Monday morning you would need to
call different method for each subtype of employee.  Hope it
will help.
 
Is This Answer Correct ?    2 Yes 3 No
Kv
 
  Re: what is the purpose of method overriding in java where v r completely re-defining a inherited method instead y can't v create a new method and define.If the question is very silly plz excuse me and do reply.Thank U!
Answer
# 2
hi
   MethodOverriding is the concept which implements Dynamic 
Code(Method) binding.
   i.e., The method which is going to bind or execute is 
decided at the runtime basing on the Object that we are 
using to call that method...
 Suppose assume we have two Classes A,B Where class B is 
inheriting class A.And even we have overridden(given 
different implementation with same method signature)a 
method of class A in class B.
   Now the criteria is which method(superclass method or 
subclsas overridden method) is to be called or executed is 
determined based on the object(class A object Or class B 
object) we are using to call that method............
 
Is This Answer Correct ?    3 Yes 2 No
Imambasha
 
 
 
  Re: what is the purpose of method overriding in java where v r completely re-defining a inherited method instead y can't v create a new method and define.If the question is very silly plz excuse me and do reply.Thank U!
Answer
# 3
Bcoz......wen we think in Object Oriented Lang ..has u ask 
if we create a new method we hav to call the method each 
time wen we invoke the Object & it is a performance ISSUE 
it wil eat lot of memory & it is a COMPLEXITY 
Issue  ........if u override Using the superclass Handle we 
can create  any instance which is of any type(int Float 
Long Short)it wil save space and reduce COMPLEXITY and 
increase PERFORMANCE...
 
Is This Answer Correct ?    1 Yes 4 No
Ershad Md Sk
 
  Re: what is the purpose of method overriding in java where v r completely re-defining a inherited method instead y can't v create a new method and define.If the question is very silly plz excuse me and do reply.Thank U!
Answer
# 4
Unlike data fields, method names can be duplicated. This is 
an important feature that allows method overriding, which 
in turn facilitates polymorphism in the design of object-
oriented programs. Method overriding allows a subclass to 
provide its own implementation of a method already provided 
by one of its superclasses. When a method is called on an 
object, IDL searches for a method of that class with that 
name. If found, the method is called. If not, the methods 
of any inherited object classes are examined in the order 
their INHERITS specifiers appear in the structure 
definition, and the first method found with the correct 
name is called. If no method of the specified name is 
found, an error occurs. 

We can think of overriding as redefining. When we want to 
redefine an inherited behaviour in a more specialised way, 
we must provide implementation with the exact method 
signature as the inherited method (that we want to 
redefine).


For example:

If I define class A:
class A{
void m(){
}
}
We can be making objects from A like this:
A a = new A;
And we can call its method m like this:
a.m();

If we also define class B as a child of A like this:
class B extends A {
}
Then we know it inherits method m from its parent, class A

So we can do this:
B b = new B();
b.m();
The above works because m is inherited.

if u dont understand go through this link.
http://www.tgs.com/support/oiv-java-
release_notes/extension/guide_content.html
 
Is This Answer Correct ?    1 Yes 2 No
Kino
 
  Re: what is the purpose of method overriding in java where v r completely re-defining a inherited method instead y can't v create a new method and define.If the question is very silly plz excuse me and do reply.Thank U!
Answer
# 5
using this concept we can call base class function 
repeatedly in subclass only change of inner coding in 
subclass each and very subclass overrides baseclass when 
they r called
 
Is This Answer Correct ?    0 Yes 0 No
Sathish Kumar
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
What is the default initialized value of String type variable?  3
What are types of Java applications?  4
What is file class and what is its purpose?  1
why Runnable interface is preferable than extending the Thread class? Wipro5
What is the life cycle of an Applet ?  1
what is use of business objects? Tech-Mahindra3
why java does not support mulitple inheritance directly? TCS2
What is I/O Filter? TCS1
Howmany classes that package java.applet.* contains? TCS1
Hi friends, i am new to java. can you explain how java is secured.  1
I have one Shopping cart application, i that i have selected some items, while clicking submit button by mistake i have clicked twice or trice, that time items are selected twice or trice. Actually i want only one copy of items but its selected twice or trice. So how can we avoid this problem? Honeywell2
what is real-time example of runtime polymorphism and compile time polymorphism  1
What is casting? BMC3
wht is mean by dirty read?  1
what are depricated methods ? Satyam4
Can an object be garbage collected while it is still reachable?  2
What is the differnence between String Buffer and String builder despite having knowledge that String builder is faster than String Buffer and last one is threadsafe.please tell another important difference.  3
why the primitive data type have classes?  2
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  2
What is Exception handling in Java How do you handle run time errors please explain with an example TCS2
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com