JSP - difference between extending class and importing class

In the following scenario
class A
private static String con;
Case 1
==========
class B extends A
Case 2
===========
import A;
class C
A objA = new A;
What will be the difference in Case 1 and Case 2 on accessing the variable con.
thanx
Venki

>
If i am not wrong, the above line should be private
static variables are not inherited.
NO, AFAIK, static variables, private or otherwise arent inherited. Please note that doesnt mean, its not available in the sub-class. Infact it is. However you cannot override or hide them ie polymorphism isnt applicable to static members which is what , IMO, inheritance is all about. Its logical, when you think about it, polymorphism is applicable for objects and static is a class thinggy, has nothing to do with objects.
cheers,
ram.

Similar Messages

  • Whats the difference between an INTERFACE and a CLASS?

    Whats the difference between an INTERFACE and a CLASS?
    Please help.
    Thanx.

    http://search.java.sun.com/search/java/index.jsp?col=javaforums&qp=%2Bforum%3A31&qt=Difference+between+interface+and+class

  • Question about main difference between Java bean and Java class in JSP

    Hi All,
    I am new to Java Bean and wonder what is the main difference to use a Bean or an Object in the jsp. I have search on the forum and find some post also asking the question but still answer my doubt. Indeed, what is the real advantage of using bean in jsp.
    Let me give an example to illustrate my question:
    <code>
    <%@ page errorPage="errorpage.jsp" %>
    <%@ page import="ShoppingCart" %>
    <!-- Instantiate the Counter bean with an id of "counter" -->
    <jsp:useBean id="cart" scope="session" class="ShoppingCart" />
    <html>
    <head><title>Shopping Cart</title></head>
    <body bgcolor="#FFFFFF">
    Your cart's ID is: <%=cart.getId()%>.
    </body>
    <html>
    </code>
    In the above code, I can also create a object of ShoppingCart by new operator then get the id at the following way.
    <code>
    <%
    ShoppingCart cart = new ShoppingCart();
    out.println(cart.getId());
    %>
    </code>
    Now my question is what is the difference between the two method? As in my mind, a normal class can also have it setter and getter methods for its properties. But someone may say that, there is a scope="session", which can be declared in an normal object. It may be a point but it can be easily solved but putting the object in session by "session.setAttribute("cart", cart)".
    I have been searching on this issue on the internet for a long time and most of them just say someting like "persistance of state", "bean follow some conventions of naming", "bean must implement ser" and so on. All of above can be solved by other means, for example, a normal class can also follow the convention. I am really get confused with it, and really want to know what is the main point(s) of using the java bean.
    Any help will be highly apprecaited. Thanks!!!
    Best Regards,
    Alex

    Hi All,
    I am new to Java Bean and wonder what is the main
    difference to use a Bean or an Object in the jsp. The first thing to realize is that JavaBeans are just Plain Old Java Objects (POJOs) that follow a specific set of semantics (get/set methods, etc...). So what is the difference between a Bean and an Object? Nothing.
    <jsp:useBean id="cart" scope="session" class="ShoppingCart" />
    In the above code, I can also create a object of
    ShoppingCart by new operator then get the id at the
    following way.
    ShoppingCart cart = new ShoppingCart();
    out.println(cart.getId());
    ...Sure you could. And if the Cart was in a package (it has to be) you also need to put an import statement in. Oh, and to make sure the object is accessable in the same scope, you have to put it into the PageContext scope. And to totally equal, you first check to see if that object already exists in scope. So to get the equivalant of this:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart"/>Then your scriptlet looks like this:
    <%@ page import="my.pack.ShoppingCart %>
    <%
      ShoppingCart cart = pageContext.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        pageContext.setAttribute("cart", cart);
    %>So it is a lot more work.
    As in my mind, a normal class can also
    have it setter and getter methods for its properties.True ... See below.
    But someone may say that, there is a scope="session",
    which can be declared in an normal object.As long as the object is serializeable, yes.
    It may be
    a point but it can be easily solved but putting the
    object in session by "session.setAttribute("cart",
    cart)".Possible, but if the object isn't serializable it can be unsafe. As the point I mentioned above, the useBean tag allows you to check if the bean exists already, and use that, or make a new one if it does not yet exist in one line. A lot easier than the code you need to use otherwise.
    I have been searching on this issue on the internet
    for a long time and most of them just say someting
    like "persistance of state", "bean follow some
    conventions of naming", "bean must implement ser" and
    so on. Right, that would go along the lines of the definition of what a JavaBean is.
    All of above can be solved by other means, for
    example, a normal class can also follow the
    convention. And if it does - then it is a JavaBean! A JavaBean is any Object whose class definition would include all of the following:
    1) A public, no-argument constructor
    2) Implements Serializeable
    3) Properties are revealed through public mutator methods (void return type, start with 'set' have a single Object parameter list) and public accessor methods (Object return type, void parameter list, begin with 'get').
    4) Contain any necessary event handling methods. Depending on the purpose of the bean, you may include event handlers for when the properties change.
    I am really get confused with it, and
    really want to know what is the main point(s) of
    using the java bean.JavaBeans are normal objects that follow these conventions. Because they do, then you can access them through simplified means. For example, One way of having an object in session that contains data I want to print our might be:
    <%@ page import="my.pack.ShoppingCart %>
    <%
      ShoppingCart cart = session.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        session.setAttribute("cart", cart);
    %>Then later where I want to print a total:
    <% out.print(cart.getTotal() %>Or, if the cart is a JavaBean I could do this:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart" scope="session"/>
    Then later on:
    <jsp:getProperty name="cart" property="total"/>
    Or perhaps I want to set some properties on the object that I get off of the URL's parameter group. I could do this:
    <%
      ShoppingCart cart = session.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        cart.setCreditCard(request.getParameter("creditCard"));
        cart.setFirstName(request.getParameter("firstName"));
        cart.setLastName(request.getParameter("lastName"));
        cart.setBillingAddress1(request.getParameter("billingAddress1"));
        cart.setBillingAddress2(request.getParameter("billingAddress2"));
        cart.setZipCode(request.getParameter("zipCode"));
        cart.setRegion(request.getParameter("region"));
        cart.setCountry(request.getParameter("country"));
        pageContext.setAttribute("cart", cart);
        session.setAttribute("cart", cart);
      }Or you could use:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart" scope="session">
      <jsp:setProperty name="cart" property="*"/>
    </jsp:useBean>The second seems easier to me.
    It also allows you to use your objects in more varied cases - for example, JSTL (the standard tag libraries) and EL (expression language) only work with JavaBeans (objects that follow the JavaBeans conventions) because they expect objects to have the no-arg constuctor, and properties accessed/changed via getXXX and setXXX methods.
    >
    Any help will be highly apprecaited. Thanks!!!
    Best Regards,
    Alex

  • Is there any difference between java Beans and general class library?

    Hello,
    I know a Java Bean is just a java object. But also a general class instance is also a java object. So can you tell me difference between a java bean and a general class instance? Or are the two just the same?
    I assume a certain class is ("abc.class")
    Second question is is it correct that we must only use the tag <jsp:useBean id="obj" class="abc.class" scope="page" /> when we are writng jsp program which engage in using a class?Any other way to use a class( create object)? such as use the java keyword "new" inside jsp program?
    JohnWen604
    19-July-2005

    a bean is a Java class, but a Java class does not have to be a bean. In other words a bean in a specific Java class and has rules that have to be followed before you have a bean--like a no argument constructor. There are many other features of beans that you may implement if you so choose, but read over the bean tutorial and you'll see, there is a lot to a bean that is just not there for many of the Java classes.
    Second question: I'll defer to someone else, I do way to little JSP's to be able to say "must only[\b]".

  • What's the differences between a singleton and a class with static methods

    Hi everybody.
    My question is in the subject. Perhaps "differences" is not the good word. The positive and negative points ?
    Imagine you have to write a connection pool, sure you gonna choose a singleton but why ?
    Thank you very much.

    A class is a class. Java doesn't have (and I wish it
    did) a static outer class. Any class can extend
    another class or implement an interface.A Class object cannot extend or implement anything - it is not under programmer control in any way. You can create a class which implements interfaces, but calling static methods is completely unrelated. Interfaces only affect instance methods, not class ones. I think all of your comparison to C++ is actually confusing you more. In Java, there is a real class object at runtime, as opposed to C++.
    YATArchivist makes a good point about being able to
    serialize, altho I've not met that desire in practice.
    Maybe a concrete example would help.
    mattbunch makes another point that I don't understand.
    A class can implement an interface whether it sticks
    its data in statics or in a dobject, so I guess I
    still don't get that one.See my comment above. Static methods are free from all contractual obligations.
    I prefer instance singletons to singleton classes because they are more flexible to change. For instance I created a thread pool singleton which worked by passing the instance around, but later I needed two thread pools so I made a slight modification to the class and poof! no more singleton and 99% of my code compiled cleanly against it.
    When possible, I prefer to hand the instance off from object to object rather than have everything call Singleton.instance() since it makes changes like I mentioned earlier more feasible.

  • Difference between capture schema and import/register schema

    As far as versioning control, what are the differences, if any, between 1.) capturing a schema's objects thru design editor and 2.) importing and registering a schema?

    Capturing a schema will create instances of the TABLE type in the Designer model.
    Registration creates a new model with new types in the Repository.
    DAvid

  • Difference between new network and extended network

    Difference between extended network and new network settings

    An "extended" network acts as one large wireless network. Wireless devices can roam anywhere a signal is present and stay on the network without having to make any changes.
    A "new" network will require that a wireless device manually "switch" to that network and enter the password for the network to connect whenever you want to use that network. In other words, a "new" network will use a different wireless network name and password, which will require that you manually log on to that network.
    The exception would be if you created a "new" wireless network and used the same wireless network name, same wireless security settings and same password as the "main" network and connected the AirPort back to the main router using an Ethernet cable. In that case, you would have an "Ethernet extended wireless" network.

  • Difference Between Business Object And Class Object

    Hi all,
    Can any one tel me the difference between business object and class Object....
    Thanks...
    ..Ashish

    Hello Ashish
    A business object is a sematic term whereas a class (object) is a technical term.
    Business objects are all important objects within R/3 e.g. sales order, customer, invoice, etc.
    The business objects are defined in the BOR (transaction SWO1). The have so-called "methods" like
    BusinessObject.Create
    BusinessObject.GetDetail
    BusinessObject.Change
    which are implemented (usually) by BAPIs, e.g.:
    Business Object = User
    User.Create => BAPI_USER_CREATE1
    User.GetDetail => BAPI_USER_GET_DETAIL
    CONCLUSION: Business Object >< Class (Object)
    Regards
      Uwe

  • What is the difference between document class and normal class

    Hi,
    Please let me know what is the difference between document class and normal class.
    And I have no idea which class should call as document class or call as an object.
    Thanks
    -Actionscript Developer

    the document class is invoked immediately when your swf opens.  the document class must subclass the sprite or movieclip class.
    all other classes are invoked explicitly with code and need not subclass any other class.

  • Difference between interface pool and class pool

    Hi,
    Can any body tell me the difference between Interface pool and Class pool.
    thank you in advance.
    regards

    Hi,
    Class and Interface Pools
    This section discusses the structure and special features of class and interface pools for global classes.
    Global Classes and Interfaces
    Classes and interfaces are object types. You can define them either globally in the Repository or locally in an ABAP program. If you define classes and interfaces globally, special ABAP programs called class pools or interface pools of type K or J serve as containers for the respective classes and interfaces. Each class or interface pool contains the definition of a single class or interface. The programs are automatically generated by the Class Builder when you create a class or interface.
    A class pool is comparable to a module pool or function group. It contains both declarative and executable ABAP statements, but cannot be started on its own. The runtime system can create runtime instances (objects) through a request using the CREATE OBJECT statement. These objects execute the statements of the class pool.
    Interface pools do not contain any executable statements. Instead, they are used as containers for interface definitions. When you implement an interface in a class, the interface definition is implicitly included in the class definition.
    Structure of a Class Pool
    Class pools are structured as follows:
    Class pools contain a definition part for type declarations, and the declaration and implementation parts of the class.
    Differences From Other ABAP Programs
    Class pools are different from other ABAP programs for the following reasons:
    ·        ABAP programs such as executable programs, module pools, or function modules, usually have a declaration part in which the global data for the program is defined. This data is visible in all of the processing blocks in the program. Class pools, on the other hand, have a definition part in which you can define data and object types, but no data objects or field symbols. The types that you define in a class pool are only visible in the implementation part of the global class.
    ·        The only processing blocks that you can use are the declaration part and implementation part of the global class. The implementation part may only implement the methods declared in the global class. You cannot use any of the other ABAP processing blocks (dialog modules, event blocks, subroutines, function modules).
    ·        The processing blocks of class pools are not controlled by the ABAP runtime environment. No events occur, and you cannot call any dialog modules or procedures. Class pools serve exclusively for class programming. You can only access the data and functions of a class using its interface.
    ·        Since events and dialog modules are not permitted in classes, you cannot process screens in classes. You cannot program lists and selection screens in classes, since they cannot react to the appropriate events. It is intended to make screens available in classes. Instead of dialog modules, it will be possible to call methods of the class from the screen flow logic.
    Local Classes in Class Pools
    The classes and interfaces that you define in the definition part of a class pool are not visible externally. Within the class pool, they have a similar function to local classes and interfaces in other ABAP programs. Local classes can only be instantiated in the methods of the global class. Since subroutines are not allowed in class pools, local classes are the only possible modularization unit in global classes. Local classes have roughly the same function for global classes as subroutines in function groups, but with the significant exception that they are not visible externally
    Reward points if useful....
    Regards
    AK

  • Difference between Data Class and Delivery Class

    What is the Difference between Data Class and Delivery Class , what happens Phisically to the Data .
    Moderator message: what is the difference between your question and a question that we'd welcome here in the forums?
    [Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
    Edited by: Thomas Zloch on Nov 22, 2010 1:17 PM

    What is the Difference between Data Class and Delivery Class , what happens Phisically to the Data .
    Moderator message: what is the difference between your question and a question that we'd welcome here in the forums?
    [Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
    Edited by: Thomas Zloch on Nov 22, 2010 1:17 PM

  • What is the difference between acquiring lock on a CLASS and OBJECT (instance) of that class

    What is the difference between acquiring lock on a CLASS and OBJECT (instance) of that class

    What is the difference between acquiring lock on a CLASS and OBJECT (instance) of that class
    The Java Tutotials has several trails that discuss both implicit and explicit locking, how they work and has code examples.
    The Concurrency trail has the links to the other sections you need to review
    http://docs.oracle.com/javase/tutorial/essential/concurrency/index.html
    The Synchronized Methods and Intrinsic Locks and Synchronization trails discusse Synchronized Methods and Statements
    http://docs.oracle.com/javase/tutorial/essential/concurrency/syncmeth.html
    And the Lock Objects trail begins the coverage of explicit locking techniques.
    http://docs.oracle.com/javase/tutorial/essential/concurrency/newlocks.html

  • Difference between Material Class and Batch Class

    Hi!
    What is the difference between Material Class and Batch Class?
    and how can we use these classes?
    Rgds,
    Ajit

    Iam not sure but i think
    1) Material class for sorting purpose
    2) Batch Class for Batch Management
    thanks
    K.Prabakaran

  • Difference between extends and implements

    hi
    i am new to java. i need to know the difference between extends class implement class.
    can anybody explain in simple words? i am new too oops concept also?
    what are the conditions to use extends class, implement and interface?
    class b extends a implements c
    i know class a is a super class and class b is a sub class.
    if class b extends class a means how should be the class a, what about the methods?
    and class a implements class c means what should be the conditions?
    i searched in Internet but the explanation is not very to me.can body explain me please?
    thank you

    sarcasteak wrote:
    Your class can implement an interface, which means it must use the methods defined in the interface.No, it doesn't need to use them. It needs to implement them. Or be declared abstract.
    Note that the methods in the interface are empty,No, they're not. They're abstract.
    // empty method
    void foo() {}
    // abstract method
    abstract void foo();(The abstract keyword is optional for interface methods, since they're all abstract.
    and you have to define what they do in your class that implements the interface.Just like they have to for abstract methods in a class you extend, if the child class is not declared abstract.
    There really isn't any difference between "extends" and "implements." There is no situation where you can choose. Any case where one is legal, only that one is legal. They could just as easily be a single keyword.
    Presumably the OP's real question is, "When do I use a class for a supertype vs. using an interface for a supertype?" The answer to that, of course, is:
    Use a class when at least some of the methods have valid default implementations. Use an interface when that is not the case. And of course the two are not mutually exclusive. It's quite common to do both.
    At the end of the day, an interface is really nothing more than a class that has no non-final or non-static member variables and whose instance methods are all abstract, and from which you can multiply inherit.
    Edited by: jverd on Feb 4, 2010 1:56 PM

  • The Difference between Extending a Wireless network and WDS?

    I have an Extreme (n) and an Express (n).
    I want to make sure the signal is strong upstairs and share a printer (connected to the express) and use AirTunes. I also may add an external drive to the Extreme.
    What's the difference between Extending a Wireless Network and using WDS? Will there be a speed difference?
    Message was edited by: J. Christopher Edwards

    I think you don't get it
    If I have another draft N router that operates at 2.4G and I have only n devices I can still use WDS and it will connect using draft n in the 2.4G band.
    If one g device connects to the network will go in mixed mode.
    The AEBS will still report 130 Mbps for your n clients and 54 for your g clients.
    If the other router is g only obviously you can't connect between the two router at n mode but still the AEBS will be in mixed mode and not in g. The Extreme will still report 130 Mbps for the connected n clients.
    I can tell you that because I have actually implemented it am not taking off the documentation.
    The same device if I try to use the "extend n network" does not even see the AEBS but will happily keep the n in the WDS mode and though the bandwidth is halved it is still more than g.
    In any case enough for this!

Maybe you are looking for

  • My profile is missing so Firefox won't open at all. How do I reset it then?

    I had been using Firefox for a while off and on, but was using a different browser as my main one. Now that that browser is outdated and there's no update available, I wanted to switch to Firefox permanently. Since all of my bookmarks are only update

  • Videos will no longer play on laptop

    i have tried to look at some of my old videos in my Nokia Suite on my Vista laptop today, but none of them will now play. I get "video cannot be played, the video file may contain an unsupported video format." They have always played before why not n

  • Unexpected problem with Delete Workflow

    G5 iMac, OS 10.4.3 I have been happily running a workflow called delete.files. It allowed me to do a 35-pass delete of sensitive files (financial data) at the click of a mouse in the contextual menu. Suddenly, it would no longer work, so I deleted it

  • Move/Duplicate/Copy

    All, Ok, so essentially I'm trying to write a script so that I can batch process a whole bunch of .SVG files. The .SVG files come from a variety of sources... some open very cleanly with nice layer structure, etc... others open with completely wacked

  • Question mark in folder

    I have question mark in a folder when i turn on my computer this morning. It was still fine last night. I tried few of what others people do on website but it doesnt work. Can anyway I van fix that?