java_cw1
java_cw1
Then
create two other classes named 'Rectangle', 'Circle' inheriting the Shape class, both
having a method to print "This is rectangular shape" and "This is circular shape"
respectively. Create a subclass 'Square' of 'Rectangle' having a method to print
"Square is a rectangle". Now call the method of 'Shape' and 'Rectangle' class by the
object of 'Square' class.
Class Vehicle:
Vehicle Class will contain a display() function, which will say "This is a Vehicle".
Class Car:
Car Class will derive the Vehicle Class and overwrite its display() function. it will say
"This is a Car".
Class Bike:
Bike Class will derive the Vehicle Class and overwrite its display() function. it will say "This
is a Bike".
Write an application that reads an Integer N, which will denote the number of tyres in the
vehicle. You have to create an object of the appropriate class according to the value of N and
use it display() function.
Definition of Done:
DoD 2: Switch statement is used for identifying the appropriate class for which the object is
to be invoked.
3. Create an abstract class 'Bank' with an abstract method 'getBalance'. $100, $150 and
$200 are deposited in banks A, B and C respectively. 'BankA', 'BankB' and 'BankC'
are subclasses of class 'Bank', each having a method named 'getBalance'. Call this
method by creating an object of each of the three classes.