阅读程序题(给出【代码】注释标注的代码的输出结果)class Fish {int weight = 1;}class Lake {Fish fish;void setFish(Fish s){fish = s;}void foodFish(int m) {fish.weight=fish.weight+m;}Fish getFish(){fish.weight -= 10;return fish;}}public class E {public static void main(String args[]) {Fish redFish = new Fish();Lake lake = new Lake();lake.setFish(redFish);lake.foodFish(120);int w = lake.fish.weight;Fish fishOK = lake.getFish();System.out.printf("%d:%d:%d",w,lake.fish.weight,fishOK.weight); //【代码】}}
查看答案
阅读程序题(给出【代码】注释标注的代码的输出结果)class B {int x = 100,y = 200;public void setX(int x) {x = x;}public void setY(int y) {this.y = y;}public int getXYSum() {return x+y;}}public class E {public static void main(String args[]) {B b = new B();b.setX(-100);b.setY(88);System.out.printf("%d:%d:%d",b.x,b.y,b.getXYSum());//【代码】}}
阅读程序题(给出【代码】注释标注的代码的输出结果)class Tom {static int sum;int getSum(int ... item ){for(int n:item){sum += n;}return sum;}}public class E {public static void main(String args[]) {Tom cat1 = new Tom();Tom cat2 = new Tom();int resultOne = cat1.getSum(1,2,3,4);int resultTwo = cat2.getSum(10,30);System.out.printf("%d:%d",resultOne,resultTwo); //【代码】}}
阅读程序题(给出下列【代码】注释标注的代码的输出结果)class Circle {int radius = 1 ;void setRadius(int radius){if(radius>0)this.radius = radius;}}class Geometry {Circle c;void setCircle(Circle c) {c.radius += 10;this.c = c;}}public class E {public static void main(String args[]) {Circle circle = new Circle();circle.setRadius(10);Geometry geometry = new Geometry();geometry.setCircle(circle);Circle circleTwo = new Circle();geometry.setCircle(circleTwo);System.out.printf("%d:%d",circle.radius,geometry.c.radius); //【代码】}}
阅读程序题(给出下列【代码】注释标注的代码的输出结果)class AAA{static int m;static{m=888;}}public class Test040501 {public static void main(String[] args) {AAA a=null;System.out.printf("%d:%d",AAA.m,a.m); //【代码】}}