Saturday 6 April 2013

MCQ #11

Question) Are you allowed to have more than one top level (non inner) class definition per source file?

Options)

  • No
  • Yes
Answer) Yes

Explanation) Yes you can have multiple top level class definitions per source file. Yeah, it's also true that the source file name must be same as that of the class name. To resolve both these constraints Java states some basic rules which are -
  1. Out of the multiple top level classes defined only one can be public.
  2. Source file name must match this public class name.

No comments:

Post a Comment

t> UA-39527780-1 back to top