• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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).
 
I claim this furniture in the name of The Ottoman Empire! You can keep this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic