Friday C# Quiz: Know Your Closures
Although I've vowed not to post about closures anymore, I can't help but post one more quiz. I know Friday is mostly over for many of my readers, but there are still a few time zones left.
Without downloading Microsoft Visual C# 2008 Express Edition and compiling the following C# source file, answer the following question:
Q: Will the following program
public delegate int IntToInt(int i); public class Foo { public static IntToInt fib = n => n == 0 ? 0 : n == 1 ? 1 : fib(n - 1) + fib(n - 2); public static void Main() { System.Console.WriteLine(fib(6)); } }
compile? Run? If so, what will it print out?
Friday Java Quiz: Incompatible Language Changes
The evolution of the Java programming language has been managed carefully (maybe too carefully) to avoid incompatible language changes. However, binary compatibility was given more consideration than source compatibility. In the words of one of the Java Posses, your class will continue to work as long as you don't recompile your code.
Q: Which of the following Sun JDK/JSDK/J2SDK/JDK upgrades contain code breaking language/library changes? Give an example snippet.
- Beta ⇒ 1.0
- 1.0 ⇒ 1.1
- 1.1 ⇒ 1.2
- 1.2 ⇒ 1.3
- 1.3 ⇒ 1.4
- 1.4 ⇒ 1.5
- 1.5 ⇒ 1.6