ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
Hi Friends, can u give me  Real Time example for interface 
and abstract class.(With Banking Example)
 Question Submitted By :: Rajendra007
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Hi Friends, can u give me Real Time example for interface and abstract class.(With Banking Example)
Answer
# 1
<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 ?    2 Yes 0 No
Pushpa
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
When finally clause is executed?  3
what is the life cycle of jsp? Photon2
how to use finalize()Method to resources TCS2
What is the return type of read()?  2
What are the traverses in Binary Tree? Adobe2
Why const and goto are reserved keyword in java?  1
when i write string s1="java"; in one program(application) and string s2="java"; in another application on the same jvm will both objects s2,s2 will refer to same memory location where "java" is stored in string pool.  2
Package1 and Package2 both have a method name lets say "methodA" with different implementation. When I import both the packages in a java class how can I use both the methods? Ericsson3
what modifiers are used with top-level class?  2
What is file class and what is its purpose?  1
Can we place the any object to key attribute of HashMap<key,value>? HCL3
define System.out.println(); what is the meaning!  8
what is the use of custom tags? with example? Photon1
In C we use only compiler. Why java uses both compiler and interpreter? What is its significance?  5
Why all programming languages have main as a execution starting point?  2
StringBuilder s = new StringBuilder("Hello Mom");s.append(",I mean,Mother"); Response.Write(s.ToString()); String s = "Hello Mom"; s+ = ",I mean Mom"; Response.Write(s); Which is faster ? which uses the most memory?  4
what is mutability?which one is mutable String or StringBuffer?and why?give examples of each which shows the mutability of each String or StringBuffer  2
What is an enumeration class?  2
I have 100 records in a table with two rows. I need to display 10 records per page like Google Search. I need only the Logic(Pagination) in Pure Java. No JSP and all..Thanks in Advance... Cybernet2
long d =10;int i =0;i=d; /// is this possible? If d is very long number (10 digits or some thing) then?  3
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com