• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Overloading or Overriding ?

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am preparing for SCJP and i have the following doubt.

Consider the following code :

public class Test
{
public static void main(String [] args)
{
SuperTest st = new SubTest();
st.testMethod(10);
}
}

class SuperTest
{
public void testMethod(int a)
{
System.out.println("\n Test Method in Super Test Class ");
}
}

class SubTest extends SuperTest
{
public void testMethod(final int a)
{
System.out.println("\n Test Method in SubTest Class ");
}
}

Whether the testMethod in SuperTest is overloaded or overriden in SubTest ?
 
Ranch Hand
Posts: 138
Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My guess is that it is overridden because the argument no and type are the same therefore the signature is the same(the final modifier does not matter).(but I am not sure as I will take the exam in a month and have not studied that objective this is just as far as I know).
Please correct me if I am wrong.
 
Ranch Hand
Posts: 657
Spring VI Editor Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's overridden (same signature).
reply
    Bookmark Topic Watch Topic
  • New Topic