--%>

Method over ridding in java

Q. Explain method over ridding in java. Give example.              

Ans. Method over ridding: In a class hierarchy, when a method in a subclass has the same name and type signature as a method in its subclass then the method in the subclass in said to over ride the method in the super class. When an over ridden method is called from with a subclass it will always refer to the version of tat method defined the subclass. The version of the technique defined by the super class will be unseen. When show () is invoked on the object of type B, the version of show () defined in B is utilized. This is the version of show () inside B over riddles the version declared in A. If you want to access the super class version of an over ridden method function, you can do so by using super class. For example, in the version of B, the super class version is show () is invoked within the subclass version. This permits all instance variables to be exhibited.

Class B extends A

{  int K;

B { int a, int b, int c)

{  super (a, b)

K = c;

}

}

Method over ridding occurs only when the names and the types signature of the two methods are identical. If they are not then the two methods are simply over loaded. 

   Related Questions in Programming Languages

  • Q : Scripting Language Programming

    Hi Assignment Team, Please find attachment of my assignment. Please advise if there is any unclear information Regards, King

  • Q : Define the reasons of Process Handle

    Define the reasons of Process Handle Table.

  • Q : Index value of the initial element in

    Write the index value of the initial element in an array?

  • Q : Define Daemon thread Daemon thread :

    Daemon thread: The daemon threads are non-user threads. They are usually employed to carry out low-priority tasks which must not take priority over the major task of the program. They can be employed to do helpful work whenever all other user threads

  • Q : Define the term Heterogeneous collection

    Define the term Heterogeneous collection: It is a collection of objects with distinct dynamic types

  • Q : What is Abstract method Abstract method

    Abstract method: This is a method with the abstract reserved word in its header. The abstract method has no method body. Methods stated in an interface are for all time abstract. The body of an abstract method should be stated in a su

  • Q : Write a recursive implementation of

    Assignment 5 Selecting Array Elements Implement the following C++ code in assembly language, using the block-structured .IF and .WHILE directives. Assume that all variables are 32-bit signed integers: int array[] = {10,60,20,33,72,89,45,65,72,18}; int sample = 50; intArraySize = s

  • Q : Give some instances of XML DTDs or

    Give some instances of XML DTDs or schemas which you have worked with?

  • Q : Describe Throw an exception Throw an

    Throw an exception: Whenever an exceptional circumstance occurs in a program - frequently as an outcome of a logical error and exception object is formed and thrown. When the exception is not caught by an exception handler, the program will finish wit