Replies
Welcome, guest
Join CrazyEngineers to reply, ask questions, and participate in conversations.
CrazyEngineers powered by Jatra Community Platform
-
@anoop-kumar-GDGRCn • Jun 6, 2013
suppose you have to write code for TwoWheeler.
Lets make a abstract class for TwoWheeler do following things in common
1. Turning mechanism
2. break mechanism
But following things can be differ from kind of TwoWheeler
A. Gear Mechanism
you can write with implementation of 1 & 2 method in abstract class and provide a abstract method for GearMechanism.
Now whatever class will extend TwoWheeler class, they already have method 1,2 and just need to implement method A. this give you proper reuse of code.
PS: In java, always think as if in real scenarios, makes java like a cake. more you eat more you get amused😀 -
@hare-singh-nayak-WEmcz0 • Jun 6, 2013
ianoopsuppose you have to write code for TwoWheeler.
Lets make a abstract class for TwoWheeler do following things in common
1. Turning mechanism
2. break mechanism
But following things can be differ from kind of TwoWheeler
A. Gear Mechanism
you can write with implementation of 1 & 2 method in abstract class and provide a abstract method for GearMechanism.
Now whatever class will extend TwoWheeler class, they already have method 1,2 and just need to implement method A. this give you proper reuse of code.
PS: In java, always think as if in real scenarios, makes java like a cake. more you eat more you get amused😀
Thank you anoop
you have explain in very nice way and any one can easily understand...