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)

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / amit singh

hi pushpa don't go with the book think that
i'm going to tell you what is the imagine
abstract class Human
{
public abstact void eat();
}


thereis osme class is Amit ,Apoorva,and Imarana
they both in hierarchy ofthe Human class theu all extend
this class
class Amit extends Human
{
public void eat()
{
Systm.out.println("eat biryani")
}
}
classApoorva extends Human
{
pulic void eat())
{
Sysetm.out.println("eat food");
}
}
class Imrana extends Human
{
public void eat()
{
System.out.println("eat teh Dosa");
}
}
}
someans to say that theare is same hierarchy means Human
so you want toextends it just for inner world Human
2)
second pointis srise that what you think about the outer
world imagine in outre world there is another class Lizard
it aldso want ot use the functionality eat
that this particular class can extends this i don't think
so and you too
so this is the outer world class this is not in the
hierrachy of the Human so think
i am goin to make the interface for that touse this for
alll world class object whther they are in the hierrrachy
of any superr class are not

interface Nature
{
void eat();
}

class Lizard implements Mature
{

public void eat()
{
System.out.println("eaa mosquito");
}
}

and i'm too going to use this functionality so tell me
isthsii wherer the class in the same hoerrarchy are not

class Amit implements Nature
{

public void eat()
{
System/oput.println("eat any thing");
}
}
}
so this the possible to us this wiytout going any hoerarchy
so if the inner world you should to use abstrac class
but in to use functionality intyhe outer world or inner
world u should to use interface.
i think you got this
amitsing2008@@gmail.com
amit09mca(scjp1.5)

Is This Answer Correct ?    13 Yes 2 No

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

Answer / phani kumar

The understanding of the concept is correct. But what ever
the names you choosen for the classes are not giving right
meaning, for example Imrana, Apoorva, etc... These has to
reprasent objects,not the classes.

Is This Answer Correct ?    8 Yes 1 No

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

Answer / r.jainrocks@gmail.com

Above answer is excellent answer...

thank you "Pushpa" for this great answer

Is This Answer Correct ?    6 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is the benefit of lambda expressions?

0 Answers  


What is %02d?

0 Answers  


explain oops concepts with examples?

29 Answers   AbhiBus, Beeline, DELL, HCL, Satyam, TCS, VLS, Wipro,


String and stringbuffer both represent string objects. Can we compare string and stringbuffer in java?

0 Answers  


What are the different ways to handle exceptions?

0 Answers  


how come we know the object is no more used in the class?

2 Answers   Accenture,


What is passing value java?

0 Answers  


Is it possible to create object with out its default constructor? if possible how? else not possible? justify

5 Answers  


What is the program compilation process?

0 Answers  


Is it correct to say that due to garbage collection feature in java, a java program never goes out of memory?

0 Answers  


Is there any way to skip finally block of exception even if some exception occurs in the exception block?

0 Answers  


What is the null?

0 Answers  


Categories