Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Hi Friends, can u give me Real Time example for interface
and abstract class.(With Banking Example)

Answer Posted / pushpa

<b>Abstract Class :</b>In an object-oriented drawing
application, you can draw circles, rectangles, lines, Bezier
curves, and many other graphic objects. These objects all
have certain states (for example: position, orientation,
line color, fill color) and behaviors (for example: moveTo,
rotate, resize, draw) in common. Some of these states and
behaviors are the same for all graphic objects—for example:
position, fill color, and moveTo. Others require different
implementations—for example, resize or draw. All
GraphicObjects must know how to draw or resize themselves;
they just differ in how they do it. This is a perfect
situation for an abstract superclass. You can take advantage
of the similarities and declare all the graphic objects to
inherit from the same abstract parent object—for example,
GraphicObject, as shown in the following figure.

Classes Rectangle, Line, Bezier, and Circle inherit from
GraphicObject

Classes Rectangle, Line, Bezier, and Circle inherit from
GraphicObject

First, you declare an abstract class, GraphicObject, to
provide member variables and methods that are wholly shared
by all subclasses, such as the current position and the
moveTo method. GraphicObject also declares abstract methods
for methods, such as draw or resize, that need to be
implemented by all subclasses but must be implemented in
different ways. The GraphicObject class can look something
like this:

abstract class GraphicObject {
int x, y;
...
void moveTo(int newX, int newY) {
...
}
abstract void draw();
abstract void resize();
}

Each non-abstract subclass of GraphicObject, such as Circle
and Rectangle, must provide implementations for the draw and
resize methods:

class Circle extends GraphicObject {
void draw() {
...
}
void resize() {
...
}
}
class Rectangle extends GraphicObject {
void draw() {
...
}
void resize() {
...
}
}

When an Abstract Class Implements an Interface
In the section on Interfaces , it was noted that a class
that implements an interface must implement all of the
interface's methods. It is possible, however, to define a
class that does not implement all of the interface methods,
provided that the class is declared to be abstract. For example,

abstract class X implements Y {
// implements all but one method of Y
}

class XX extends X {
// implements the remaining method in Y
}

In this case, class X must be abstract because it does not
fully implement Y, but class XX does, in fact, implement Y.




*************************************************************

Is This Answer Correct ?    12 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does hashmap work in java ?

1026


What is the purpose of a transient variable?

1033


What method is used to specify a container's layout in java programming?

1110


Does constructor return any value?

1007


What are dot operator queries?

1093


Describe the Big-O Notation.

1032


What is exception propagation?

1118


What are multiple inheritances? Is it supported by java?

928


Can I learn java without any programming experience?

1022


what do you understand by the term string with respect to java?

1018


What are different types of control structures?

961


What is multi-catch block in java?

1055


What is the scope or life time of instance variables?

1084


Explain exception chaining in java?

1146


What is the difference between processes and threads?

1031