TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Monday 13 April 2020

Instance Initializer Block In Java | Instance Initializer Block In Java In Hindi

Instance initializer block

Instance Initializer block is used to initialize the instance data member. It run each time when object of the class is created.

The initialization of the instance variable can be done directly but there can be performed extra operations while initializing the instance variable in the instance initializer block.



instance initializer block in java example

Fig: Instance initializer block 


Example of instance initializer block


    class Bike7{  

    int speed;  
    Bike7(){System.out.println("speed is "+speed);}  
    {speed=100;}     
    public static void main(String args[]){  
    Bike7 b1=new Bike7();  
    Bike7 b2=new Bike7();  
    } }  


      Output:


         speed is:100
         speed is:100

No comments:

Post a Comment