Core java fundamental help
- From: "pras.vaidya" <pras.vaidya@xxxxxxxxx>
- Date: 31 Aug 2006 00:35:08 -0700
Hello all , I am a newbie in java .Learning core java concepts and i
got confused with this piece of code . The output of code is "Extends
Super" . First time it prints Extends because of overriding but why it
prints " super" later.
Thanks in advance.
Code goes as follow
class SuperShow{
public String str ="Super";
public void show(){
System.out.println(str);
}}
class ExtendsShow extends SuperShow{
public String str = "Extend";
public void show(){
System.out.println(str);}
public static void main(String[]args){
ExtendsShow ext = new ExtendsShow();
SuperShow sup = ext;
sup.show();
//ext.show();
System.out.println(sup.str);
//System.out.println( ext.str);
}}
.
- Follow-Ups:
- Re: Core java fundamental help
- From: krishna
- Re: Core java fundamental help
- From: kittu
- Re: Core java fundamental help
- From: Kevin
- Re: Core java fundamental help
- From: Chris Uppal
- Re: Core java fundamental help
- Prev by Date: Re: Java Networking Frage - überwachen mehrerer Sockets
- Next by Date: POJO Interface
- Previous by thread: Unescaping Unicode code points in a Java string
- Next by thread: Re: Core java fundamental help
- Index(es):
Relevant Pages
|