- Find the 'Run' menu item from the start menu.
- Open up a command prompt and type:
java -version
....or you can just visit the Oracle site :)
Access Modifiers | Private, Public & ProtectedAn access modifier determines the visibility of a class member (states & behaviours).An access modifier of Public allows a class member to be accessed from external objects & is denoted on a class diagram with a + (addition) symbol. A Private access modifier allows only internal access and prevents access by external objects. Private access is denoted on a class diagram with the - (minus) symbol. The Protected access modifier allows internal access and access by child classes. Protected access is denoted on a class diagram with the # (hash) symbol. |
Access Modifiers | Private, Public & ProtectedAn access modifier determines the visibility of a class member (states & behaviours).An access modifier of Public allows a class member to be accessed from external objects & is denoted on a class diagram with a + (addition) symbol. A Private access modifier allows only internal access and prevents access by external objects. Private access is denoted on a class diagram with the - (minus) symbol. The Protected access modifier allows internal access and access by child classes. Protected access is denoted on a class diagram with the # (hash) symbol. |
Constructor OverloadingMultiple constructors may be provided within a class to allow object construction to take place in a variety of ways.Each constructor MUST have a unique parameter list. For example:
However, a constructor may contain a parameter list of (string, integer) and another constructor may have a parameter list of (string, integer, integer). The following demonstrates the correct implementation of constructor overloading: Public Player (String name, Integer credits){} Public Player (String name, Integer credits, Integer gameID){} By providing a second constructor in the Player class, a Player object may be instantiated with an additional parameter. The following is incorrect: Public Player (String name, Integer credits){} Public Player (String name, Integer gameID){} Another example In this example, we will be concentrating on the two constructors of this Player class (therefore, all of the other behaviours that you might expect to see here have not been included).
Figure 6: Player class with overloaded constructors
When a player logs into the game network, a new Player object is created with what is known about the player at that time. As the player has not yet joined a game, only the Name and number of Credits is known.
Later on, another player logs into the game network via an alternate method that leads directly to a game that is in progress. As the player has elected which game to join during the login process, the Name, Credits & GameID of the player is known when the new Player object is created.
|