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 an application that illustrates method overriding in the same package and different packages. Also demonstrate accessibility rules in inside and outside packages

Write a program that illustrates interface inheritance. Interface P12 inherits from both P1 and P2. Each interface declares one constant and one method. The class Q implements P12. Instantiate Q and invoke each of its methods. Each method displays one of the constants.

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