aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Overriding and Polymorphism Question, Whizzlabs 11 of 15 on sample test 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 "Overriding and Polymorphism Question, Whizzlabs 11 of 15 on sample test" Watch "Overriding and Polymorphism Question, Whizzlabs 11 of 15 on sample test" New topic
Author

Overriding and Polymorphism Question, Whizzlabs 11 of 15 on sample test

Robert Elbourn
Ranch Hand

Joined: Oct 15, 2007
Posts: 69
class SuperBase { void print(SuperBase a){System.out.println("SuperBase");}}
class Based extends SuperBase { void print(Based a){System.out.println("Based");}}
class Derived extends Based {static void print(Derived a){System.out.println("Derived");}}

public class SuperBaseTest {

public static void main(String[] args) {


SuperBase a1= new SuperBase();
SuperBase a2 = new Based();
SuperBase a3 = new Derived();

Based b2 = new Based();
Based b3 = new Derived();

Derived d3 = new Derived();

a1.print(new SuperBase());//SuperBase
a1.print(new Based());//SuperBase
a1.print(new Derived());//SuperBase

a2.print(new SuperBase());//SuperBase
a2.print(new Based()); //SuperBase
a2.print(new Derived()); //SuperBase

a3.print(new SuperBase()); //SuperBase
a3.print(new Based());//SuperBase
a3.print(new Derived());//SuperBase

b2.print(new SuperBase()); //SuperBase
b2.print(new Based()); //Based
b2.print(new Derived()); //Based

b3.print(new SuperBase());//SuperBase
b3.print(new Based()); //Based
b3.print(new Derived()); //Based

d3.print(new SuperBase()); //SuperBase
d3.print(new Based()); //Based
d3.print(new Derived()); //Derived
}

}


I have created this compilable class( Base is now Based as I had a class already defined that I couldn't be bothered to package differently)
this prints out all the valid permutations and combinations that the question could have to offer (I think)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Overriding and Polymorphism Question, Whizzlabs 11 of 15 on sample test