Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Static final variables
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Srilakhsmi v k
Static final variables
1 Answer(s)      5 years and 9 months ago
Posted in : Java Beginners



Advertisement
View Answers

February 26, 2009 at 6:47 AM


Hi,

static final variable u can access in non-static method.

but the variable should has accessibility, means check the access specifier.

the following example may be useful for u.

class Xyz{
private static final String name="xyz";

public void displayData(){

System.out.println("name is "+name);//within class u can access the variable 'name'
}
}

class Abc extends Xyz{
public void display(){

System.out.println("name is "+name);//here u can't access the variable 'name'.
}
}


regards,

siva kumar


Related Tutorials/Questions & Answers:
Static final variables - Java Beginners
Static final variables  can a static final variable be accessed by a instance (non-static)method?  Hi, static final variable u can... Xyz{ private static final String name="xyz"; public void displayData
private static final
private static final  Why there is necessary to make a variable private static final
Advertisements
Static & Instance variables in java
Static & Instance variables in java  What are the Difference between Static & Instance variables in java
final
final  what does final means in "public static final void main (string args[])" ?   keyword final can be assigned only once. They cannot be modified
Static
Static  Can i know the real time example for Static method and final variables with defenition? Thank you
Java final keyword
with the name "Final" in a Java program. We can have final methods, final classes, final data members, final local variables and final parameters. When...Java final keyword The final is a very important keyword in java, which
Variables
Variables  What are the difference between Static variables, instance variables and local variables
PHP Variables Static
PHP Variables Static PHP static variable is used to remember the value... is running a static variable is only retained by the function , but it is NOT shared... disappears, Once the function is finished. To solve this problem we use PHP static
static
,then go for static methods. If we want variables those values will not be changed from object to anther object,then go for static variables...(According to my...Static Concept  in what are all the situation we may use static
static
in all objects.They are not re-created or re-initialized. Static variables...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
static
is applied to member variables, it means that the static variable is shared among all...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
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
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
The final Keyword
final methods, final classes, final data members, final local variables and final parameters.   variables: A variable declared with the final.... private and static methods are always implicitly final
final keyword
final keyword  why is final keyword used in java
Final Keyword
Final Keyword  hello, What is final?   hii In case of class if we use final then this class can not be extended or final class may not be subclassed. A final method can't be overridden when its class is inherited
final variable
final variable  Please give some easiest and understanding example program for final variable
interface variables - Java Beginners
interface variables  why interface variables are final? explain me with good program example?? i knw why the variable is static but,i dont knw why it is final by default? thanks in advance
final grade
final grade  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display the Point...?s final grade from 50-100. Evaluate the Final grade and display the Point
Final Methods - Java Tutorials
; The fields which are declared as static, final and public are known as named...{ public static final double x = 2.998E8; } final method arguments You can also...The final Keyword in Java In Java, final keyword is applied in various context
static methods
static methods  why static methods cannot read or write the instance variables
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... Variables & Methods : <?php class One{ private static $var=0
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
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... variables). 2)A static method can call only other static methods and can not call
static functions
static functions  Give some brief defenition for 1. Static Variables 2. Static Functions 3. Instance Variable  Static Variables Static... variables. 3)A single copy to be shared by all instances of the class. 4)A static
Java final
classes, final data members, final local variables and final parameters. 1. variables: A final variable can be set once and only once. 2. methods: A final method... Java final      
Java final Keyword Example
final void methodName1() { ...... } public static final... methodName1() { ...... } public static final void methodName2...() { ...... } } Keyword final with Variables In Java the final keyword can be used
Static Variable
of a class, an object, is created. When static is applied to member variables...Static Variable  What is the basic use of introducing static variable type in java?Please explain clearly....   The Static means
Static
an instance of a class. Static methods are implicitly final method, since overriding... final. However, a static method can't be overridden by a nonstatic method. Or we... Static       Static
getting variables
getting variables   how to get variables from servlet program to webservice program
Squaring of two number in Static class
Squaring of two number in Static class  ... static method and how can display multiplication of two any number. The static method use no instance variables of any object of the class they are defined
 

 

 

DMCA.com