nus-cs2103-AY2324S1 / forum

10 stars 0 forks source link

Practice Exam Part 1 Q5 #557

Closed GlendaChong closed 9 months ago

GlendaChong commented 9 months ago

Hello, may I know what's the reasoning behind why the options 2 and 3 are correct?

My understanding is that removing the store() method will cause a compile error because Bar is not an abstract class, which makes the option correct.

However, by the same logic, will removing process() method not also cause a compile error?

Could someone help to clarify any misunderstandings I have, as well as to provide an explanation for the 2 options?

Thank you!

image
TeeRenJing commented 9 months ago

Question stated that "the Goo interface doesn't have any default method implementation", for Bar to be a concrete class it has to provide an implementation for store().

On the other hand the process() method is not italicized and there is no {abstract} keyword. Hence it is not an abstract method and has a default implementation in the abstract class Foo.

I think Java allows definition of abstract classes without any abstract methods https://stackoverflow.com/questions/4811678/defining-an-abstract-class-without-any-abstract-methods

damithc commented 9 months ago

Question stated that "the Goo interface doesn't have any default method implementation", for Bar to be a concrete class it has to provide an implementation for store().

On the other hand the process() method is not italicized and there is no {abstract} keyword. Hence it is not an abstract method and has a default implementation in the abstract class Foo.

I think Java allows definition of abstract classes without any abstract methods https://stackoverflow.com/questions/4811678/defining-an-abstract-class-without-any-abstract-methods

@GlendaChong this answer given by @TeeRenJing is correct.

GlendaChong commented 9 months ago

Thank you!