Debug the error !

Discussion in 'Java' started by Gaurav, Dec 1, 2005.

  1. Gaurav

    Gaurav Guest

    Hi .. kindly tell me the error in the following code

    package test1;
    public class Test1 {
    static int x = 42;
    }




    package test2;
    public class Test2 extends test1.Test1 {
    public static void main(String args[]) {
    System.out.println("x="+x); } }
     
    Gaurav, Dec 1, 2005
    #1
    1. Advertising

  2. Gaurav

    Roedy Green Guest

    On 30 Nov 2005 23:43:53 -0800, "Gaurav" <> wrote,
    quoted or indirectly quoted someone who said :

    >Hi .. kindly tell me the error in the following code

    Please tell what the problem is, quoting the error message verbatim.
    It is annoying to be given guessing games. Teachers give students
    guessing games, not the reverse.

    Presumably your problem is that x is default rather than protected
    scope, thus classes in package test2 can't see it.
    see http://mindprod.com/jgloss/scope.html



    >
    >package test1;
    >public class Test1 {
    > static int x = 42;
    > }
    >
    >
    >
    >
    >package test2;
    >public class Test2 extends test1.Test1 {
    >public static void main(String args[]) {
    >System.out.println("x="+x); } }

    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Dec 1, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RonL
    Replies:
    0
    Views:
    757
  2. ringos75
    Replies:
    0
    Views:
    978
    ringos75
    Apr 14, 2005
  3. Mike C. Fletcher
    Replies:
    3
    Views:
    994
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Oct 12, 2003
  4. André
    Replies:
    3
    Views:
    1,617
  5. SÁRINGER Zoltán

    JET error in interdev debug only (DCOM error?)

    SÁRINGER Zoltán, Aug 30, 2004, in forum: ASP General
    Replies:
    7
    Views:
    206
    Jeff Dillon
    Sep 2, 2004
Loading...

Share This Page