Posts Tagged ‘puzzle’

C Puzzle #3

C - programming language - thumb

What is the output of the following programm? . . . . . . . . . . . . . . . . . . . Short answer -7 Long answer Signed integers are two’s complement binary values that can be used to represent both positive and negative integer values. Source: Intels IA-32 Architectures [...]

C Puzzle #2

C - programming language - thumb

What is the output of the following script? Why? How can it be fixed to get the expected output? . . . . . . . . . . . . . . . . . Answer Expected output Explanation 1<<30 does a bitshift for int, not for uint64_t How to fix it Add a [...]

Java Puzzle #13: Absolute value weirdness

Java Thumbnail

What does the following snippet output? . . . . . . . . . . . . . . . . . . . . . . Answer Explanation Integer values range (in Java) from -2147483648 to 2147483647. This means, the absolute value of -2147483648 is not in the integer range. For more details, [...]

Java Puzzle #12: Control-flow

Java Thumbnail

What is the output of the following HelloWorld.java? . . . . . . . . . . . Answer The output is “Yes”. Explanation The ; means, that no block is executed. The { … } is just a code block and not really related to the if-statement.

Java Puzzle #11: Change argument of foreach

Java Thumbnail

What is the output of the following HelloWorld.java? . . . . . . . . . . . . . . . . . . . . . . . . Answer

Python Puzzle #3: Associativity

Python-Logo

What is the output of and what is the output of or . . . . . . . . . . . . . . . . . . . . . . . . . Answer The first expression evaluates to False, because it gets evaluated as (1 in []) and ([] in [...]

Java Puzzle #10: Multiple Interfaces

Java Thumbnail

You have to following source code: A.java: B.java: test.java: What is the output? Does it compile? Is there a RuntimeException? . . . . . . . . . . . . . . . . . Answer Output: Explanation If you use an Interface, it simply means you have to implement some methods. If [...]