jQuery in Action, 2nd edition*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes need help.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "need help.." Watch "need help.." New topic
Author

need help..

Marcos Vilela
Greenhorn

Joined: Jul 06, 2005
Posts: 18
1. public class TestQ48 {
2. public static void main (String[] args){
3. TestQ48 tq = new DerivedQ48();
4. ((DerivedQ48)tq).echoN( tq.paramA );
5. }
6. int paramA = 9 ;
7. }
8. class DerivedQ48 extends TestQ48 {
9. int paramA = 3 ;
10. void echoN( int n ){
11. System.out.println("number is " + n );
12. }
13. }


I didn't understand 9 as output.
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Because member variables are not overriden & decided at compile time.


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
Always remember, variables are binded to the class in compliation time whereas methods/functions are binded to the class in runtime (that's why it is sometimes called dynamic binding).

Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need help..