Comment on Tutorial - Method Overriding in Java By Henry



Comment Added by : DevJ

Comment Added at : 2011-03-18 05:41:52

Comment on Tutorial : Method Overriding in Java By Henry
@readers
this is an example of Hiding and Not Overriding. As overriding doesnt apply to static methods.


---------------------------
public class Animal {

public static void testClassMethod1() {
System.out.println("The class method in Animal.");
}
public void testInstanceMethod() {
System.out.println("The instance method in Animal.");
}
}


public class Cat extends Animal {
public static void testClassMethod() {
System.out.println("The class method in Cat.");
}
public void testInstanceMethod() {
System.out.println("The instance method in Cat.");
}
}


public static void main(String[] args) {
// TODO code application logic here
Cat myCat = new Cat();
myCat.testClassMethod1();

}
my QUESTION is that can we call "myCat.testClassMethod1()" as OVERRIDING.if yes then why?

By: georgy at 2009-10-22 02:46:10


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. hi all !

This is the error im getti

View Tutorial          By: Ajit at 2010-02-17 23:09:47

2. Really just brilliant...thanks
View Tutorial          By: Ash Singh at 2011-02-21 04:47:20

3. hi,
i am download 5 files and instantiate

View Tutorial          By: ganesh kumar at 2008-09-23 05:27:16

4. Problem
The managed bean doesn't get update

View Tutorial          By: jsfuser at 2007-12-25 22:21:54

5. hi how ru
anybody tell me that how to print

View Tutorial          By: imran at 2010-12-10 00:34:51

6. Question: if clone is a protected method then why
View Tutorial          By: siva kiran at 2011-01-20 11:40:23

7. sir i want how to write record into file and readi
View Tutorial          By: himasekhar at 2013-05-25 10:38:31

8. Excellent site.
View Tutorial          By: anonymous at 2011-11-06 12:07:14

9. When I tried to run this code, I got time out ***
View Tutorial          By: Gandhi at 2009-06-04 06:20:48

10. i have a problem ie., Animal is the super class an
View Tutorial          By: renuka at 2012-08-29 15:08:33