Skip to content
javabypankaj
HomeLibraryPopularCommunity
01
Core Java
32 topics · 170 questions
1JDK, JRE & JVM0/442Variables, Scope & var0/333Primitive Types & Wrappers0/11114Operators & Expressions0/995The main Method0/56Access Modifiers0/117Keywords: final0/448Keywords: static0/449Methods & Varargs0/3310Constructors & this/super0/3311Enum0/2212String & String Pool0/121213Immutability0/4414Arrays0/4415Object Class, equals & hashCode0/9916Upcasting & Dispatch0/2217Pass-by-Value & References0/2218Object Cloning0/2219Inner Classes0/2220Marker Interface0/1121Exception Hierarchy0/2222I/O & System0/3323Serialization & transient0/111124Annotations0/3325Recursion0/1126Reflection & Object Creation0/2227Interface Evolution0/1128Class Loading & Compilation0/4429Memory Management & GC0/212130JVM Internals: Advanced0/101031JVM Tuning & Troubleshooting0/151532Predict the Output0/1010
1JDK, JRE & JVM42Variables, Scope & var33Primitive Types & Wrappers114Operators & Expressions95The main Method56Access Modifiers17Keywords: final48Keywords: static49Methods & Varargs310Constructors & this/super311Enum212String & String Pool1213Immutability414Arrays415Object Class, equals & hashCode916Upcasting & Dispatch217Pass-by-Value & References218Object Cloning219Inner Classes220Marker Interface121Exception Hierarchy222I/O & System323Serialization & transient1124Annotations325Recursion126Reflection & Object Creation227Interface Evolution128Class Loading & Compilation429Memory Management & GC2130JVM Internals: Advanced1031JVM Tuning & Troubleshooting1532Predict the Output10
32 topics170 Qs0%
01Core Java17002OOP3203Collections6704Exception Handling2805Concurrency & Multithreading12706Java Streams, Lambda & Functional Programming32807Spring & Spring Boot2608Transactions3209JPA & Hibernate6910Microservices19411Kafka & Messaging9112DevOps, CI/CD & Tooling13313Database & SQL14114REST API & Web4015Design Patterns & LLD5716Advanced Java7117Coding Problems: DSA49218AWS & Cloud4119Data Engineering19420QA, Testing & SDET4121System Design3522Security2023Behavioral / HR: STAR Method37
32Topics
170Questions
0%Complete
5 of 32 topics
Topics
1JDK, JRE & JVM0/442Variables, Scope & var0/333Primitive Types & Wrappers0/11114Operators & Expressions0/99
5The main Method0/55
6Access Modifiers0/117Keywords: final0/448Keywords: static0/449Methods & Varargs0/3310Constructors & this/super0/3311Enum0/2212String & String Pool0/121213Immutability0/4414Arrays0/4415Object Class, equals & hashCode0/9916Upcasting & Dispatch0/2217Pass-by-Value & References0/2218Object Cloning0/2219Inner Classes0/2220Marker Interface0/1121Exception Hierarchy0/2222I/O & System0/3323Serialization & transient0/111124Annotations0/3325Recursion0/1126Reflection & Object Creation0/2227Interface Evolution0/1128Class Loading & Compilation0/4429Memory Management & GC0/212130JVM Internals: Advanced0/101031JVM Tuning & Troubleshooting0/151532Predict the Output0/1010

The main Method

Core Java·Topic 5 of 32·5 questions
Q1Why is the main method public, static, and void?

public so the JVM can access it from outside, static so no object is needed, void because there is no caller to return to. String[] args receives command-line arguments.

Read Answer
Q2Can the main method be overloaded?

Yes, main can be overloaded with different parameter types. But the JVM always calls the String[] version as the entry point. The others are just regular methods.

Read Answer
Q3Can the main method be overridden?

No. Static methods cannot be overridden – they are resolved by the class, not the object. A subclass can define its own main, but it hides the parent's rather than overriding it.

Read Answer
Q4Can you have two main methods in a Java application?

Yes. Multiple classes can each have main(String[] args). You choose which one to run by specifying the class name. In a jar, the MANIFEST.MF Main-Class attribute selects the default.

Read Answer
Q5Can varargs replace String[] args in the main method?

Yes. String... args is compiled to the same bytecode as String[] args, so the JVM accepts it as a valid entry point. But the convention is to use String[] args.

Read Answer
Previous · Topic 4Operators & Expressions9 questionsNext · Topic 6Access Modifiers1 questions
javabypankaj© 2026 javabypankaj
PrivacyTerms
HomeSearchLibrary