Which methods can a class have?

I got this question I am stuck on, can't seem to come up with answer, don't know if it is just too easy for me to see it or because it is 4:30 am!!

I need to know if a Java class can have which of the following methods:

foo( int a )
foo( int a, int b )
foo( double )
foo( double a, double b )
foo( int b )

a- all of the above
b-A,B,D,E
c-A,B,C,D
d-A,C,D,E

I think it is all of the above, ? Can someone open my eyes please?
PJ
Self torture through education,
but enjoy it!

Comments

  • The answer is c-A,B,C,D because there is no difference for the compiler between [italic]foo(int a)[/italic] and [italic]foo(int b)[/italic], as they both have one single parameter, which is an int. The difference of the name of the variables is not important. An example:

    if you call one of the function by this:
    [code]...
    foo (5)
    ...[/code]
    which one of them did you call? A or E? Because it is not possible to decide, there would be an error.


    : I got this question I am stuck on, can't seem to come up with answer, don't know if it is just too easy for me to see it or because it is 4:30 am!!
    :
    : I need to know if a Java class can have which of the following methods:
    :
    : foo( int a )
    : foo( int a, int b )
    : foo( double )
    : foo( double a, double b )
    : foo( int b )
    :
    : a- all of the above
    : b-A,B,D,E
    : c-A,B,C,D
    : d-A,C,D,E
    :
    : I think it is all of the above, ? Can someone open my eyes please?
    : PJ
    : Self torture through education,
    : but enjoy it!
    :


    [size=1][Blue]For our true nature is sin
    [B]Cradle of Filth[/b]


  • Thank you for explaining that too me, I really appreciate it.
    PJ


    : The answer is c-A,B,C,D because there is no difference for the compiler between [italic]foo(int a)[/italic] and [italic]foo(int b)[/italic], as they both have one single parameter, which is an int. The difference of the name of the variables is not important. An example:
    :
    : if you call one of the function by this:
    : [code]...
    : foo (5)
    : ...[/code]
    : which one of them did you call? A or E? Because it is not possible to decide, there would be an error.
    :
    :
    : : I got this question I am stuck on, can't seem to come up with answer, don't know if it is just too easy for me to see it or because it is 4:30 am!!
    : :
    : : I need to know if a Java class can have which of the following methods:
    : :
    : : foo( int a )
    : : foo( int a, int b )
    : : foo( double )
    : : foo( double a, double b )
    : : foo( int b )
    : :
    : : a- all of the above
    : : b-A,B,D,E
    : : c-A,B,C,D
    : : d-A,C,D,E
    : :
    : : I think it is all of the above, ? Can someone open my eyes please?
    : : PJ
    : : Self torture through education,
    : : but enjoy it!
    : :
    :
    :
    : [size=1][Blue]For our true nature is sin
    : [B]Cradle of Filth[/b]
    :
    :
    :

    PJ
    Self torture through education,
    but enjoy it!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories