ErSKS / Java

Java Training
http://khec.edu.np/
MIT License
16 stars 17 forks source link

Submit - Own Method Overriding Example #42

Closed ErSKS closed 7 years ago

ErSKS commented 7 years ago

Submit - Own Method Overriding Example representing simple but specific problem solving.

milan604 commented 7 years ago

package overridesampleexample;

/*

}

class Degree {

void convert(float DegreeC) {

    System.out.println("The Degree Centigrade is " + DegreeC);
}

}

class Fahrenheit extends Degree {

@Override
void convert(float DegreeC) {
    super.convert(DegreeC);
    float fah = (9 / 5.0f * DegreeC + 32);
    System.out.println("The Fahrenheit of" + DegreeC + " Centigrade is " + fah);
}

}

class Kelvin extends Fahrenheit {

@Override
void convert(float DegreeC) {
    super.convert(DegreeC);
    float Kelvin = DegreeC + 273;
    System.out.println("The Kelvin of" + DegreeC + " Centigrade is " + Kelvin);
}

}

screenshot from 2017-08-18 09-44-33

jagdish4249 commented 7 years ago

package methodoverriding17august2;

/*

class Auto{

void start(){

    System.out.println("Starting...");
}

}

class Truck extends Auto{ @Override void start(){ super.start(); System.out.println("Truck ignition..."); } }

public class MethodOverriding17August2 {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
   Truck t = new Truck();
    t.start();
}

}

image

RakenShahi commented 7 years ago

/*

import javax.swing.JOptionPane;

/*

}

class Pro extends Java {

@Override
void test() {
    super.test();
    int a;

    a = Integer.parseInt(JOptionPane.showInputDialog(null, "Input your number"));
    JOptionPane.showMessageDialog(null, "Your entered number = " + a);
    //System.out.println("You entered number = " + a);
}

}

public class JavaPro {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    // TODO code application logic here
    Pro p = new Pro();
    p.test();
}

}

OUTPUT over1 over2 over3

ajay987 commented 7 years ago

/*

/*

}

/*

/*

/*

/*

/*

/*

/*

/*