Java is the future !: Quiz of the Day | Oct 30, 2010

Saturday, October 30, 2010

Quiz of the Day | Oct 30, 2010

Which of the following statements are true about the relationships between the following classes?
a.) A Bar is a Baz
b.) A Foo has a Bar
c.) A Baz is a Foo 
d.) A Foo is a Baz
e.) A Baz has a Bar


Solution : Choices B, C, and E are the correct answers. An instance of the Baz class is also an instance of the class Foo since the Baz class extends the Foo class. So choice C is correct. 

A Baz has a Bar, since instances of the Baz class contain an instance of the Bar class by reference. So choice E is correct. 

A Foo has a Baz, since instances of the Foo class contain an instance of the Baz class by reference. Since a Foo has a Baz, which in turn has a Bar, a Foo has a Bar. So choice B is also correct. 

Choice A is incorrect because Bar does not extend Baz. Choice D is also incorrect because Foo does not extend Baz either. Refer http://cnx.rice.edu/content/m11709/latest/ for more details.


Source : "Facebook community"

No comments:

Post a Comment