Why Static variable required in java?For ex,class A
{
static int a;
int b;
}
Why static is required?

Answers were Sorted based on User's Feedback



Why Static variable required in java?For ex,class A { static int a; int b; } Why static is requ..

Answer / za

because it help us to declare class field asglobal variable

Is This Answer Correct ?    3 Yes 0 No

Why Static variable required in java?For ex,class A { static int a; int b; } Why static is requ..

Answer / sumit pal singh

static keyword is mainly used for memory management purpose. And static variable is used for declare the common property of object.

Is This Answer Correct ?    3 Yes 0 No

Why Static variable required in java?For ex,class A { static int a; int b; } Why static is requ..

Answer / aswini

Without using instance of the class means no need to use the class object to call static variable insted directly use the classname to use the static variable.moreover ,only one copy of static varible avaible to use all the classes.

Is This Answer Correct ?    2 Yes 0 No

Why Static variable required in java?For ex,class A { static int a; int b; } Why static is requ..

Answer / soumya

what is the advantage to declare a var as static instead of instance var..can you please tell me in brief?

Is This Answer Correct ?    1 Yes 0 No

Why Static variable required in java?For ex,class A { static int a; int b; } Why static is requ..

Answer / vaishnavi

To answer Soumya's question, instance variables are declared at class level, but the instance variables still belong to an instance/object. But static variables belong to a class.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Which are different kinds of source code?

0 Answers  


What is Java Reflection API? Why it’s so important to have?

0 Answers  


Is there any case when finally will not be executed?

0 Answers  


Explain about abstract classes in java?

0 Answers  


What is the biggest integer?

0 Answers  






What is the relationship difference the canvas class and the graphics class?

0 Answers  


What is the use of private static?

0 Answers  


What is the minimum and maximum length of an identifier?

6 Answers   TCS,


solve (x-1)(x-9)=8;

3 Answers   IBM, Manhattan, TCS,


When is the finally clause of a try-catch-finally statement executed?

0 Answers  


How do you relate a Interface to a Class? Tell me in Detail?

4 Answers  


How many types of assembly languages are there?

0 Answers  


Categories