• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OCPJP code

 
dhvani shah
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
dt.m.go();
Thingy t= new Deluxe Thingy();
t.m.go();
}
}
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch dhvani!

Sure, we will help you out. before that Please, QuoteYourSources (<= click here)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic