0% found this document useful (0 votes)
90 views1 page

Overriding

Method overriding occurs when a subclass defines a method with the same name and signature as a method in its parent superclass, replacing the superclass method. Method overloading occurs when multiple methods in the same class share the same name but differ in parameters, allowing separate methods to be called depending on parameters.

Uploaded by

lalitha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views1 page

Overriding

Method overriding occurs when a subclass defines a method with the same name and signature as a method in its parent superclass, replacing the superclass method. Method overloading occurs when multiple methods in the same class share the same name but differ in parameters, allowing separate methods to be called depending on parameters.

Uploaded by

lalitha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Overriding OVERLOADING

When a method in a class having the same  When a method in a class having the same
method name with same arguments is said to be method name with different arguments is said
method overriding. to be method overloading. 
In overriding, there is relationship between a In overloading, there is a relationship between
super class method and subclass method. methods available in the same class
Overriding must have same signature. Overloading must have different method
signatures
 In overriding, subclass method replaces the  In overloading, separate methods share the
super class. same name 

package developer;

import java.util.Scanner;

public class CelsiusToFahrenheit {

    public static void main(String[] args) {

        System.out.println("Enter a temperature in Celsius: ");


        Scanner scanCelsius = new Scanner(System.in);
        double Fahrenheit = 0;

        if (scanCelsius.hasNextDouble())


        {
            Fahrenheit = (scanCelsius.nextDouble()*9) / 5 + 32;
        }
        System.out.println("The temperature in Fahrenheit is: " + Fahrenheit);
    }
}

You might also like