Z*****Z 发帖数: 723 | 1 Egg2 e2 = new BigEgg2();
BigEgg2 Constructor called
Egg2 constructor called
Yolk y initialize
Egg2.Yolk constructor called
"Egg2.Yolk()"
Egg2.Yolk constructor return
"New Egg2()"
Egg2 constructor return
now back in BigEgg2 constructor
create a new BigEgg2.Yolk object
BigEgg2.Yolk constructor called
Egg2.Yolk constructor called
"Egg2.Yolk()"
Egg2.Yolk constructor return
"BigEgg2.Yolk... 阅读全帖 |
|
t**********h 发帖数: 2273 | 2 今天面了一个和下面类似的一个题,很有意思,大家一起看看。写出打印的东西
class Egg2 {
protected class Yolk {
public Yolk() { print("Egg2.Yolk()"); }
public void f() { print("Egg2.Yolk.f()");}
}
private Yolk y = new Yolk();
public Egg2() { print("New Egg2()"); }
public void insertYolk(Yolk yy) { y = yy; }
public void g() { y.f(); }
}
public class BigEgg2 extends Egg2 {
public class Yolk extends Egg2.Yolk {
public Yolk() { print("BigEgg2.Yolk()"); }
public void f() { print("BigEgg2.Yolk.f()"); }
}
p... 阅读全帖 |
|
z*********e 发帖数: 10149 | 3 最差情况下careercup里面的解是
Goal: Create a system for dropping Egg1 so that the most drops required is
consistent, whether Egg1 breaks on the first drop or the last drop 1 A
perfectly load balanced system would be one in which Drops of Egg1 + Drops
of Egg2 is always the same, regardless of where Egg1 broke 2 For that to be
the case, since each drop of Egg1 takes one more step, Egg2 is allowed one
fewer step 3 We must, therefore, reduce the number of steps potentially
required by Egg2 by one drop each... 阅读全帖 |
|
|