Valid Call in Java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chiasien
    New Member
    • Aug 2007
    • 2

    Valid Call in Java

    Hi All,

    I am new learner for Java.

    My doubt is:

    public static void mystery (int list [], int size)

    parameter: int list [], int size

    declaration: int [] alpha = new int[50]


    Q: Produce a valid call to the method mtstery.
    My answer: mystery(alpha,5 0); (isn't correct?)

    BTW what is the valid call mean?

    Thanks and appreciate for the assist.

    Brgs,
    ChiaSien
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by chiasien
    Hi All,

    I am new learner for Java.

    My doubt is:

    public static void mystery (int list [], int size)

    parameter: int list [], int size

    declaration: int [] alpha = new int[50]


    Q: Produce a valid call to the method mtstery.
    My answer: mystery(alpha,5 0); (isn't correct?)

    BTW what is the valid call mean?

    Thanks and appreciate for the assist.

    Brgs,
    ChiaSien
    Well, syntactically speaking even mystery(null, -42) is quite a valid method call.
    Also mystery(new int[42], 54) would be fine. There is no way to enforce that the
    second parameter reflects the length of the frst parameter. The caller can do
    whatever it wants. The mystery() method should check the validity of its parameters
    itself in order to make it a 'valid' call.

    Personally I'd had made it a mystery(int[] anArray) method; that int size thing
    seems redundant.

    kind regards,

    Jos

    Comment

    • TripleDES
      New Member
      • Aug 2007
      • 16

      #3
      Originally posted by chiasien
      Hi All,

      I am new learner for Java.

      My doubt is:

      public static void mystery (int list [], int size)

      parameter: int list [], int size

      declaration: int [] alpha = new int[50]


      Q: Produce a valid call to the method mtstery.
      My answer: mystery(alpha,5 0); (isn't correct?)

      BTW what is the valid call mean?

      Thanks and appreciate for the assist.

      Brgs,
      ChiaSien
      Looks like a trick question to me, unless you have omitted some code from your example. Otherwise it is not valid Java, since every function must belong to a class.

      Comment

      Working...