सीधे मुख्य सामग्री पर जाएं

#47 What is difference between Static & Instance block in Java | Static & Instance block क्या है

package com.sudhirtheindian2.java123;

public class instance_vs_static {

public static void main(String[] args) {

// What is difference between instance block & static block in java


// Instance Block

// Note -- instance block called before the constructor


// 1 it deals with object
// 2 executed at the time of object creation
// 3 no any keyword required
// 4 static & non static variable can be accessed
// inside the instance block



// Static Block
// 1 It deals with class
// 2 Executed at the time of loaded .class file in java
// 3 static keyword is required
// 4 only static variable can be accessed
// inside the static block





}
}

टिप्पणियाँ

इस ब्लॉग से लोकप्रिय पोस्ट