--%>

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 : Different layers in Windows Architecture

    Explain how many different layers comprise in Windows Architecture?

  • Q : Types of buffering supported by UNIX

    Explain different types of buffering which is supported by the UNIX?

  • Q : Purpose of exec functions Specify the

    Specify the purpose of exec functions?

  • Q : Define the term Statement terminator

    Define the term Statement terminator: The semicolon (;) is employed to point out the end of a statement.

  • Q : Compute the Total Shopper Spending in

    Most of the reports produced from the system compute the total dollars in purchases for a shopper. Process the following steps to build a function named TOT_PURCH_SF which accepts a shopper id as input and returns the total dollars which the shopper has spent with com

  • Q : Print the factors of each perfect number

    An integer number is said to be a perfect number if its factors, including 1 (but not the number itself), sum to be the number. For example, 6 is a perfect number because 6 = 1+ 2+ 3. Write a function perfect that determines if parameter number is a perfect number. Us

  • Q : Explain If statement If statement : A

    If statement: A control structure employed to select between performing or not performing additional actions.     if(boolean-expression){        // Statements

  • Q : Explain Do loop Do loop : This is one

    Do loop: This is one of Java's three control structures employed for looping. The other two are the for loop and while loop. A do loop comprises of a loop body and a Boolean expression. The condition is tested subsequent to the loop body has been fini

  • Q : Define Formal argument Formal argument

    Formal argument: The definition of a method’s argument is the part of a method header. Each and every formal argument has an associated type. Whenever a method is called, the actual argument values are copied into the analogous formal arguments.

  • Q : Abstract list domain The abstract list

    The abstract list domain is as shown: {empty, some, [d1], [d2],[ d1, d2], [d2, d1], all}. A) empty represents empty lists.

    Discover Q & A

    Leading Solution Library
    Avail More Than 1460766 Solved problems, classrooms assignments, textbook's solutions, for quick Downloads
    No hassle, Instant Access
    Start Discovering

    18,76,764

    1961117
    Asked

    3,689

    Active Tutors

    1460766

    Questions
    Answered

    Start Excelling in your courses, Ask an Expert and get answers for your homework and assignments!!

    Submit Assignment

    ©TutorsGlobe All rights reserved 2022-2023.