permaculture playing cards
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes OCPJP code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "OCPJP code" Watch "OCPJP code" New topic

OCPJP code

dhvani shah

Joined: Oct 23, 2012
Posts: 1
i m preparing for ocpjp. can anyone explain me da flow of this code. and how does the output come mm. its output is mm.

class Thingy{Meter m=new Meter();}
class Component{void go() {System.out.print("c");}}
class Meter extends Component{void go() {System.out.print("m");}}
class Deluxe Thingy extends Thingy{
public static void main(String []args){
Deluxe Thingydt=new Deluxe Thingy();
Thingy t= new Deluxe Thingy();
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Welcome to CodeRanch dhvani!

Sure, we will help you out. before that Please, QuoteYourSources (<= click here)
I agree. Here's the link:
subject: OCPJP code
It's not a secret anymore!