PDA

View Full Version : Code Puzzles



ghostfucker
23.08.12, 18:16
proove your coding skills with code puzzles :)
- don't use a compiler
- think twice ;)



i'll start with a neat java puzzle:
- does this compile? why? why not?
- what will happen if you remove the fifth line? why?


1. public class Test {
2. public static void Main(String[] args) {
3. System.out.print("The SB-Innovation URL: ");
4. http://www.sb-innovation.de/
5. System.out.println(".");
6. }
7. }

ParamouR
24.08.12, 17:35
This should compile/run if you edit the "main"



Maybe you would have to comment 4th line, don't know :confused:

Lucius
03.10.14, 18:16
- does this compile? why? why not?
- what will happen if you remove the fifth line? why?


1. public class Test {
2. public static void Main(String[] args) {
3. System.out.print("The SB-Innovation URL: ");
4. http://www.sb-innovation.de/
5. System.out.println(".");
6. }
7. }


1. It won't compile because of the 4th line. you have to comment it.
2. the compiler won't print a new line with "." in it, so after commenting the 4th line the result will be:

The SB-Innovation URL: .

After removing the 5th line the result will be :

The SB-Innovation URL:

aflamtk
14.02.22, 05:23
nope syntax error on 4th line