What makes a class a "top-level" class?

1.
2.    public static int getThis() {
3.      int x = 4;
4.      int y = 5 * x;
5.      return y;
6.    }
7.  }
8.
9.  public class NetGro extends ToNet {
10.    public static void main(String args[]) {
11.      int z = getThis();
12.      System.out.println("Z = " + z);
13.    }
14.  }At line 1 of this program, ToNet "can only be declared as public or the default of no modifier" (not private or protected) because it's a "top-level class." What makes ToNet a "top-level class?"

A class or interface is 'Top-Level' if it is not nested inside another class or interface.
Otherwise the class would not be visible... Private and Protected for classes and interface only make sense within another class or interface as inner classes or interfaces.
Hope that helps...

Similar Messages

  • How to create top level classes

    what is the meaning of top level classes. and how to create toplevel classes.

    http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000188.html

  • How to make  menuBar UI listen for top level click

    Hi,
            The  menubar only listen to the sub level menu item(i mean click), and I  would like to make menubar listen to top level also.
    for eg:
    NEWS-> worldnews.
    it listen the sublevel item worldnews ,i would like to make top level NEWS also.
    I  tried using selected index. sometimes  -1 was returned when I clicked  the “NEWS” item.  I assume this is because it has sub-menu items.
    can anyone give solution for this???????

    hi Neobox75,
    I have created an air application for a  news website( i didnt finsh it fully) . I display the images ,news everythng using feed. I used httpservice to get the values from the feed. now my problem is if i deploy this package to the user means if he has the internet connection ...All my information wil be displayed to him as i read all the information through feed .  if the network conection is not available(offline) means i have to  display the previous news and images to him( if v use timer to refresh it wil be cached in user system  but i dnt knw how to retreive from cache if the user is offline ).how it can be done please give the solution for it...
    regards,
    divya.

  • How to find top level object on a given layer?

    I need to assign it to a var...
    var topLevelObj = app.activeDocument.layers.name("foo")... whatever is on top of that stack...
    ...this is probably not correct but you know what I mean

    Jump_Over wrote:
    Hi,
    top level object is the first in a collection:
    var fooLayerTopObj = app.activeDocument.layers.item("foo").pageItems[0]
    Jarek
    I'm not very good in ID-scripting, but I think this isn't good enough to find topmost item of a layer.
    Why?
    - create a new document
    create a polygon
    create a rectangle
    create an ellipse
    create a line
    Run this script snippet:
    var pI = app.activeDocument.layers.item(0).pageItems;
    for (i=0; i<=pI.length-1; i++) {
    pI[i].select();
    alert (i);
    pI[i].locked = true;
    Do you see, which element pageItems[0] is?

  • What is top level class declaration in java?

    What is top level class declaration in java?

    The declaration of a class that's not nested inside any other class.

  • Declaring top level classes instead of subclasses

    I seem to have misunderstood something very basic.
    It's always better, where possible, to declare the top-level class instead of the sub-class, right?
    Ok, then why do I have the following problem?
    I declare, from the JavaMail API the following:
    Message theMessage = new MimeMessage(session);instead of declaring directly the subclass like this:
    MimeMessage theMessage = new MimeMessage(session);but when I use a method which is only found in the MimeMessage class I get a compile error.
    [javac] 189.           theMessage.setSubject(subject, "iso8859_1");
    [javac] <-------------------------------->
    [javac] *** Error: No match was found for method "setSubject(java.lang.String, java.lang.String)".
    Have I really misunderstood something so basic?? Surely the compiler knows that theMessage is an instance of MimeMessage??
    Any clear explanation to explain why I get this compile error would be gratefully received. I have been faithfully declaring top-level classes instead of subclasses in my code, but if the compiler doesn't let you do so, then what's the point?

    Ok, my confusion was started by an article on the
    Collection classes which stated that:
    Map theMap = new HashMap(); was better
    programming practice.
    Yep.
    But the Map class is an Interface, right? - Whereas
    Message is a normal class with subclass MimeMessage.
    I think that's where my confusion started.Well, this isn't really a class vs. interface difference. It goes to which class (or interface) is the "highest" (closest to Object) and still has all the public interface you need.
    There are cases where you'll declare a variable to be of a base class type like Message.
    You just need to get into the habit of separating the left side of the = from the right side. On the left, you put the bare minimum that completely meets your needs. You say, "I need a List" or "I need a Map" or "I need a SortedMap" (a subinterface of Map) or "I need a Message" or "I need a MimeMesage".
    Then, on the RHS =, you decide which particular class best implements the public interface that you said you need (by declaring it on the LHS). "For my Map, I'll use a HashMap." "For my Message, I'll use a MimeMessage." "For my MimeMessage, I'll use a MimeMessage".

  • Top level class ?

    hi,
    i am preparing the sun certified java progammer, there's some questions involving "top level class", i don't understand what is a top level class ? can anyone give me some information about it ? is it a class at the top of a package hierarchie like class Object ????
    thanks for your help

    hi,
    i am preparing the sun certified java progammer,
    there's some questions involving "top level class", i
    don't understand what is a top level class ? can
    anyone give me some information about it ? is it a
    class at the top of a package hierarchie like class
    Object ????No. See
    http://java.sun.com/docs/books/jls/second_edition/html/packages.doc.html#26783
    Jim S.

  • Release memory for nested top-level classes

    Hello experts.
    I have a top-level class which consists of several static methods. Inside such a method I create several new instances of a nested top-level class inside my original class. Later I want to release one of these instances i.e. destroy instance and free memory. How can I do that?
    Thanks.

    sure, but I do not see any references to this nested top-level class. With "Releasing" I mean something like directly assigning a NULL value to the nested top-level clas in order to enable GC.
    But as I said there are no references and while monitoring the memory I see that the GC does not collect some memory. (I know that GC is not reliable, but after ten attempts of this scenario the memory allocation is equal the whole time).
    I guess the GC does not work with classes, but the classloader. But how can I control releasing memory in this scenario?
    Any further hints?

  • Shell we make a class as an interface?

    shell we make a class as an interface then how ? give me one example

    shell we make a class as an interface then how ?What do you mean? Currently something is a class and you want to change that type to an interface?
    If so, then as for "shall you," I don't know. That depends on your needs, time, and skill level.
    give
    me one exampleAssuming you mean what I think you mean, it might be something like this:
    // BEFORE
    public class Foo {
        public void doStuff() { /* do some stuff */ }
    Foo foo =new Foo();
    foo.doStuff();
    // AFTER
    public interface Foo {
        void doStuff();
    public class SimpleFoo implements Foo {
        public void doStuff() { /* do some stuff */ }
    Foo foo = new SimpleFoo();
    foo.doStuff();

  • How to make top level navigation not refresh

    Hello Guys,
    I have a question concerning on my External Facing Portal, my boss wants that when I click on a tab or a link in the Top Level Navigation , to load the content in the Content Area without refreshing the whole page, What I want is that when I click on a tab or link of the Top Level Navigation , the Top Level Navigation and the MasterHead not to refresh and that the content be loaded and refreshed only in the Content Area. The only way I know to do this is by making a frameset of my page and to make the masterhead and toplevel navigation a frame and the detalied navigation a frame and the content area a frame, and in the links to put the target property to the name of the content area frame, but I don't know if this is possible to do in the portal, I see that all is embedded and I don't know how to make a frameset like this in the portal.
    Any highlights to solve this will sure be appreciated.
    Thanks
    Rewarding points will be given.
    Luis

    Hi,
       When you are implementing External Facing Portal, i think you have used Light Framework Page.  In Light Framework Page, only one Framework has been used, so when you click on the top level navigation, the whole page will get refresh, so there is no otherway as of my knowledge.  If you use standard framework page in portal, it is possible to do (i.e. the content area only get refresh)  and the concept of your External Facing Portal is eliminated here.
    Regards,
    Venkatesh. K
    /* Points are Welcome */

  • What is the best way of converting a Top Level VI into a 'sub vi' - or function ( without duplicating programming)

    Hi,
    General question here about design architecture, which i keep running into, but haven't found a really good solution.  If i write a 'Top Level VI' to do something, what is the best way of converting it into a subVI - which is call-able from other VIs, while still allowing the top level VI to have synchronised feedback/indicator updates.
    I guess the point is that when something is a top level VI you write gui logic about what happens when someone clicks buttons or whatever - which you don't want in the 'sub vi' version.
    I did at one point try having a hidden boolean button that was an input to the subVI which would let the VI know if it was supposed to be doing the front panel stuff - or simply running as a subVI.  This isn't really ideal though - since it would be better to be able to hive off the grizzly useful stuff from the fluffy - front panel updating stuff - having them together makes the VIs rather untidy.  More annoyingly though, if you have the front panel version of it running - say waiting for you to hit 'go', it breaks all the other VIs that use it as a sub vi - since they can't compile when a sub vi is already running.
    Another possibility that i tried was to basically duplicate the vi so that there was a backend part, and a front end part - and when i click 'go' the backend part is called as a sub vi.  The problem with this is that it really limits the interface that the user gets - since none of the controls on the front panel update with the results untill the sub vi is over.  I guess again i could solve this by passing references to some of the controls to update them in the subvi - but this doesn't really seem like the ideal situation if the subvi is called by something else without the same types of controls etc.
    One final idea i had was to essentially paste all the controls in the VI into a global variable file, and make the sub vi update them, and the front panel VI read from them.  This seems to 'work' - although clearly it is a work around rather than a proper solution - since i spend loads of time worrying about how i update cluster variables in the global - reading and writing.
    Does anyone have any guidance on what they do to solve this problem?
    JP

    You could run a subvis in a Subpanel on your top level.  Lets you see the current data while the subvi is running.
    --Using LV8.2, 8.6, 2009, 2012--

  • Could anyone tell me what is a class

    Hi gurus,
                  could anyone explain me in detail what does a class mean (se24) in sap and for what it is used? i have tried my best to know about it. it is like greek and latin to me.
    Thanks in advance,
    Ramana

    Classes describe objects. From a technical point of view, objects are runtime instances of a class. In theory, you can create any number of objects based on a single class. Each instance (object) of a class has a unique identity and its own set of values for its attributes.
    classes consist of ABAP source code, enclosed in the ABAP statements CLASS ... ENDCLASS. A complete class definition consists of a declaration part and, if required, an implementation part. The declaration part of a class <class> is a statement block:
    CLASS <class> DEFINITION.
    ENDCLASS.
    It contains the declaration for all components (attributes, methods, events) of the class. When you define local classes, the declaration part belongs to the global program data. You should therefore place it at the beginning of the program.
    If you declare methods in the declaration part of a class, you must also write an implementation part for it. This consists of a further statement block:
    CLASS <class> IMPLEMENTATION.
    ENDCLASS.
    The implementation part of a class contains the implementation of all methods of the class. The implementation part of a local class is a processing block. Subsequent coding that is not itself part of a processing block is therefore not accessible.
    Structure of a Class
    The following statements define the structure of a class:
    A class contains components
    Each component is assigned to a visibility section
    Classes implement methods
    The following sections describe the structure of classes in more detail.
    Class Components
    The components of a class make up its contents. All components are declared in the declaration part of the class. The components define the attributes of the objects in a class. When you define the class, each component is assigned to one of the three visibility sections, which define the external interface of the class. All of the components of a class are visible within the class. All components are in the same namespace. This means that all components of the class must have names that are unique within the class.
    There are two kinds of components in a class - those that exist separately for each object in the class, and those that exist only once for the whole class, regardless of the number of instances. Instance-specific components are known as instance components. Components that are not instance-specific are called static components.
    In ABAP Objects, classes can define the following components. Since all components that you can declare in classes can also be declared in interfaces, the following descriptions apply equally to interfaces.
    Attributes
    Attributes are internal data fields within a class that can have any ABAP data type. The state of an object is determined by the contents of its attributes. One kind of attribute is the reference variable. Reference variables allow you to create and address objects. Reference variables can be defined in classes, allowing you to access objects from within a class.
    Instance Attributes
    The contents of instance attributes define the instance-specific state of an object. You declare them using the DATA statement.
    Static Attributes
    The contents of static attributes define the state of the class that is valid for all instances of the class. Static attributes exist once for each class. You declare them using the CLASS-DATA statement. They are accessible for the entire runtime of the class.
    All of the objects in a class can access its static attributes. If you change a static attribute in an object, the change is visible in all other objects in the class.
    Methods
    Methods are internal procedures in a class that define the behavior of an object. They can access all of the attributes of a class. This allows them to change the data content of an object. They also have a parameter interface, with which users can supply them with values when calling them, and receive values back from them The private attributes of a class can only be changed by methods in the same class.
    The definition and parameter interface of a method is similar to that of function modules. You define a method <met> in the definition part of a class and implement it in the implementation part using the following processing block:
    METHOD <meth>.
    ENDMETHOD.
    You can declare local data types and objects in methods in the same way as in other ABAP procedures (subroutines and function modules). You call methods using the CALL METHOD statement.
    Instance Methods
    You declare instance methods using the METHODS statement. They can access all of the attributes of a class, and can trigger all of the events of the class.
    Static Methods
    You declare static methods using the CLASS-METHODS statement. They can only access static attributes and trigger static events.
    Special Methods
    As well as normal methods, which you call using CALL METHOD, there are two special methods called CONSTRUCTOR and CLASS_CONSTRUCTOR, which are automatically called when you create an object (CONSTRUCTOR) or when you first access the components of a class (CLASS_CONSTRUCTOR).
    Events
    Objects or classes can use events to trigger event handler methods in other objects or classes. In a normal method call, one method can be called by any number of users. When an event is triggered, any number of event handler methods can be called. The link between the trigger and the handler is not established until runtime. In a normal method call, the calling program determines the methods that it wants to call. These methods must exist. With events, the handler determines the events to which it wants to react. There does not have to be a handler method registered for every event.
    The events of a class can be triggered in the methods of the same class using the RAISE EVENT statement. You can declare a method of the same or a different class as an event handler method for the event <evt> of class <class> using the addition FOR EVENT <evt> OF <class>.
    Events have a similar parameter interface to methods, but only have output parameters. These parameters are passed by the trigger (RAISE EVENT statement) to the event handler method, which receives them as input parameters.
    The link between trigger and handler is established dynamically in a program using the SET HANDLER statement. The trigger and handlers can be objects or classes, depending on whether you have instance or static events and event handler methods. When an event is triggered, the corresponding event handler methods are executed in all registered handling classes.
    Instance Events
    You declare instance events using the EVENTS statement. An instance event can only be triggered in an instance method.
    Static Events
    You declare static events using the CLASS-EVENTS statement. All methods (instance and static methods) can trigger static events. Static events are the only type of event that can be triggered in a static method.
    See also Triggering and Handling Events.
    Types
    You can define your own ABAP data types within a class using the TYPES statement. Types are not instance-specific, and exist once only for all of the objects in a class.
    Constants
    Constants are special static attributes. You set their values when you declare them, and they can then no longer be changed. You declare them using the CONSTANTS statement. Constants are not instance-specific, and exist once only for all of the objects in a class.
    Visibility Sections
    You can divide the declaration part of a class into up to three visibility areas:
    CLASS <class> DEFINITION.
      PUBLIC SECTION.
      PROTECTED SECTION.
      PRIVATE SECTION.
    ENDCLASS.
    These areas define the external visibility of the class components, that is, the interface between the class and its users. Each component of a class must be assigned to one of the visibility sections.
    Public Section
    All of the components declared in the public section are accessible to all users of the class, and to the methods of the class and any classes that inherit from it. The public components of the class form the interface between the class and its users.
    Protected Section
    All of the components declared in the protected section are accessible to all methods of the class and of classes that inherit from it. Protected components form a special interface between a class and its subclasses. Since inheritance is not active in Release 4.5B, the protected section currently has the same effect as the private section.
    Private Section
    Components that you declare in the private section are only visible in the methods of the same class. The private components are not part of the external interface of the class.

  • Can you find out what packages a class has imported?

    Hi all, I start my final year at uni in september and at the moment i'm just experimenting with stuff while i try and decide what to do for my final year project.
    Without going into too much detail what i want to be able to do is for the client to "submit" a class file that is then dynamically loaded and run on the server. Obviously this has security implications so what i was wondering was if it is possible to determine what packages a class has imported from the actual classfile.
    I've looked through the vm spec but haven't been able to find anything theyre that looks like it'll help. Any suggestions or ideas (or solutions!) would be much appreciated.
    Thanks. Matt.

    You could use the Class.getDeclaredClasses() to see the class types that exist as members, but that won't do you any good since the class will have already undergone static initialization within your VM, and the security breach would have already been made. You could inspect the constant pool in the class data to check what other classes are referenced but then that brings up several questions:
    1 - How do you know which classes are bad? Even if you define a set, copies can be created in new packages (or simply aliased) so that the list is invalid.
    2 - How do you know the class you are loading is not malicious? A client class may not reference any external class but may be malicious itself.
    3 - The offending class might use reflection exclusively to reference classes without leaving a trace in the class file. This would be absolutely impossible to detect.
    Your only choices are (a) to use signed classes, and make it the responsibility of someone to review the classes and sign them, or (b) install your own Security Manager to catch all prohibited activity, or (c) check as classes are referenced in the classloader. Option (a) is the best method, but (b) or (c) might work in a very restricted environment.

  • What is valuation class

    what is valuation class? where do we make settings for it?
    Can we make new valuation class?

    Hi
    Assignment of a material to a group of G/L accounts
    With other factors, the valuation class determines the G/L accounts that are updated as a result of a valuation-relevant transaction or event such as a goods movement.
    The valuation class makes it possible to:
    Post the stock values of materials of the same material type to different G/L accounts
    Post the stock values of materials of different material types to the same G/L account
    Yes you can create new valuation Classes
    You can define the Valuation Calsses in Transaction OMSK or SPRO-> MATerails Management-> Valuation and Account Assignment-> Account Determination-> Account Determination Without Wizard-> Define Valuation Classes
    Under valuation class, define the valuation classes for each account category reference.
    Thanks & Regards
    Kishore

  • What  is  Persistancy  Class ?

    What is  Persistancy  Class ?..with  Example  .

    Hi Girish,
       There is a way to avoid building a fully object-oriented program while still working with non-object-oriented relational database. The object services layer now provides a <b>persistence framework</b> that closes the object-relational gap.
    You no longer need to write <b>SQL code</b> as objects are transparently loaded from the database when needed. You must create a <b>persistent class</b>. Choose transaction SE24 and create a persistent class; this class must be protected.
    steps :
    Go to se 24 - choose persistence class
    it will be always protected class.
    next screen will give u the persistence button when u click on that it will ask u to
    add the table or struture.
    now u can see two division of the screen where bottom portion of the screen will list uall the fields available and u need to double click and map to the top portion.
    Save the persistence class and hit back button..
    Whenever u create persistence class zcl_example_persist - it will create two classes - zca_example_persist
    and zcb_example_persist automatically
    Where zca_example_persist is the agent class and zcb_example_persist is base agent class..
    Save and activate.
    Activate the whole class. Now that we have a persistent object to access the database table SFLIGHT, we must access it in a program. Here is a small example to read/write data into SFLIGHT using persistent objects.
    REPORT  ZPERSISTENCECLASS.
    data : l_flight type ref to zcl_persist.
    data : l_flight_agent type ref to zca_persist.
    data : l_seatsfree type i.
    data : l_seatsocc type i.
    l_flight_agent = zca_persist=>agent.
    * CATCH CX_OS_OBJECT_NOT_FOUND .
    *ENDTRY.
    *TRY.
    CALL METHOD L_FLIGHT_AGENT->GET_PERSISTENT
      EXPORTING
        I_CARRID = 'LH'
        I_CONNID = '0400'
        I_FLDATE = '20060701'
      RECEIVING
        RESULT   = l_flight
    * CATCH CX_OS_OBJECT_NOT_FOUND .
    *ENDTRY.
    l_seatsfree = L_FLIGHT->GET_SEATSMAX( ) - L_FLIGHT->GET_SEATSOCC( ).
    if l_seatsfree > 0.
    l_seatsfree = L_FLIGHT->GET_SEATSOCC( ) + 1.
    l_flight->set_seatsocc( l_seatsfree ).
    endif.
    There are lots of other methods and techniques that you can use in persistent classes.
    A demonstration of this can be found in program <b>DEMO_CREATE_PERSISTENT</b>.
    <b>DEMO_QUERY_PERSISTENT</b>
    kindly look into below link for screen shot to create persistence class
    http://erpgenie.com/abaptips/content/view/417/38/
    Regards
    Sathish

Maybe you are looking for

  • Win 7 x64 LJ2100tn network install

    I could use some new ideas about installing a Laserjet 2100tn through a network with a Linksys wrt54GS router. Printer works fine on network through XP, with 3 desktops, 1 laptop and 1 netbook.  Tried the HP network diagnostic through XP and it can't

  • Hyperlink to PDF

    Hi We are planning on storing report information pdf documents in a unique folder defined under folder in the Central Management Console" Each report will have a unique report information pdf document. Is it possible to create a hyperlink from my web

  • Printer will only print 2 pages then say error - windows 8

    Hi, we have purchased a new laptop to make life simpler, only things never end up being that way. Currently we are having trouble printing more than 1 page, the computer on the second page half way through will bleep and an error message will be disp

  • Hash Table Misses Are Expensive

    I have built several Hash Databases with 80,000 records in them, and indexed on an ascii string (person's name). I am processing their audited history, and each person has several hundred events. At the receiving of a new event I first check to see i

  • Automatic SOS in shopping cart for reservation items

    Dear all, I am creating a shopping cart using a catalog item that creates a reservation in the backend (classic). However, when i change sthing, the system reads an info record that exist in the back-end and assigns the vendor as the source of supply