Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Mock test doubt?

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
code:

public class Droitwich{
class one{
private class two{
public void main(){
System.out.println("two");
}
}
}
}

in the above code main class not declared as public static,how it will compile with out errors.In answer it is compile successfully,but I got fatal error.
can anyone explain this how it will work.

Thanks in advance..
 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by swati:
code:

public class Droitwich{
class one{
private class two{
public void main(){
System.out.println("two");
}
}
}
}

in the above code main class not declared as public static,how it will compile with out errors.In answer it is compile successfully,but I got fatal error.
can anyone explain this how it will work.

Thanks in advance..



Your programm will compile but it cannot run since the main is not defined correctly:

The main method you write is consider like a simple method. It's equivalent to:

I hope i clear your doubt.
[ September 04, 2007: Message edited by: Collins Mbianda ]
 
What's that smell? I think this tiny ad may have stepped in something.
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic