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 demonstrate single inheritance, multilevel inheritance and hierarchical inheritance.

Write a java program to create 3 threads using Thread class. Three threads should calculate the sum of 1 to 5, 6 to 10 and 11to 15 respectively. After all thread finishes main thread should print the sum and average.