Puzzle! Puzzle! Puzzle!?

  • Thread starter Thread starter carmen
  • Start date Start date
C

carmen

Guest
Two developers, Ann and Suzy, are waiting for code to compile. Suzy learns that Ann's sister has three children, and asks how old they are. Ann responds, "The product of their ages is 36." Suzy says, "Oh c'mon--I can't figure it out with that!" Ann replies, "Ok, then the sum of their ages is the same as this number right here," and points to a number on the screen. Suzy says, "Nope, still can't do it," and Ann replies, "The oldest is dyslexic." How old are the children? (Order from oldest to youngest.)
 
acuitus-interview DOT blogspot DOT com

True/False: Both a static nested class and inner class have access to the private members declared in the enclosing class.

False


True/False: A Java class that contains an abstract method cannot be instantiated.

True


True/False: An instance method defined on a Java class can directly access private static variables of the same class.

True


True/False: It is valid to use an interface name in an instanceof expression.

True


True/False: If the class definition doesn't assign an access specifier to a static method, it defaults to private access.

False


True/False: The String "012345" requires exactly 6 bytes of storage in Java.

False



What are all of the possible outputs of the following code? The exception code has been removed for clarity. Assume that this code compiles and runs, and that when it runs there are no exceptions.

final Object lock = new Object();
Thread t1 = new Thread() {

public void run() {

System.out.print("a");
synchronized(lock) { lock.wait(); }
System.out.print("b");

}

};
Thread t2 = new Thread() {

public void run() {

System.out.print("c");
synchronized(lock) { lock.notify(); }

}

};
t1.start();
t2.start();


ac, ca, acb, cab



The following four questions are based on the following class. Please assume that the last two methods are implemented correctly, and that this code compiles and runs.

public class Time {

private int minutesAfterMidnight;
public final int objectId;
private static int numCreated = 0;

public Time(int minutes) {

setMinutes(minutes);
objectId = ++numCreated;

}

private void setMinutes(int minutes) {

this.minutesAfterMidnight = minutes;

}

public static int getNumCreated() {

return numCreated;

}

public boolean equals(Object other) {

[...code that implements this method correctly...]

}

public static int compareTo(Time t1, Time t2) {

[...code that implements this method correctly...]

}

}
True/False: The getNumCreated() method can be sent to the Time class itself, and doesn't require instantiating a Time object first.

True


True/False: Making the objectId data member public is bad design because it can be changed by clients outside the class.

False


True/False: One objectId variable will be created for each instance of the Time class.

True


True/False: Because a Time object has a compareTo method, it can be safely upcast to Comparable.

False





Three smart biker dudes go into a dark closet, where there are five leather jackets that are identical except that three have a Harley-Davidson logo on the back while two have a Mini Cooper logo on the back. Each of the bikers selects a jacket and puts it on without being able to see which one it is. Each of them knows that (1) the closet has three Harley-Davidson jackets and two Mini Cooper jackets, and (2) the other two bikers have the same information.

The bikers emerge from the closet wearing the jackets, and while each biker can see which jackets the other two are wearing, he cannot see what he is wearing. The first biker looks at the other two, thinks, and says, "Dude, I have no idea what I'm wearing." The second biker looks at the other two, thinks, and says, "Dude, me neither." The third biker, who is still wearing a headcast from his last accident and can't see a thing, nonetheless says, "Dude--I know what I'm wearing!" Which jacket is he wearing?


Harley-Davidson



An aging novelist, seeking to combat writer's block, brings his typewriter aboard a canoe that is floating in the middle of his swimming pool. Fortunately the novelist strikes on a great idea, but unfortunately in his excitement he knocks the typewriter off the canoe and it sinks to the bottom of the pool. What happens to the water level on the side of the pool?

It stays the same.



A rustic village contains one million married couples and no children. Each couple is capable of having exactly one child per year. Each couple wants a girl, but also wants to minimize the number of children they have, so they will continue to have children until they have their first girl. Assume that children are equally likely to be born male or female. Let p(t) be the percentage of children that are female at the end of year t. What is p(t)? "Can't tell" is a potential answer if you don't have sufficient information.

can't tell


Two developers, Ann and Suzy, are waiting for code to compile. Suzy learns that Ann's sister has three children, and asks how old they are. Ann responds, "The product of their ages is 36." Suzy says, "Oh c'mon--I can't figure it out with that!" Ann replies, "Ok, then the sum of their ages is the same as this number right here," and points to a number on the screen. Suzy says, "Nope, still can't do it," and Ann replies, "The oldest is dyslexic." How old are the children? (Order from oldest to youngest.)

9 2 2


Two bikers bike toward each other at constant speed on a single lane road. The first, wearing leather, is going 75 miles per hour, and the second, wearing spandex, is going 25 miles per hour. When they are 50 miles apart, a high-speed African fly takes off from the first biker's helmet going 90 miles per hour, and flies until he reaches the second biker's helmet, at which point he instantly turns around and flies back to the first biker's helmet at 90 miles an hour. The fly continues to fly between the two helmets until all three crash into each other. Approximately how many miles will the fly have flown before being squished?

45 miles


After a night of wild revelry, a group of local intoxicated hoodlums stumble into a children's playground. One of these hoodlums, Phil, climbs to the middle of a spin-around carousel and his friends push the carousel so it rotates once every five seconds. Phil, who is trying not to get sick, holds a flashlight motionless in his hand.

There is a straight path running by the playground that, at its closest point, is 30 meters from the middle of the carousel. Unknown to Phil, there are two cops facing him on the path, shocked at the spectacle. One of them is standing on the path at the point closest to the carousel, while the other is standing 60 meters down the path. At approximately what speed (in meters per second) does the spot illuminated by the flashlight traverse each of the cops' bodies? State speed at the closest cop first.

299,792,458 m p s


What is the sum of all odd numbers from 47 to 342, inclusive?

28712
 
Back
Top