Home Answers Viewqa Java-Interview-Questions why using static keyword

 
 


hariramaraju
why using static keyword
3 Answer(s)      2 years and 3 months ago
Posted in : Java Interview Questions

why using static keyword

View Answers

February 27, 2011 at 10:14 PM


Hi,

The static variable is declared by using static keyword. Following is an example of static declaration:

static int i=10;

The variable declared with static keyword is called class variable. This variable is shared by all the instances of the class. The static variable can be accessed without creating the instance of the class.

This variable is created statically and same variable is accessed by all instance of the class.

Check the tutorial static Java Keyword.

Thanks


August 13, 2012 at 7:27 PM


static variable & static methode is directly access with help of class name. mean static variable or method belong only class name.


January 3, 2013 at 4:15 PM


What is Static Keyword
In Java,the Static Keyword enables a class/ method / or variables accessible without creating an instance of the class that contains the Static methods and variables.









Related Pages:
why using static keyword
why using static keyword  why using static keyword
static keyword in interface
static keyword in interface  Could any one explain,why static keyword implict (or explict ) come in interface? I asked lot of persons about this question, but nobody did not answered clearly. please explain clearly and say what
Static keyword in public static void main
: static keyword indicates that this method can be invoked simply by using the name... is declared by using static keyword. Following is an example of static declaration...Static keyword in public static void main  Hi, I have seen
static keyword
static keyword  please give some detail about Static keyword.   Static Variables Static variables are class variables that are shared... and not to object(instance). 2)Static variables are initialized only once , at the start
static keyword
static keyword  Hii, In which portion of memory static variables stored in java. Is it take memory at compile time? thanks deepak mishra
static keyword with real example
static keyword with real example  static keyword with real examplestrong text
making consistency of data member in the whole programme without using static keyword
making consistency of data member in the whole programme without using static keyword  In the below programme i use one boolean variable named check... use static but i want to know some alternative way ..could anyone give me some
static
instances of the class. When static is applied to methods, the static keyword...static  what r the main uses of static in java   Hi Friend, The Static means that a certain object/variable is resident in memory
static
is why if you declare the function main as static then java does not have...Static Concept  in what are all the situation we may use static...,then use static blocks and without creation of object we need to perform some task
static Java Keyword
static Java Keyword       The static is a keyword defined in the java programming language. Keywords... in java programming language likewise the static keyword indicates the following
Why is the main method declared static?
Why is the main method declared static?  Hi, Why is the main method declared static? thanks   Hi, When we declare main() method in any Java class always has the same signature, and we declare public static void main
Static variable in java
Static variable in java. Static is a keyword in java used to create static.... Static variable is accessed without creating object of class using class name...; Classname.variablename; Example: Using Static Variable. public class Staticvariable
PHP Static Variable and Methods
PHP Static Methods and Variables: In this tutorial we will study when we should use static methods and variables. Static keyword is used to make only one... the method using class, without instantiating any object. Example of PHP Static
The interface keyword
variable i.e. the variables defined as final and static. One benefit of using... The interface keyword       In java programming language the keyword interface in java is used
final keyword
final keyword  why is final keyword used in java
Static Nested Classes
class having keyword static in the outer class. class OuterClass... Static Nested Classes       A nested class that is declared static is called a static nested class
static methods
static methods  why static methods cannot read or write the instance variables
Return keyword
of return keyword import java.util.*; public class ReverseString{ public static String reverse(String st){ String rev = new StringBuffer(st).reverse().toString(); return rev; } public static void main(String
Super keyword in java
Super keyword in java In this section we will discuss about the super keyword in java. Super is a keyword defined in java. Super is used to refer... of the super class method ,then we can invoke the super class method using
Static Variable
. When static is applied to methods, the static keyword means that the specified...Static Variable  What is the basic use of introducing static variable type in java?Please explain clearly....   The Static means
Using throw keyword in exception handling in Core Java
. The throw keyword tells the compiler that it will be handled by calling a method... { public static FileInputStream file1(String fileName) { FileInputStream... static void main(String args[]) { FileInputStream fileIn; String fileName
Why we are writting public static void main(String args[])?
Why we are writting public static void main(String args[])?  Why we are writting public static void main(String args[])? please elaborate it... and also explain the statement System.out.println("abc
SQL as Keyword
SQL as Keyword      ... keywords like, create table keyword is used to create a table Stu_Table..._Table using create table Statement. The insert into add the records
The final Keyword
The final Keyword       The final is a keyword. This is similar to const keyword in other languages. This keyword may not be used as identifiers i.e. you cannot declare
why this can't
why this can't  import java.util.*; class Dash{ public static void main(String args[]){ int x0=100; int[] x1=new int[3]; int[][] x2=new int[3][3]; int[][][] x3=new int[3][3][3
The extends Keyword
The extends Keyword       The extends is a Java keyword, which is used in inheritance process of Java. It specifies the superclass in a class declaration using extends keyword
The While keyword
using the keyword while. public class Myclass { while (expression... The While keyword       While is a keyword defined in the java programming language. Keywords
STATIC VARIABLE DECLARATION
STATIC VARIABLE DECLARATION  why cannot the static variable declare inside the method
private static final
private static final  Why there is necessary to make a variable private static final
Why this is not working...?
Why this is not working...?  import java.util.*; public class Family { int size_of_family=0; public Person[] members=new Person[size_of_family..."); } } } public static void main(String[] args) { Person
The byte Keyword
The byte Keyword       The byte Java Keyword defines the 8-bit integer primitive type.  The keyword byte in Java is a primitive type that designates with eight bit signed
Super - keyword
Super - keyword       super keyword super is a keyword in java that plays an important role in case of inheritance. Super keyword is used to access the members of the super class. Java
The import keyword
The import keyword      ... compile easily finds the corresponding source file simply by using fully qualified... "*" while using one or two class of a package because it can arise
Java static method example
Description: Static variable are used within the static method. Non static variable do not exits in the static method. Static variables are shared by its class instances. Static variable can be used without using the instances
include a static file
include a static file  How will you include a static file in a JSP page?    You can include a static resource to a JSP using <jsp:directive > or <%@ inlcude >
The implement keyword
for using the implement keyword in a class. public class DominoPizza... The implement keyword       In java programming language, the keyword implement specifies
why get method is used?
why get method is used?  why get method is used in 60% commercial application while using post is more secure
STATIC
STATIC  WHAT IS STATIC BLOCK?EXPLAIN , AND WHAT IS THE DIFFERENCE BETWEEN STATIC BLOCK AND STATIC METHOD?   A STATIC block is automatically... between static block and static method: static block will execute when ever
Calling Static Methods Using SpEL
Calling Static Method Using SpEL Spring 3 provides powerful Expression Language which can be used to wire values into beans properties by calling static method of any bean using SpEL's T() operator. Lets take an example
Static
Static  Can i know the real time example for Static method and final variables with defenition? Thank you
static
static  What is the exact need of declaring a variable as static?   A static variable is a variable who's single copy in memory is shared by all objects,so any modifications to the static variable will modify it's value
synchronized Java Keyword
synchronized Java Keyword       The synchronized is a keyword defined in the java programming... relevant to a compiler in java programming language likewise the synchronized keyword
Return Java Keyword
or a compatible type. Using a return Keyword within a class, with a method A method... Return Java Keyword       The return is a keyword defined in the java programming language. Keywords
static
redeclare static variable in the inherited class  can we redeclare static variable in the inherited class like this: public class StaticClass1 { class StaticClass1{ static int noOfInstances; StaticClass1
Private Java Keyword
members is package access. Using a private Keyword within a class... Private Java Keyword       private is a keyword defined in the java programming language. Keywords
Public Java Keyword
outside the class in which it is declared.  Using a public Keyword within... Public Java Keyword       public is a keyword defined in the java programming language. Keywords
throw Java Keyword
throw Java Keyword       "throw " is a keyword defined in the java programming... to a compiler in java programming language likewise the throw keyword indicates
The new keyword
The new keyword       The new keyword in java programming language is used to create a new instance... meaning relevant to a compiler. The new keyword allocates new objects
Protected Java Keyword
Protected Java Keyword       protected is a keyword defined in the java programming language. Keywords... in java programming language likewise the protected keyword indicates

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.