class test_parent
{
int x = 5;
int y = 10;
void set_value(int a, int b)
{
x = a;
y = b;
}
int get_1()
{
return this.x + this.y;
}
int get_2()
{
return x - y;
}
}
class test_4 extends test_parent
{
int y;
test_4(int a)
{
y = a;
}
void set_value(int a, int b)
{
x = a;
y = b;
}
int get_2()
{
return y;
}
}
class Test2
{
public static void main(String[] args)
{
test_4 a1=new test_4(-1) ;
a1.set_value(5,5);
int x = a1.get_2();
System.out.println("x="+x);
test_4 a2=new test_4(1);
int z= a2.get_1();
System.out.println("z="+z);
}
}你能一眼看出结果吗?
|
|