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 const pointer and const reference?

591


What is the best way to declare and define global variables?

695


Eplain extern keyword?

560


Is swift faster than c++?

560


what is Loop function? What are different types of Loops?

638






What is polymorphism and its type in c++?

588


Can a program run without main?

625


Explain stack unwinding.

632


Can user-defined object be declared as static data member of another class?

552


Why is polymorphism useful?

563


How const int *ourpointer differs from int const *ourpointer?

606


What is the c++ programming language used for?

579


Is c++ high level programming language?

673


How can I learn c++ easily?

620


What is command line arguments in C++? What are its uses? Where we have to use this?

575