class A {
void fun1() {
System.out.println(fun2());
}
int fun2() {
return 123;
}
}
public class B extends A {
int fun2() {
return 456;
}
public static void main(String args[]) {
B b = new B();
b.fun1();
A a = b;
a.fun1();
}
}
7、 在打印语句中如何打印这3个x变量?
class A {
int x = 1;
class B {
int x = 2;
void func() {
int x = 3;
System.out.println( ? );
}
}
}
8、 编写一个可以获取文件扩展名的函数,形参接收一个文件名字符串,返回一个扩展名字符串。