Declare Reference variable

Declare Reference variable

    class A
    {
      int a; //instance variable
      static int b; // static variable
      A ref;
      static A refs;
      public static void main(String[] args)
      {
        // statements followed here...
      }

}

My Question is that instance variable occupy space in memory when object is created. Static variable is class variable which is shared. I just want to ask if we declare Reference variable above then what does that mean. like we declared 'A ref' and 'static A refs'. How this is treated??

(Generally we used to declare reference variable in main method at the time of object creation, but here i am declaring reference variable in class not in the main, so what is the difference and second what is the use of static reference variable)

please explain with example??

View Answers

Ads









Related Tutorials/Questions & Answers:
Declare Reference variable
is shared. I just want to ask if we declare Reference variable above then what does...?? (Generally we used to declare reference variable in main method at the time...Declare Reference variable   class A { int a; //instance
Can we declare a static variable inside a method?
Can we declare a static variable inside a method?   Hi, Can we declare a static variable inside a method? thanks
Advertisements
cannot declare variable inside @interface or @protocol
cannot declare variable inside @interface or @protocol  When i declare variable inside the interface, it always send an error saying "cannot declare variable inside @interface or @protocol". Can anyone please tell me why
declare a variable that will store an array of 5 objects
declare a variable that will store an array of 5 objects  Q7. Give a declaration for a variable that will 'store' an array of 5 Card objects... you   Declare Array of 5 objects in the following way: int list[]=new
Use DECLARE Statement in Procedure
Use DECLARE Statement in Procedure       Use DECLARE Statement in Procedure is used to define variable and its data type. Understand with Example
Mysql Declare Procedure
Mysql Declare Procedure        Mysql Declare Procedure is used to define a local variable within a procedure. The local variable are used within the procedure. Understanding
Creating a Local Variable in JSP
or variable we usually declare it inside the declaration tag. If we declare... consider a situation where we have to declare a variable as local, then we should...Creating a Local Variable in JSP     
reference
reference of student into person can do like this or any other alternative Student
Creating a Local Variable in JSP
Creating a Local Variable in JSP      In jsp when we have to create a method or variable we usually declare... to declare a variable as local, then we should declare the methods and variables
javascript where to declare variables
;script language="javascript"> // declare variable or do your calculation...javascript where to declare variables  javascript where to declare variables   Javascript variable always be declared inside script tag
STATIC VARIABLE DECLARATION
STATIC VARIABLE DECLARATION  why cannot the static variable declare inside the method
Instance variable in java
. Here are the various example to declare variable as below: int a,b,c..., boolean it s false and for object reference it is null. Instance variable...Instance variable in java In this section you will learn about Instance
Use DECLARE Statement in Procedure
Section that include DECLARE statement which define a variable x ,y and z... Use DECLARE Statement in Procedure       Use DECLARE Statement in Procedure is used to define
Version of reference>reference dependency
List of Version of reference>reference dependency
Declare the Navigation Rules
Declare the Navigation Rules  How to declare the Navigation Rules for JSF
How to declare NSMatrix
How to declare NSMatrix  How to declare NSMatrix in XCode can anyone explain it with example
ModuleNotFoundError: No module named 'declare'
ModuleNotFoundError: No module named 'declare'  Hi, My Python... 'declare' How to remove the ModuleNotFoundError: No module named 'declare... to install padas library. You can install declare python with following command
Create Session Variable PHP
Create Session Variable PHP  hi, Write a program which shows the example of how to create session variable in PHP. Please suggest the reference... session Variable in PHP. May be this reference will solve your query. Thanks
Local Variable and Instant Variable
Local Variable and Instant Variable  difference between Local Variable and Instant Variable   Difference between local variable and instance variable Instance variable is declared within a class but not within
by value or by reference
by value or by reference  Are objects passed by value or by reference
creating a global variable with php
creating a global variable with php  Is it possible to create a variable to declare as global in case of database connectivity?   Yes, if you want to have access of that variable anywhere in the program. See the example
How to declare array in Java?
How to declare array in Java?  Hi, How to declare array in Java? Thanks   Hi, Following is a code of declaration of String array: String[] javaTechnologies = new String[]{"Java", "JSP", "Servlet", "JPA"}; Example
Store Variable in Java
Store Variable in Java  How to store Variables in Java?   ... aDouble = 5.76; // Declare and initialize aDouble System.out.println...(aDouble); // Outputs 7.21 } }   Variable in Java
Declare Cursors in SQL
Declare Cursors in SQL       Declare Cursors in SQL is used to define cursor and its... 'Declare Cursors in SQL'. To grasp the example, we create a table 'Stu_Table
What is the purpose of declaring a variable as final?
What is the purpose of declaring a variable as final?   Hi, What is the purpose of declaring a variable as final? Thanks   Hi, In Java when we declare a final variable as a variable which has been initialized
you pass a variable by value.
you pass a variable by value.  How do you pass a variable by value?   Hi friends, Just like in C++, put an ampersand in front of it, like...($a) { return ++$a; } add($a); /*---------------Pass by reference
appdelegate reference
appdelegate reference  Hi, How to get the reference of appdelegate in my view controller class. Thanks.   Hello Friend, Following code example show how to get appdelegate reference anywhere in your iPhone/iPad
Converting jsp variable to java variable
Converting jsp variable to java variable  Hi how to convert java script variable to java variable on same jsp page
cross reference
cross reference   hi everbody as i got a problem and i have no idea the problem that i need to create a cross reference map for a Java source file... generation of the cross-reference map. Finally, the cross-reference map is output
ModuleNotFoundError: No module named 'declare-amqp'
ModuleNotFoundError: No module named 'declare-amqp'  Hi, My Python... 'declare-amqp' How to remove the ModuleNotFoundError: No module named 'declare-amqp' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'declare-amqp'
ModuleNotFoundError: No module named 'declare-amqp'  Hi, My Python... 'declare-amqp' How to remove the ModuleNotFoundError: No module named 'declare-amqp' error? Thanks   Hi, In your python

Ads