嵌套类练习已完成
1
考虑类A:
public class A{
public int x=1;
public void increaseBy(int n)
{ x=x+n; } }
以下哪个选项输出结果不会产生4?
A、A a = new A();a.x = 3 + a.x;System.out.print(a.x); B、A a = new A();a.increaseBy(2);a.increaseBy(1);System.out.print(a.x); C、
A a = new A(){public void increaseBy (int n) {super.increaseBy(n);}};a.increaseBy(4);System.out.print(a.x);
D、A a = new A();a.increaseBy(3);System.out.print(a.x);
我的答案:C
包的应用已完成
1
以下哪几段代码可以成功编译?()
1)
import java.awt.*;
package Mypackage;
class Myclass {}
2)