Question: Declare Reference variable

Ads

 
 
 

Share on Google+Share on Google+

Ankit Maini
Declare Reference variable
0 Answer(s)      6 years and 3 months ago
Posted in : Java Beginners
    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??

Ads
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
reference
reference of student into person can do like this or any other alternative Student
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
PHP Call By Reference
PHP Call By Reference: In PHP we can pass reference of a variable, so that we can modify the variable's value inside another function and get the modified values from where we have sent. It is much like the call by reference, in which we
PHP Variable Outside Function
PHP Variable Outside Function In PHP Functions, a variable can be called either outside the function or inside the function. If we declare a variable within the function, it will not seen outside the function and if you declare
Declare construct
Declare construct  hii, Define about declare construct?   hello, Declare construct allows you to define execution directives for a block.... These declare construct can be set in such a manner that all the code is affected
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     
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
PHP Object Reference
a reference is an alias and an object variable does not contain the object rather... that the terms object and reference is interchangeable. Now we must know what is actually an object and what is a reference. Whenever an object is instantiated
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
by value or by reference
by value or by reference  Are objects passed by value or by reference
Java reference
Java reference  What is weak reference in Java
PHP Variable variables
PHP Variables variable: Variables variable is a new kind of technique of using variables, in this technique we need to use more than one variable and we can... the use of variable variable both in general use as well as in OOP concept. PHP
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
Declare the Navigation Rules
Declare the Navigation Rules  How to declare the Navigation Rules for JSF
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
PHP Variable Functions
PHP Variable Functions: Learn PHP Variable Function means that if a variable name has a format like this $var(), PHP will consider this as a variable function... to execute it. This variable function does not work with echo(), print(), unset
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
How to declare NSMatrix
How to declare NSMatrix  How to declare NSMatrix in XCode can anyone explain it with example
pointer to a reference
pointer to a reference  pointer to a reference in C++    #include <iostream> using namespace std; void foo1(int& x) { int* p = &x; *p = 123; } void foo2(int* x) { int
pointer to a reference
pointer to a reference  pointer to a reference in C++    #include <iostream> using namespace std; void foo1(int& x) { int* p = &x; *p = 123; } void foo2(int* x) { int
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
Pass by Reference - Java Beginners
by Reference?can u please explain with examples.is java supports Pass by reference...(i); display(i); } } Pass By Reference: It refers to pass an object variable to a method. Example: public class PassByRefernce{ public static
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
pass method reference in java
pass method reference in java  How to pass method reference in Java
Are objects passed by value or by reference?
Are objects passed by value or by reference?  Are objects passed by value or by reference
Is Java pass-by-reference?
Is Java pass-by-reference?  Is Java pass-by-reference
Tutorials   
Java Spring Hibernate Struts Training Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java Java Example Codes and Tutorials in 2017 How do I read a large file quickly in Java? Is learning Java worthwhile? How to create first Java Program? Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include?

Ads

 
Advertisement null

Ads