Results 1 to 3 of 3

Thread: Code Puzzles

  1. #1

    Code Puzzles

    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?
    Code:
    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. }
    Last edited by ghostfucker; 23.08.12 at 18:17.
    Reply With QuoteReply With Quote
    Thanks

  2. #2
    Advanced User Jewel Thief Champion, Super Mario Flash Champion, Quick Shoot Champion, Mafia Driver Champion ParamouR's Avatar
    Join Date
    01.09.10
    Location
    Third Rome
    P2P Client
    µ
    Posts
    773
    Activity Longevity
    1/20 15/20
    Today Posts
    0/5 ssssss773
    This should compile/run if you edit the "main"




    Maybe you would have to comment 4th line, don't know
    Show respect to all people, but grovel to none​


    Reply With QuoteReply With Quote
    Thanks

  3. #3
    Quote Originally Posted by ghostfucker View Post

    - does this compile? why? why not?
    - what will happen if you remove the fifth line? why?
    Code:
    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:
    Code:
    The SB-Innovation URL: .
    After removing the 5th line the result will be :
    Code:
    The SB-Innovation URL:
    Last edited by Lucius; 03.10.14 at 18:20.
    Reply With QuoteReply With Quote
    Thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •