title: Is it possible to override a method in same class in Java?
body: <p>Take a look at the following code sample :</p>
  
  <pre><code>public class Test{
  
     public static void main(String[] args){
  
          System.out.println(new Test());
  
  
         System.out.println(new Test(){
  
          public String toString(){
               return "manual override";
           }
  
         });
  
  
  
        System.out.println(new Test(){
  
                public String gm(){
                      return  "manual gm";
                 }
          }.gm());
       }  //end of main method
  
     public String gm(){
       return "gm";
      }
  }
  </code></pre>
  
  <p>There may be some argument that the <code>toString()</code> method is being overridden in anonymous inner class which is an entirely different class.<br>
  But the overriding code still resides in the same class. So, will it be justified to conclude that in some situations [as described above] , the overriding of a method in same class is possible?</p>