Don't understand Inner Classes and how to use it

Hi
As you guess i 'am a newbie!
I don't understand Inner Classes, particulary members(methods & fields) that an Inner method is able to manipulate.
So I know that the methods of an Inner class (respectively Outer Class) instance can access members (private or public) of an instance of the Outer Class (respectively Inner Class).
I tried to answer to a quizz : http://java.sun.com/developer/onlineTraining/new2java/supplements/quizzes/January03.html
In the following class definition, which variables are inaccessible within the method of the inner class?
class Test1 {
   public static int a = 1;
   private static int b = 2;
   public int c = 3;
   private int d = 4;
   public static class Inner {
     int e = 5;
     public void aMethod(int f) {
       int g = 6;
       // What can't be accessed here?
}A.      b, c, d
B.      c, d
C.      b, c, d, f
D.      None of them
In my opinion members (public or private) of the Outer Class can be accessed by methods of the Inner Class; e.g: a, b, c,d thus for me the answer is D.
Obviously i'm wrong, but why?

Hi
As you guess i 'am a newbie!
I don't understand Inner Classes, particulary
members(methods & fields) that an Inner method is
able to manipulate.
So I know that the methods of an Inner class
(respectively Outer Class) instance can access
members (private or public) of an instance of the
Outer Class (respectively Inner Class).
I tried to answer to a quizz :
http://java.sun.com/developer/onlineTraining/new2java/
supplements/quizzes/January03.html
In the following class definition, which variables
are inaccessible within the method of the inner
class?
class Test1 {
public static int a = 1;
private static int b = 2;
public int c = 3;
private int d = 4;
public static class Inner {
int e = 5;
public void aMethod(int f) {
int g = 6;
// What can't be accessed here?
}A.      b, c, d
B.      c, d
C.      b, c, d, f
D.      None of them
In my opinion members (public or private) of the
Outer Class can be accessed by methods of the Inner
Class; e.g: a, b, c,d thus for me the answer is
D.
Obviously i'm wrong, but why?Inner class method can access all the private members of the class. But the inner class is static. So the non-static members cannot be accessed directly (i.e. c and d).
***Annie***

Similar Messages

  • Don't understand error messages and how to resolve them

    I am having error messages that are confusing. I thought any fonts I used that were not web safe or in Typekit would turn to images, and there would be no problem. What are these errors about? When I view the site in Safari everything looks the way it should.
    Thanks for your help.
    Here is the site:
    http://marystephens.businesscatalyst.com/index.html

    Hi
    As you guess i 'am a newbie!
    I don't understand Inner Classes, particulary
    members(methods & fields) that an Inner method is
    able to manipulate.
    So I know that the methods of an Inner class
    (respectively Outer Class) instance can access
    members (private or public) of an instance of the
    Outer Class (respectively Inner Class).
    I tried to answer to a quizz :
    http://java.sun.com/developer/onlineTraining/new2java/
    supplements/quizzes/January03.html
    In the following class definition, which variables
    are inaccessible within the method of the inner
    class?
    class Test1 {
    public static int a = 1;
    private static int b = 2;
    public int c = 3;
    private int d = 4;
    public static class Inner {
    int e = 5;
    public void aMethod(int f) {
    int g = 6;
    // What can't be accessed here?
    }A.      b, c, d
    B.      c, d
    C.      b, c, d, f
    D.      None of them
    In my opinion members (public or private) of the
    Outer Class can be accessed by methods of the Inner
    Class; e.g: a, b, c,d thus for me the answer is
    D.
    Obviously i'm wrong, but why?Inner class method can access all the private members of the class. But the inner class is static. So the non-static members cannot be accessed directly (i.e. c and d).
    ***Annie***

  • What is inner class ,and how can I use it?thanks

    what is inner class ,and how can I use it?thanks

    Theres a whole chapter here http://developer.java.sun.com/developer/Books/certification/certbook.html (thanks to SSvetlana for pointing this one out).
    Col

  • Private inner class and static private inner

    Hi,
    I understand the concept and usage of inner classes in general.
    When should we go for a private inner class and when for a static private inner class? I tried searching but it wasn't of much help.
    Basically I need to design a caching solution in which I need to timestamp the data object. After timestamping, data will be stored in a HashMap or some other collection. I'm planning to use a wrapper class (which is inner and private) which holds the data object and timestamp. I can make the program work by using either normal inner class or static inner class, however would like to know which is better in such case. Also If I can get some general guidelines as to when to use a staic inner class and when to use a normal inner class, it would help me.
    Thanks in advance.

    user1995721 wrote:
    When should we go for a private inner class and when for a static private inner class?
    I can make the program work by using either normal inner class or static inner class, however would like to know which is better
    If I can get some general guidelines as to when to use a static inner class and when to use a normal inner class, it would help me.Making the inner class static is helpful in that it limits visibility.
    If the inner class needs to access non-static fields or methods from the containing class instance
    the inner class has to be non-static.

  • Can anyone help me change fonts and size on my page? I don't understand the class questions?

    Can anyone help me change fonts and size on my page? I don't understand the class questions? All I want to do is change the font and size of a table or div.
    http://www.allgearinc.com/AG12SSWL-Swift.htm -One problem page

    If you want to change the fonts of the entire page then this code will do the trick:
    body {
        font-size: 16pt;
        color: silver;
         font-family: whatever, goes, here;
    If you want to change the fonts of ALL tables on a page then the code is something like this:
    table {
        font-size: 20pt;
        font-family: "Courier New", Courier, monospace;
        font-style: italic;
        font-weight: bold;
    what exactly do you want to change?  Can you be a bit specific so that Ben or Ken can give you the exact code and tell you about the short-hand method to write the code in one line.
    Have you bought a book on CSS yet?  If not, it is a good idea to get one as a reference.  Eric Meyer writes good books on CSS.

  • Where we use the window class in the sql and how to use it

    where we use the window class in the sql and how to use it

    http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions004.htm#SQLRF06174
    Regards
    Etbin

  • What is meant by Local Class and how we can create local classes in abap?

    Hi Friends
    what is meant by Local Class and how we can create local classes in abap?
    Regards,
    Sree

    Hi
    Local classes are the classes which we declare and use using the SE38 ABAP editor
    Global classes are the classes which we find in SE24 and call the methods of them into our program.
    see the sample code
    REPORT zs_class.
    SELECTION SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
    PARAMETERS:p_var TYPE i,
    p_var1 TYPE i.
    SELECTION-SCREEN END OF BLOCK b1.
    CLASS d_class DEFINITION
    CLASS d_class DEFINITION.
    PUBLIC SECTION.
    METHODS:
    add,
    sub.
    PROTECTED SECTION.
    DATA : var2 TYPE i.
    ENDCLASS. "d_class DEFINITION
    CLASS d_class IMPLEMENTATION
    CLASS d_class IMPLEMENTATION.
    METHOD add.
    var2 = p_var + p_var1.
    WRITE:/ var2.
    ENDMETHOD. "add
    METHOD sub.
    var2 = p_var - p_var1.
    WRITE:/ var2.
    ENDMETHOD. "sub
    ENDCLASS. "d_class IMPLEMENTATION
    START-OF-SELECTION
    START-OF-SELECTION.
    DATA: obj TYPE REF TO d_class.
    CREATE OBJECT: obj .
    CALL METHOD: obj->add,
    Regards
    Anji

  • Why and how to use events in abap objects

    Dear all,
      Please explain me why and how to use events in abap objects with real time example
    regards
    pankaj giri

    Hi Pankaj,
    I will try to explain why to use events... How to use is a different topic.. which others have already answered...
    This is same from your prev. post...
    Events :
    Technically speaking :
    " Events are notifications an object receives from, or transmits to, other objects or applications. Events allow objects to perform actions whenever a specific occurrence takes place. Microsoft Windows is an event-driven operating system, events can come from other objects, applications, or user input such as mouse clicks or key presses. "
    Lets say you have an ALV - An editable one ...
    Lats say - Once you press some button  you want some kind of validation to be done.
    How to do this ?
    Raise an Event - Which is handled by a method and write the validation code.
    Now you might argue, that I can do it in this way : Capture the function code - and call the validate method.
    Yes, in this case it can be done.. But lets say .. you change a field in the ALV and you want the validation to be done as soon as he is done with typing.
    Where is the function code here ? No function code... But there is an event here - The data changed event.
    So you can raise a data changed event that can be handled and will do the validation.
    It is not user friendly that you ask the user to press a button (to get the function code) for validation each time he enters a data.
    The events can be raised by a system, or by a program also. So in this case the data changed event is raised by a system that you can handle.
    Also, Lets say on a particular action you want some code to trigger. (You can take the same example of validation code). In this case the code to trigger is in a separate class. The object of which is not available here at this moment. (This case happens very frequently).
    Advantage with events : Event handlers can be in a separate class also.
    e.g : In the middle of some business logic .. you encounter a error. You want to send this information to the UI (to user - in form of a pop up) and then continue with some processing.
    In many cases - A direct method call to trigger the pop up is not done. Because (in ideal cases) the engine must not interact with UI directly - Because the UI could be some other application - like a windows UI but the error comes from some SAP program.
    So - A event is raised from the engine that is handled in the UI and a pop up is triggered.
    Here -- I would have different classes (lets say for different Operating Systems). And all these classes must register to the event ERROR raised in application.
    And these different classes for different Operation systems will have different code to raise a pop-up.
    Now you can imagine : If you coded a pop-up for Windows (in your application logic) .. it will not work for Mac or Linux. But of you raise a event.. that is handled separately by a different UI classes for Win, Linux or Mac  they will catch this event and process accordingly.
    May be I complicated this explanation .... but I couldn't think of a simpler and concrete example.
    Cheers.
    Varun.

  • On-The-Go Playlist: what is it and how to use?

    I've read the notice on the iPod when you select the On-the-Go playlist but don't know what it does and how to best use it. I've tried to add a song to it by holding down the center button while the song was playing but don't know how to check to see if it's been added. When I go to the On-the-Go playlist in the menu I only get the text instructions. Can someone describe how to add, and remove, songs from it or tell me if you can and how to use it?
    OT

    EDIT: BAH! I posted too slow... but there is still some information about saving and clearing in there
    Its for making a playlist while your 'on the go'. So you click and hold the middle button the selected song (or album) should flash... Then you go into the playlist menu (music>playlists>on-the-go) and use it like any normal playlist...
    When there's songs on the playlist it gives you the option to save or clear at the end of the song list, you select either one and it'll ask for conformation.
    It works in both manually sync and auto sync mode. But if you have it on auto sync the play list will be created in iTunes...
    So I'm not sure why you don't see songs in it after yo assign them to it, try sending a whole album and then music>playlists>on-the-go the album songs should be listed.
    As for reasons to use it well maybe while out and about you realise that you want to hear from two artists at the same time, Radiohead and Bowie, in a shuffle mode. You could make it a on-the-go playlist. Or there's a few podcasts you want to hear in order... so you go down the list and assign them to on-the-go.
    Some people use the On the go to note songs that need to be looked at in iTunes later, maybe because its too quiet, badly imported or they don't understand how such a bad song found its way onto the iPod.
    Once you save it if you try and put more songs to it, 'on-the-go-1' will be created.
    -hope this helps

  • What's the Commitment item? And how to use it?

    When I create a G/L account by FS00 I need to input a Commitment item.
    But I don't know how to use it.
    Can you tell me what's the Commitment item? And how to use it?
    Thank you very much.
    Moderator: Try pressing F1 or going to help.sap.com

    >>In SAP XI / PI, WS adapter is not thier frm standard SAP.
    Are you sure about this?
    WS is a standard adapter shipped along with PI 7.1 installation.
    Quote from help.sap.com
    Using the WS adapter you can configure the communication of systems, which communicate with each other using the Web service runtime either directly (point-to-point) or using the Integration Server
    Refer:
    http://help.sap.com/saphelp_nwpi71/helpdata/en/0d/5ab43b274a960de10000000a114084/content.htm
    http://help.sap.com/saphelp_nwpi71/helpdata/en/45/37d73b80554c2ce10000000a1553f6/frameset.htm
    If you are not sure about what you are saying, it is better not to say it.

  • VPN. What's this and how to use it?

    Hello,
    Recently I started to work from home and not the office. To connect to my work server my company's sysadmin sent me the requisites to connect to VPN (I need to ssh to my work server but it's allowed to the limited set of IPs). But I have no idea what to do next. How to set up the connection and how to use it?
    Thanks

    Thanks! I've tried to follow the steps described in the wiki article but unfortunately stucked on 'Making Your Connection' section:
    # pon tunnel debug dump logfd 2 nodetach
    pppd options in effect:
    debug # (from command line)
    nodetach # (from command line)
    logfd 2 # (from command line)
    dump # (from command line)
    noauth # (from /etc/ppp/options.pptp)
    refuse-pap # (from /etc/ppp/options.pptp)
    refuse-chap # (from /etc/ppp/options.pptp)
    refuse-mschap # (from /etc/ppp/options.pptp)
    refuse-eap # (from /etc/ppp/options.pptp)
    name pshevtsov # (from /etc/ppp/peers/tunnel)
    remotename PPTP # (from /etc/ppp/peers/tunnel)
    # (from /etc/ppp/options.pptp)
    pty pptp xx.xx.xx.xx --nolaunchpppd # (from /etc/ppp/peers/tunnel)
    crtscts # (from /etc/ppp/options)
    # (from /etc/ppp/options)
    asyncmap 0 # (from /etc/ppp/options)
    lcp-echo-failure 4 # (from /etc/ppp/options)
    lcp-echo-interval 30 # (from /etc/ppp/options)
    hide-password # (from /etc/ppp/options)
    ipparam tunnel # (from /etc/ppp/peers/tunnel)
    proxyarp # (from /etc/ppp/options)
    nobsdcomp # (from /etc/ppp/options.pptp)
    nodeflate # (from /etc/ppp/options.pptp)
    require-mppe-128 # (from /etc/ppp/peers/tunnel)
    noipx # (from /etc/ppp/options)
    using channel 28
    Using interface ppp0
    Connect: ppp0 <--> /dev/pts/3
    sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x3541a215> <pcomp> <accomp>]
    sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x3541a215> <pcomp> <accomp>]
    sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x3541a215> <pcomp> <accomp>]
    sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x3541a215> <pcomp> <accomp>]
    sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x3541a215> <pcomp> <accomp>]
    sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x3541a215> <pcomp> <accomp>]
    sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x3541a215> <pcomp> <accomp>]
    Script pptp xx.xx.xx.xx --nolaunchpppd finished (pid 26089), status = 0x0
    Modem hangup
    Connection terminated.
    I don't know what to do

  • I want to know what's the conference call in community level and how to use it

    i want to know what's the conference call in community level and how to use it

    Welcome to Apple Support Communities
    Conference calls are got when you reach level 4. Sometimes, ASC hosts may do a conference call about something related to Apple Support Communities. You will be notified through mail or through the "Using Apple Support Communities" forum.
    The last community calls were only for level 6 and higher users, so it's possible that you don't get invited to any until you reach level 6

  • How to create a hierarchy in Regional Structure and how to use it

    Hi,
    Please guide me how to create a Political Region Structure hierarchy and how to use it.
    Thanks and Regards

    Hi,
    Thanks for reply please.
    I request you to please copy paste all the possible information here. It will be a great help.
    I hope you understand why we can not provide our id on this forum.
    Please guide.
    Thanks and Regards
    Edited by: MP Vashishth on May 18, 2009 7:14 AM

  • How to create the servlet as acontroller  and how to use it

    how to create the servlet as acontroller and how to use it

    >
    John
    Please update your forum profile with a real handle instead of "914824".
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    I am going to have over 50 buttons in a page, Why? This would be a most unusual UI paradigm. I've never seen such a page, which suggests that whatever you want to do is normally done another way. Please explain the requirement in more detail.
    just wanted to know if its possible to do something like this in java.
    Java is not used in programming APEX UI behaviour. Java and JavaScript may share initial syllables, but they are not closely related.
    It's possible to achieve a great deal in JavaScript, but a clear definition of the requirements is necessary. Do you mean the buttons should be dynamically generated? If so, yes, this is possible in JavaScript. What would drive the process?
    Also, i would like to have dynamic action on it, for example, when the button is pressed, fill a string of text into other items(text field) within the page. Without more detail its not possible to make any specific suggestions. For example, I certainly would not want to create 50+ individual dynamic actions relating to different buttons.

  • What are variables or parameters in Apex and how to use them?

    Hi
    What are variables or parameters in apex and how to use them to connect and run BI Publisher Report
    From Apex URL

    Hello Kanaiya,
    You should go here: http://www.oracle.com/technology/products/database/application_express/index.html
    Look at "What is Oracle APEX?" then download the documentation and review the various PDF files that are available.
    If you have a version of APEX installed and available, go through the 2-Day Application Express Developer's Guide followed by the Advanced Developer's Guide.
    Good luck,
    Don.

Maybe you are looking for