Answer:
First of all we can not write non-static methods inside static class,but if we try to write non-static methods inside static classes,then we will get compile-time error as:
'Method': cannot declare instance members in a static class
Meaning that if we write non-static methods,then we have to access this method by creating object of class,and as static classes do not have instance constructor.So how can we access non-static methods.that's why we can not write non-static methods inside static class.
Asked In: Many Interviews |
Alert Moderator