Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.sample2;
- class Father {
- public int num1 = 0;
- public int num2 = 0;
- public void show() {
- System.out.printf("num1=%d, num2=%d\n", num1, num2);
- }
- }
- class Son extends Father {
- public void setNum(int a1, int a2) {
- num1 = a1;
- num2 = a2;
- }
- }
- public class JavaInheritanceTest1 {
- public static void main(String[] args) {
- Son son = new Son();
- son.setNum(10, 20);
- son.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement