Gadgets

Tuesday, 19 February 2013

Naming conventions Rules and Special characters in java


Naming conventions Rules:-
1)      Package names in java are written in all small letters
  EX: - java.awt;
                      java.io;
                      javax.swing;
2)      Each word of a class name and interface name start with a capital letter.
EX: - String, DataInputStream, ActionListener
3)      Method names starts with a small letter, then each word starts with a capital letter.
EX: - readLine( ); , getNumberInstance( );
4)      Variable names also follow the above rules.
EX: - age, empName, employee_Net_Sal;
5)      Constants should be written using all capital letters.
EX: - PI, MAX-VALUE, Font.BOLD;
Here Font is a class, BOLD is a constant.
6)      All key words should be written in all small letters.
EX: - public, static, void, main etc…


Special Characters:-
  Charecter                                                                     Meaning
                \n                                                                       next line
                \t                                                                             tab
                \v                                                                              enter
                \b                                                                       back space
                \\                                                                                \
                \”                                                                               
                \’                                                                            


Monday, 18 February 2013

Packages in java



1)        java.lang: - This package got primary classes and interfaces essential for java program. It consists of wrapper classes, strings, threads, etc. wrapper classes are useful to create an object. Thread means process.
à java.lang package by default import in to every java  program.

2)        java.util: - (utility) in this util data structures are available. This package contains useful classes and interfaces like stack, linked list, hash table, arrays. etc.
3)        java.io: - This package handles files and input output related tasks. (io – input output).
4)        java.awt : - abstract window tool kit.
        This package helps to develop GUI. It consists of important sub packages.
Java.awt.event à event is useful to providing actions.
GUIà graphics user interface.
5)        javax.swing: - This package helps to develop GUI like java.awt.  X means extended.  This package is developed from another package.
6)        java.net: - Client – server programming can be done using this package. Net stands for network.
7)        java.applet: - applets are programs which come from a server into a client and get executed on the client machine.  An applet is a program that comes to the internet server.
8)        java.sql: - structured query language.  This package helps to connect to database like oracle and utilize them in java.  A data base is a storage data.
à A variable is memory location to store data.  Int represent you can store integer numbers. Numbers are without decimal points. It is a data type.

Access Specifiers in Java


Access Specifiers:-
 Access specifier is a key word that specifies how to access or read the member of a class or the class itself.
There are 4 access specifiers.
1)      Private: - private members are not available outside the class.
2)      Public: - public members are available anywhere outside the class.
3)      Default: -Default members are available outside the class.
Note: - If the user does not use any access specifier then java compiler uses default specifier.
4)      Protected: - protected members are available in class and sub class.
                           
 Private can not be used before the class name. In type1 initialization, if the instance variables are declared as private, they are not available to other classes.