Skip to content
CodeKruPro

A class without main, and two public classes in one file

QuizMediumJava onlyAsked in: TCS

Which statements are true for Java 21 (without preview features)? Pick all that apply.

  • Running a class that has no main method fails with "Main method not found"
  • A static block can be used instead of main to run code
  • A file can hold only one public top-level class, named like the file
  • A file can hold several non-public top-level classes

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in