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  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
What happens when a main method is declared as private?
 Question Submitted By :: Harsha
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What happens when a main method is declared as private?
Answer
# 1
When a method is declared as private, the program compiles 
properly but it will give runtime error ?Main method not 
public"
 
Is This Answer Correct ?    9 Yes 0 No
Harsha
 
  Re: What happens when a main method is declared as private?
Answer
# 2
IF MAIN METHOD IS DECLARED AS PRIVATE ,THEN WE CAN NOT 
ACESSES THE PRVIATE MEMBERS IN ANOTHER CLASS
 
Is This Answer Correct ?    1 Yes 9 No
Varsha Vilas Kalebag
 
 
 
  Re: What happens when a main method is declared as private?
Answer
# 3
Nothing Happen.
Code compiles properly and executes properly.
 
Is This Answer Correct ?    1 Yes 14 No
Vani
 
  Re: What happens when a main method is declared as private?
Answer
# 4
Wrong Vani.

The output of the program is

C:\>javac abc.java

C:\>java abc
Main method not public.
 
Is This Answer Correct ?    16 Yes 0 No
Yogesh Gandhi
 
  Re: What happens when a main method is declared as private?
Answer
# 5
If the main function is made private...it will compile 
Sucessfully...and at the time of execution...it will 
execute successfully...but desired result will not be 
obtained. After execution..folowin message will be printed:
Main method not public.
 
Is This Answer Correct ?    4 Yes 0 No
Amit Kumar Chaubey
 
  Re: What happens when a main method is declared as private?
Answer
# 6
it compile easily... but it will give an error at the time 
of execution .....
 
Is This Answer Correct ?    3 Yes 1 No
Ashish
 
  Re: What happens when a main method is declared as private?
Answer
# 7
vani, varsha is correct , the 'private main method' is as
good as any member method your class can have (note that
main is not a key word in java) , it can be only used inside
the class in which it is defined. 

It is clearly mentioned in the specifications that the
executing class should contain a 'public static void method'
as a point of execution otherwise execution will fail
complaining ABOUT THE METHOD WHICH I MENTIONED ABOVE.
 
Is This Answer Correct ?    0 Yes 0 No
Pawan
 
  Re: What happens when a main method is declared as private?
Answer
# 8
JVM is also a program. If main() is declared as privateit 
is not available outside of that class . So JVM through the 
exception.
 
Is This Answer Correct ?    2 Yes 0 No
Srinivasa
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
Is it possible to write static method in abstract class? justyfy your answer? Hexaware3
how to print output with out using sop statements UHG3
Name the methods in mouse listeners ?  3
what is meant by UP& DOWN casting in java?  4
What will happens if you opened Internet Explorer 4 times?  2
Difference between prefix and postfix forms of the ++operator?  2
explain the life cycle of thread? CTS5
What is a deadlock ?  5
how can u handle run time exception in java? explain with brief explanation with examples? CTS2
suppose string s1="rajnish"; string s2="bhaskar"; then what will be happend ? Fidelity6
what is difference between colection and collections? Tech-Mahindra8
What is the difference between Checked and Unchecked exception? Give some examples Ness-Technologies2
if arraylist size is increased from initial size what is the size of arraylist...suppose initial is 100 , if i add 101 element what is the size...  6
what is Inheritense Tech-Mahindra1
Why we can not force Garbage Collection?  5
what is multitherading Tech-Mahindra2
Name the types of mouse event listeners ?  2
What is meant by JVM ?  3
What are hot spots in Java programming?  1
basic difference b/w ALL types of JDBC driver. Systematix1
 
For more Core Java 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