SHARE
TWEET

JavaInheritanceTest1

KuoHsiangYu Dec 14th, 2019 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.sample2;
  2.  
  3. class Father {
  4.     public int num1 = 0;
  5.     public int num2 = 0;
  6.  
  7.     public void show() {
  8.         System.out.printf("num1=%d, num2=%d\n", num1, num2);
  9.     }
  10. }
  11.  
  12. class Son extends Father {
  13.     public void setNum(int a1, int a2) {
  14.         num1 = a1;
  15.         num2 = a2;
  16.     }
  17. }
  18.  
  19. public class JavaInheritanceTest1 {
  20.     public static void main(String[] args) {
  21.         Son son = new Son();
  22.         son.setNum(10, 20);
  23.         son.show();
  24.     }
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top