Can a class be declared as static? Ans.We can not declare top level class as static, but only inner class can be declared static. public class Test { static class InnerClass { public static void InnerMethod() { System.out.println('Static Inner Class!'); } } public static void main(String args[]) { Test.InnerClass.InnerMethod(); } } //output: Static Inner Class! - Study24x7
Social learning Network
12 Oct 2023 09:56 AM study24x7 study24x7

Can a class be declared as static? Ans.We can not declare top level class as static, but only inner class can be declared static. public class Test { static class InnerClass { public static void InnerMethod() { System.out.println("Static Inner Class!"); ...

See more

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles