Home Java Code Java Code Puzzle #3
Java Code Puzzle #3 PDF Print E-mail
Written by Administrator   
Friday, 05 June 2009 12:28

What does the following print (assuming it compiles, which it does):

public class StrungOut {

 

      public static void main(String[] args) {

            String s = new String("Hello world");

            System.out.println(s);

      }

}

 

class String{

      private final java.lang.String s;

      public String(java.lang.String s){

            this.s = s;

      }

      public java.lang.String toString(){

            return s;

      }

}

 
Copyright © 2013 JavaPgmr.net. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.
 

Related Links