--%>

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 : State the term New in XPath 2.0 State

    State the term New in XPath 2.0?

  • Q : Explain Program counter Program counter

    Program counter: A program counter is an integral portion of a computer's Central Processing Unit. It includes a reference to the memory address of the subsequent instruction to be fetched, ready to be executed throughout the next fetch-execute cycle.

  • Q : Define the synchronization objects

    Define the synchronization objects. Ansewr: A synchronization object is use to co-ordinate the execution of many threads.

  • Q : What is an Implicit type conversion

    Implicit type conversion: The type conversion which does not need a cast. Implicit type conversions usually do not comprise any loss of information. For example, joining an integer operand with a floating point operand in an arithmetic expression will

  • Q : What are Logical operators Logical

    Logical operators: The operators, like &&, ||, &, | and ^ which take two Boolean operands and generate a Boolean outcome. Employed as part of a Boolean expression, frequently in the condition of the control structure.

  • Q : What is an Unary operator What is an

    What is an Unary operator: It is an operator which takes a single operand. Java's unary operators are as -, +, !, !, ++ and --.

  • Q : CSS and CSS3 State some of the

    State some of the difference between the CSS and the CSS3.

  • Q : What is Cursor Cursor : This is a

    Cursor: This is a visual representation of the existing position of the mouse on the user's virtual desktop. Cursor shapes are frequently set to symbolize the current state of a program – utilizing an hour glass shape to point out that the user

  • Q : Explain the way of validation XHTML

    Explain the way of validation XHTML documents online.

  • Q : What is an Arithmetic expression

    Expression: It is a combination of operands and operators which generates a resultant value. Expressions contain a resulting type that affects the context in which they might be employed.