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                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
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 are the ways of polymorphism other than Overridding &
Overloading
 Question Submitted By :: Piyush
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What are the ways of polymorphism other than Overridding & Overloading
Answer
# 1
Interface is third way to achieve polymorphism.Because when
you call a method on any interface variable then at run time
it is decided which object method to call.
Ex : 
Let there is a Interface A: 
public interface A
{
 void display();
}

And two classes B and C implement A
class B implements A
{
 display()
 {
    System.out.println("Class B");
  }
}

class C implements A
{
 display()
 {
    System.out.println("Class C");
  }
}

Then while using interface A..see what will happen
class mainClass
{
 public static void main(String args[])
 {
    A obj = new C();
    obj.display();
    obj = new B();
    obj.display();
 }
}

Output : Class C
         Class B
So it is clear that while run/execution time it is decided
which display() method to call..i.e class B or class C display()
 
Is This Answer Correct ?    2 Yes 0 No
Alka
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
Relationship between an event-listener interface and an event-adapter class?  1
What is left shift and right shift?  1
Program to find greatest prime number in n numbers? Huawei3
How does Vector implement synchronization? Ness-Technologies2
What are E and PI?  1
Linked List reverese program Bally-Technologies1
What is the difference between error and exception and explain in simple words not whatever is given in the book.  6
Which class is extended by all other classes?  2
What is difference between Eclips and MyEclips?  2
What is hypertext?  1
What are the ways of polymorphism other than Overridding & Overloading  1
What is CardLayout? Infosys1
How many times garbage collector will invoke an object?s finalize() method?  4
what is difference between Exception and Error?  13
Can a double value be cast to a byte?  3
Can we access a database using applets?  2
How will you create the class for the following scenario? Employees under one employee? Bally-Technologies2
what is polymorphism? Zensar5
IS method overriding is Duplication of Methods? CybAge4
what is main difference between architecture,framework and design pattren  1
 
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