Java - Static KeywordWhich of the following is the correct syntax to declare a static method in Java?Apublic static void methodName() {}Bstatic public void methodName {}Cvoid static public methodName() {}Dpublic void static methodName() {}Check Answer
Step-by-Step SolutionSolution:Step 1: Recall Java method declaration orderThe correct order is access modifier, then static keyword, then return type, then method name.Step 2: Check each optionpublic static void methodName() {} follows the correct order: public static void methodName()Final Answer:public static void methodName() {} -> Option AQuick Check:Static method syntax = public static returnType name() [OK]Quick Trick: Access modifier before static keyword in method declaration [OK]Common Mistakes:Placing static after return typeMixing order of keywords in method declaration
Master "Static Keyword" in Java9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Java Quizzes Methods and Code Reusability - Method declaration - Quiz 7medium Methods and Code Reusability - Why methods are needed - Quiz 3easy Packages and Access Control - Creating packages - Quiz 7medium Packages and Access Control - Why packages are used - Quiz 9hard Static Keyword - Static blocks - Quiz 4medium Strings and String Handling - StringBuilder and StringBuffer - Quiz 8hard Strings and String Handling - String vs StringBuilder - Quiz 9hard Wrapper Classes - Common wrapper methods - Quiz 3easy Wrapper Classes - Why wrapper classes are used - Quiz 11easy Wrapper Classes - Why wrapper classes are used - Quiz 13medium