You are on page 1of 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