Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
620 B
2
Indexable
Never
public class test7 {
    class Base {
        private int numl;

        public void setData(int n) {
            numl = n;
        }

        public int getData() {
            return numl;
        }
    }

    class Derived extends Base {
        int num2;

        public void product() {
            int num = getData();
            System.out.println("product = " + (num2 * num));
        }
    }

    public class PrivateInheritance {
        public void main(String[] args) {
            Derived d = new Derived();
            d.setData( 20 ); 
            d.num2 = 10;
            d.product();
        }
    }
}