Results 1 to 4 of 4
- 09-09-2009, 04:39 PM #1
Member
- Join Date
- Sep 2009
- Posts
- 4
- Rep Power
- 0
What are Instance variables and static variables?
Please tell me what are the instance variables,local varialbes and static variables in the program below
class Imp{
public static void main(String args[]){
Test obj=new Test();
obj.a=10;
obj.b=20;
obj.ini(30);
System.out.println(obj.a +""+obj.b+"" + obj.ret());
}
}
class Test{
int a;
public int b;
private int c=29;
void ini(int h){
c=h;
}
int ret(){
return c;
}
}
- 09-09-2009, 04:45 PM #2
Member
- Join Date
- Sep 2009
- Posts
- 4
- Rep Power
- 0
please help
- 09-09-2009, 05:16 PM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
- 09-09-2009, 05:48 PM #4
Member
- Join Date
- Sep 2009
- Posts
- 13
- Rep Power
- 0
I agree with Tolls, here is how you could proceed: Make a list of the items you think are variables in the code, when you have done that, go though your list and try your best at working out whether they are instance, local or static.
If you produce that list here I am sure someone will be able to point out any mistakes and help you understand where you went wrong.
Similar Threads
-
accessing instance variables from static methods
By ravian in forum New To JavaReplies: 7Last Post: 03-01-2009, 10:09 PM -
static are instance variables
By gabri in forum Advanced JavaReplies: 12Last Post: 09-30-2008, 06:30 PM -
Using Static Variables
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 11:08 PM -
significance of static variables and methods
By imran_khan in forum New To JavaReplies: 4Last Post: 08-02-2007, 09:52 AM -
Help with static variables
By bbq in forum Advanced JavaReplies: 1Last Post: 06-28-2007, 05:38 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks