Showing posts with label Tricky Java Program 2. Show all posts
Showing posts with label Tricky Java Program 2. Show all posts

Monday, June 21, 2010

Solution to the tricky program 2

 Solution to the program http://javacoderblog.blogspot.com/2010/05/tricky-program-1-to-java-beginners.html

import java.io.*;
public class NMM
{
static
{

final PrintStream out = System.out;

PrintStream newOut = new PrintStream(out)
{

public void println(String str1)
{
print("Great ");
print(str1);
super.println("Programmer");
}
};

System.setOut(newOut);
}


public static void main(String [ ]argums)
{
System.out.println("Java ");
}
}

Tuesday, May 18, 2010

A tricky program 2 to Java Beginners,

Question:- You should bring the output by not modifying the main method,The output is "Great Java Programmer".

class NMM //No main method
{
public static void main(String []args)
{
System.out.println(“Java”);
}
}Seems to be tricky for you right?.Let us see what is answer in the next post..If you know the answer just post as comment or mail to me.

UPDATE: Check out the solution here http://javacoderblog.blogspot.com/2010/06/solution-to-tricky-program-2.html