Home › Programming Questions on Static Programming Questions on Static Posted by: InstanceOfJava Posted date: Dec 31, 2014 / comment : 1 1. what is the output of following program: package com.instanceofjavaforus; public class StaticDemo{ static { i=10; } static int i; public static void main(String[] args) { System.out.println("i= "+i); } } Click for Output i= 10 2. what is the output of following program: package com.instanceofjavaforus; public class StaticDemo{ static { i=10; } static int i; public static void main(String[] args) { StaticDemo obj= new StaticDemo(); obj.i=20; System.out.println("i= "+StaticDemo.i); } } Click for Output i= 20 Share !
nice
ReplyDelete