Results 1 to 4 of 4
  1. #1
    sandeshforu is offline Member
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Default 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;
    }
    }

  2. #2
    sandeshforu is offline Member
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Default

    please help

  3. #3
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,008
    Rep Power
    20

    Default

    Quote Originally Posted by sandeshforu View Post
    please help
    I think you ought to do your own homework you know...
    Or at least have a good stab at it and then ask something slightly more specific.

  4. #4
    JavaVideos is offline Member
    Join Date
    Sep 2009
    Posts
    13
    Rep Power
    0

    Default

    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

  1. accessing instance variables from static methods
    By ravian in forum New To Java
    Replies: 7
    Last Post: 03-01-2009, 10:09 PM
  2. static are instance variables
    By gabri in forum Advanced Java
    Replies: 12
    Last Post: 09-30-2008, 06:30 PM
  3. Using Static Variables
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 11:08 PM
  4. significance of static variables and methods
    By imran_khan in forum New To Java
    Replies: 4
    Last Post: 08-02-2007, 09:52 AM
  5. Help with static variables
    By bbq in forum Advanced Java
    Replies: 1
    Last Post: 06-28-2007, 05:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •