Write a program in Java to demonstrate use of final class.

 

AIM: Write a program in Java to demonstrate the use of the final class.

CODE:

final class Demo{

            final int a=10;

            final void disp(){

                        System.out.println("Final variable="+a);

            }

}

public class p24 extends Demo{

            public static void main(String args[]){

                        Demo d= new Demo();

                        d.disp();

            }

}

OUTPUT:



Comments

Popular posts from this blog

Write a program in Java to perform I/O operations on a Text file.

Describe abstract class called Shape which has three subclasses say Triangle, Rectangle, and Circle. Define one method area()in the abstract class and override this area() in these three subclasses to calculate for specific object.