国开 / 面向对象程序设计
public class XXK2 {
private int a,b;
public XXK2(int aa, int bb) {a=aa; b=bb;}
public int f1(int x) {
if(x>10) return a+b+3*x;
else return a*b*x;
}
public static void main(String[] args) {
XXK2 x=new XXK2(3,4);
int y=x.f1(8);
System.out.println("y="+y);
}
}
y=96
y=34
private int a,b;
public XXK2(int aa, int bb) {a=aa; b=bb;}
public int f1(int x) {
if(x>10) return a+b+3*x;
else return a*b*x;
}
public static void main(String[] args) {
XXK2 x=new XXK2(3,4);
int y=x.f1(8);
System.out.println("y="+y);
}
}
y=96
y=34
参考答案:
佳题速递: