Closed ErSKS closed 7 years ago
package overridesampleexample;
/*
@author m-lan */ public class 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);
}
}
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();
}
}
/*
import javax.swing.JOptionPane;
/*
@author DELL */ class Java {
void test() {
JOptionPane.showMessageDialog(null, "******Input Your number******");
}
}
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
/*
/*
@author Dell */ public class ManyClass {
/**
}
/*
/*
@author Dell */ abstract class College {
public abstract void admitStudent();
public abstract void publishresult(); }
/*
/*
@author Dell */ public class WRC1 extends College {
public void admitStudent() { System.out.println("Admit Student by WRC1"); }
public void publishresult() { System.out.println("Publish Result WRC1"); } } /*
/*
@author Dell */ public class KhEC extends WRC1 {
public void admitStudent() { super.admitStudent(); System.out.println("Admit Student by KhEC"); }
public void publishresult() { super.publishresult(); System.out.println("Publish Result KhEC"); } } /*
/*
@author Dell */ public class KhCE extends KhEC {
public void admitStudent() { super.admitStudent(); System.out.println("Admit Student by KhCE"); }
public void publishresult() { super.publishresult(); System.out.println("Publish Result KhCE"); } } /*
/*
@author Dell */ public class KhSS extends KhCE {
public void admitStudent() { super.admitStudent(); System.out.println("Admit Student by KhSS"); }
public void publishresult() { super.publishresult(); System.out.println("Publish Result KhSS"); } } /*
/*
@author Dell */ public class NEC extends KhSS {
public void admitStudent() { super.admitStudent(); System.out.println("Admit Student by NEC"); }
public void publishresult() { super.publishresult(); System.out.println("Publish Result NEC"); } }
Submit - Own Method Overriding Example representing simple but specific problem solving.