how to print a message to console without using main()
function?(do not use even static blocks also.)




Answers were Sorted based on User's Feedback



how to print a message to console without using main() function?(do not use even static blocks als..

Answer / cvs

class testing{
public testing(){
System.out.println("Hello ");
}
}
public class TestClass{
static testing t = new testing();
public TestClass(){
}
}

Is This Answer Correct ?    29 Yes 18 No

how to print a message to console without using main() function?(do not use even static blocks als..

Answer / s.j

in c language
#define main begin
void begin()
{
printf("HELLO");
}

Is This Answer Correct ?    10 Yes 3 No

how to print a message to console without using main() function?(do not use even static blocks als..

Answer / shanu zabeen

class testing
{
public testing()
{
System.out.println("world");
}
}

public class Demo
{
static testing t = new testing();
public Demo()
{
}
}

Is This Answer Correct ?    4 Yes 2 No




how to print a message to console without using main() function?(do not use even static blocks als..

Answer / harsha

#include<stdio.h>
#define func main
int func()
{
printf("Virat
");
}

Is This Answer Correct ?    0 Yes 0 No

how to print a message to console without using main() function?(do not use even static blocks als..

Answer / s.j

in c language
#define begin main();
void begin
{
printf("HELLO");
}

Is This Answer Correct ?    0 Yes 1 No

how to print a message to console without using main() function?(do not use even static blocks als..

Answer / vijay nag

use a constructor and declare a global object.

class message
{

public:
message("Hello world\n");
}a;
void main(){}

Is This Answer Correct ?    18 Yes 20 No

how to print a message to console without using main() function?(do not use even static blocks als..

Answer / jaya

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 ?    4 Yes 7 No

how to print a message to console without using main() function?(do not use even static blocks als..

Answer / amit dubey

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 ?    6 Yes 10 No

how to print a message to console without using main() function?(do not use even static blocks als..

Answer / jaya

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 ?    2 Yes 7 No

how to print a message to console without using main() function?(do not use even static blocks als..

Answer / ravi kumar

No method can be called with out using main() method.
Every program execution starts from main() method only.
even you declare the methods inside the main() method class or out side the main() method class.

Is This Answer Correct ?    1 Yes 6 No

Post New Answer



More J2SE Code Interview Questions

Design a program using one-dimensional array that determines the highest value among the eight input values from a user. Display the difference of each value from the highest to the lowest.

1 Answers   RoboSoft,


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?

2 Answers  


For printing a message we use System.out.println in normal programs. We use String msg="text....."; Can't we use String msg=" " in normal programs and System.out.println("........") in applets. Please answer this question?

0 Answers  


write a program that will ask the user to enter a number n and display the product of all numbers from 1 to n.

1 Answers  


1+(2*3)+(4*5*6)+(7*8*9*10)+... specified input value

1 Answers   MAQ,






How to create Date method to set the date in Ms Access

0 Answers  


write a program in java to solve a system of n-variabled simultaneous equations using the guassian elimination method. let the maximum possible value of n be 100. run the program using hypothetical values for a set of 10- variables simultaneous equations. print out the program, the input equation and the results generated by the program.

0 Answers   TCS,


Is there any static classes are in java give some examples

0 Answers  


I am trying to pass the string firstName from a Servlet called SampleServet. I am running this on eclipse and it tells me that "the value for annotation attribute must be a constant expression. I don't understand why it is giving me this error. @PersonAnnotation(name = SampleServlet.firstName) public class AnnotationClass{

0 Answers  


Why we r using String args[] in main() even though v r not passing any arguments in command line?

2 Answers  


Is it possible to define marker interface in java.If possible then how to define user defined marker interface?

1 Answers   Tech Mahindra,


Can we run Applet in Web browser with security policy files

0 Answers  






Categories