11.What restrictions are placed on method overriding?
· Overridden methods must have the same name, argument list, and return type.
· The overriding method may not limit the access of the method it overrides.
· The overriding method may not throw any exceptions that may not be thrown by the overridden method.
12. What is use of this and super key words?
· ‘this’ is used for referring to current instance of the object where as ‘super’ is used to refer to variables and methods of its super class.
· Incase of constructors, this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.
13. What is the difference between a static and non-static variable?
· A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.
14. What is polymorphism and what are different types of polymorphism?
· One name, different form and there are three forms.
1. Method overloading
2. Method overriding through Interfaces
3. Method overriding through java interfaces.
15. What is the essence of run-time polymorphism behavior?
With runtime polymorphism based on method overriding, the decision as to which version of a method will be executed is based on the actual type of object whose reference is stored in the reference variable, and not on the type of the reference variable on which the method is invoked.
The decisions as to which version of the method to invoke cannot be made at compile time. That decision must be deferred and made at runtime. This is sometimes referred to as late binding.
About Me
Sunday, March 30, 2008
CORE JAVA FAQS
Posted by Its For Techies at 12:49 AM
Labels: CORE JAVA faqs-3
Subscribe to:
Post Comments (Atom)
1 comments:
In Question no 14 th:
Polymorphism examples:
1. Method Overloading
2. Polymorphism through INHERITANCE
3. Polymorphism through interfaces
Post a Comment