what is difference between static and non-static variables

Answer Posted / mahesh_b.tech@2008

Non-static variables:

Instance block can be executed automatically when you were
creating the object.

Instance variables can be called by using with the object.

Instance variables can not called by using the class name.

memory will be alocated for instanse variables when you
create the object.

Static variables:

static block will be executed automatically when jvm(Java
Virtual Machine)loading the class into memory.

static varisble can be called using both objectname&class
name.

memory will be allocated when jvm loads the class.

Is This Answer Correct ?    13 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is constructor in C++?

834


What is math h in c++?

837


Can we run c program in turbo c++?

809


What is buffering in c++?

817


Is set c++?

756


What is general form of pure virtual function? Explain?

729


Do you know the problem with overriding functions?

815


What is the difference between *p++ and (*p)++ ?

1011


Which sort does c++ use?

806


What is a rooted hierarchy?

879


When is dynamic checking necessary?

802


What are the basics of local (auto) objects?

842


Difference between a copy constructor and an assignment operator.

769


How should a contructor handle a failure?

915


How can you quickly find the number of elements stored in a dynamic array?

806