ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Code Snippets  >>  Programming Code  >>  Java Code  >>  J2SE Code
 
 


 

 
 J2SE Code interview questions  J2SE Code Interview Questions
 J2EE Code interview questions  J2EE Code Interview Questions
 J2ME Code interview questions  J2ME Code Interview Questions
Question
how to print a message to console without using main() 
function?(do not use even static blocks also.)
 Question Submitted By :: Rajavardhan Reddy K
I also faced this Question!!     Rank Answer Posted By  
 
  Re: how to print a message to console without using main() function?(do not use even static blocks also.)
Answer
# 1
using a static block you can print the message (string)s.o.p
 
Is This Answer Correct ?    3 Yes 10 No
Narender
 
  Re: how to print a message to console without using main() function?(do not use even static blocks also.)
Answer
# 2
use a constructor and declare a global object.

class message
{

      public:
     message("Hello world\n");
}a;
void main(){}
 
Is This Answer Correct ?    8 Yes 8 No
Vijay Nag
 
 
 
  Re: how to print a message to console without using main() function?(do not use even static blocks also.)
Answer
# 3
class testing{
    public testing(){
	System.out.println("Hello ");
    }
}
public class TestClass{
    static testing t = new testing();
    public TestClass(){
    }
}
 
Is This Answer Correct ?    9 Yes 6 No
Cvs
 
  Re: how to print a message to console without using main() function?(do not use even static blocks also.)
Answer
# 4
class testprint 
{
	static String print=testprint.toString("test");
	public static String toString(String s)
	{
		System.out.println("I am Here");
		return s;
	}
}
 
Is This Answer Correct ?    5 Yes 4 No
Amit Dubey
 
  Re: how to print a message to console without using main() function?(do not use even static blocks also.)
Answer
# 5
public class classWithoutMain {
	private static int x = load();
	private static int load() {
		System.err.println("This message will be printed");
		System.exit(0);
		
	}
}
 
Is This Answer Correct ?    1 Yes 3 No
Jaya
 
  Re: how to print a message to console without using main() function?(do not use even static blocks also.)
Answer
# 6
Sorry. Missing return statement in the former post

public class classWithoutMain {
	private static int x = load();
	private static int load() {
		System.err.println("This message will be printed");
		System.exit(0);
		return 0;
	}
}
 
Is This Answer Correct ?    2 Yes 4 No
Jaya
 

 
 
 
Other J2SE Code Interview Questions
 
  Question Asked @ Answers
 
How to create and run runnable jar file of a Java Project. HCL3
how to print a message to console without using main() function?(do not use even static blocks also.) Google6
how to store and retrive a set of values without using an array Maximus4
inner join,outerjoin,trigger,stored procedure explain with code snippets?  1
How can we get the details for printing the employee details at run time using JDBC connectivity? can u provide the coding for that? Its urgent?  1
 
For more J2SE Code Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com