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

Who was the creator of c++?

790


What is bubble sort c++?

795


Will rust take over c++?

811


What is do..while loops structure?

843


total amount of milk produced each morning and then calculates and outputs the number of cartons needed for this milk , the cost of producing the milk and the profit from producing this milk.

2325


What data encapsulation is in c++?

795


Can we use this pointer in a class specific, operator-overloading function for new operator?

857


What is the difference between cin.read() and cin.getline()?

836


Is map sorted c++?

757


Can a new be used in place of old mallocq? If yes, why?

876


What is the difference between public and private data members?

909


What are the advantages of prototyping?

820


How do you declare A pointer to a function which receives nothing and returns nothing

971


What is the main function c++?

857


What do you mean by persistent and non persistent objects?

1104