Page 14 - DCAP501_Modern Programming Tools and Techniques I
P. 14

Unit 1: Introduction to Java




               Interpretation

               At the command line on UNIX and DOS shell operating systems, the Java interpreter is invoked as
               follows:
               java ExampleProgram
               Running

               At the command line, you should see the output that is given within the System.out.println statement in
               the program.
                                     I am a simple program



                           Write a simple Java program to print “Java”.


               1.3   Keywords
               Keywords are predefined identifiers set aside by Java for a particular purpose. These keywords cannot
               be used as names for variables, classes, methods or as  identifiers or tokens. All  keywords must be
               written in lowercase letters. At present, there are fifty defined keywords in the Java language. Table 1.2
               gives a list of the Java keywords.

                                               Table 1.2: Keywords in Java

                  abstract      Continue         assert          default          Boolean

                  do            Double           byte            else             case
                  enum          Catch            extends         char             final
                  class         Finally          const           float            for
                  goto          If               implements      import           instanceof
                  int           Interface        long            native           new
                  package       Private          protected       public           return
                  short         Static           strictfp        super            switch
                  synchronized   This            throw           throws           transient
                  try           Void             volatile        break            while


               The keywords in Java have a predefined meaning and they perform distinct functions. Some of the
               keywords and their functions are listed below:
               1.   abstract:  This Java keyword is used for declaring a method without providing that method’s
                    implementation, in a method declaration.
               2.   assert: This Java keyword is used for making a condition’s assumed value explicit.
               3.   boolean: This Java keyword is used for relating to an expression or variable, which can have only
                    either a true or false value.







                                        LOVELY PROFESSIONAL UNIVERSITY                           7
   9   10   11   12   13   14   15   16   17   18   19