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 ?    1 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 2 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 21 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 8 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 11 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

Why the program getting error if we don't use String args[] in main(), even in the case of not getting any arguments from command line?

1 Answers  


inner join,outerjoin,trigger,stored procedure explain with code snippets?

1 Answers   IBM,


write a program that inputs two real numbers then exchanges their values.

7 Answers   Infosys,


How to create and run runnable jar file of a Java Project.

4 Answers   TCS, Wipro, US Consulate, HCL, Tech Mahindra,


how to create a (*)pyramid using java codes???

5 Answers   Infosys,






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

1 Answers   Tech Mahindra,


Bubble Sort. java thereafter the user will be asked to inpout the size of the list,sort the list in ascending order and display the sorted list in a horizontal manner???

0 Answers  


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

2 Answers  


write a java program to create a Frame with three scrolls, change the back ground color of the frame using functions with values of scrolls.

0 Answers  


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

12 Answers   Google, Zoho,


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,


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  






Categories