Sreemaha

Sreemaha

51 Articles Published

Articles by Sreemaha

Page 6 of 6

Why are classes sometimes declared final in Java?

Sreemaha
Sreemaha
Updated on 30-Jul-2019 694 Views

If a class is declared final, you cannot inherit it. If you try it gives you a compile-time error as − Example final class Super { private int data = 30; } public class Sub extends Sub { public static void main(String args[]){ } } Output Exception in thread "main" java.lang.Error: Unresolved compilation problem: at Sub.main(Sub.java:7)

Read More
Showing 51–51 of 51 articles
« Prev 1 2 3 4 5 6 Next »
Advertisements