- public class Demo {
-
- public static void main(String[] args) {
- B b = new B();
- b.show();
- b.print1();
- }
- }
- class A{
- String s = "A";
- void show(){
- System.out.println(s);
- }
- void print1(){
- System.out.println(print2());
- }
- int print2(){
- return 123;
- }
- }
- class B extends A{
- String s = "B";
- int print2(){
- return 456;
- }
- }
复制代码 |
|