1. what is the output of following program:

  1. package com.instanceofjavaforus;
  2.  
  3. public class StaticDemo{
  4.  
  5.  
  6.    static {
  7.           i=10;
  8.     }
  9.  
  10.     static   int i;  
  11.  
  12.       public static void main(String[] args) {
  13.  
  14.        System.out.println("i= "+i);
  15. }
  16. }





2. what is the output of following program:

  1. package com.instanceofjavaforus;
  2.  
  3. public class StaticDemo{
  4.  
  5.    static {
  6.           i=10;
  7.     }
  8.  
  9.     static   int i;  
  10.  
  11.       public static void main(String[] args) {
  12.         StaticDemo obj= new StaticDemo();
  13.           obj.i=20;
  14.  
  15.        System.out.println("i= "+StaticDemo.i);
  16. }
  17. }






Instance Of Java

We are here to help you learn! Feel free to leave your comments and suggestions in the comment section. If you have any doubts, use the search box on the right to find answers. Thank you! 😊
«
Next
Newer Post
»
Previous
Older Post

1 comments for Programming Questions on Static

Select Menu