Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package p1;
- class classMaster
- {
- int a, b;
- String str;
- classMaster(int a , int b , String str)
- {
- this.a = a;
- this.b = b;
- this.str = str;
- }
- void useValues()
- {
- System.out.println(str + " " + (a + b));
- }
- }
- class classMid extends classMaster
- {
- classMid(int a , int b , String str)
- {
- super(a,b,str);
- }
- void useValues()
- {
- System.out.println(str + " " + a / b);
- }
- }
- class classBot extends classMid
- {
- classBot(int a , int b , String str)
- {
- super(a,b,str);
- }
- void useValues()
- {
- System.out.println(str + " " + a * b);
- }
- }
- public class useSuper {
- public static void main(String[] args) {
- classMaster clsmstr;
- classBot clsbt = new classBot(5 , 5 , "classBot");
- clsmstr = clsbt;
- clsmstr.useValues();
- classMid clsmd = new classMid(5,5,"classMid");
- clsmstr = clsmd;
- clsmstr.useValues();
- classMaster clsmtr = new classMaster(5,5,"classMaster");
- clsmstr = clsmtr;
- clsmstr.useValues();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement