Howdy, Stranger!

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

Categories

Which methods can a class have?

PJsPlacePJsPlace Member Posts: 28
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

  • Feanors CurseFeanors Curse Member Posts: 70
    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]


  • PJsPlacePJsPlace Member Posts: 28
    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!

  • Andre YoungAndre Young USAMember Posts: 0

    ____ || http://forcoder.org || free ebooks and video tutorials about { Scratch, Visual Basic .NET, Go, JavaScript, C, Python, Assembly, Ruby, Swift, Java, MATLAB, Perl, R, C++, Visual Basic, PL/SQL, PHP, Objective-C, C#, Delphi Rust, COBOL, Scheme, FoxPro, Apex, F#, Bash, LabVIEW, Scala, Hack, Transact-SQL, Julia, Prolog, Fortran, ABAP, VBScript, Lua, Clojure, Dart, Lisp, Logo, Awk, Erlang, Ada, ML, Kotlin, SAS, D, Alice, Crystal } ____________

Sign In or Register to comment.