CORE JAVA

   Language:
         It is the Mediator. Without language we cannot communicate with others.

         There are 2 types of languages.
                            Natural language
                            Programming language

 Natural language:
         If u want to establish the communication between 2 humans

 Programming language:
        If u want to establish the communication between human and system
               E.g.: c, c++, java, .net

        Smallest word of the statement is called token
        Collection of tokens is called statement
        Collection of statements is called program
        Collection of programs is called software

 Note: each programming language follows syntax and semantics rules

 Each program has tokens :- They are keywords, identifier, operators, values/constants, and    separators
==========================================================================================
 IDENTIFIER:   A name of Class,variable,method and labels  is called an identifier. 

 Rules for constructing identifier:
   a. Identifier must starts with either  alphabets(a-z,A-Z) or  _  (underscore) or  $
   b. From 2nd character onwards either alphabets or _ or $ or digits(0-9)
   c. don't take any keyword as identifier.
   d. Identifier  doesn't   allow   any special characters.

    Ex:  Total(valid)                total123(valid)            123total(invalid)                _total (valid)
             Total#(invalid)             total_number(valid)             total-number(invalid

=========================================================================================
 RESERVED WORDS:
     53 reserved words are there in java 
     50 are keywords 
    3 reserved literals(true,false,null)

 Keywords for Primitive Datatypes: 8
      byte                            short                          int                               long
      float                            double                      char                            boolean
  Keywords for flow control: 11
      if                      else                switch                 case                  default                       for
     do                   while              break                   continue          return
   Keywords for Modifiers: 11
     private              protected            public                  static                       abstract                            final               volatile              transient                  native                  strictfp(jdk1.2)                         synchronized 
   Class related keywords: 6
      class                  interface               package             extends                implements                     import
    Object related keywords:4
      new                instanceof                super             this
    Keywords for Exception Handling: 6
    try             catch                 finally               throw            throws                       assert(jdk 1.4)
   Method related keywords: 1
     void

   Unused keywords:2
    const                         goto
    New keyword in jse 1.5(version): 1
     enum
    Reserved Literals: 3
     true                     false                 null

==========================================================================================
  JAVA VERSIONS:
   No. of Version                                  code name
   --------------------------------------------------------------
   Jdk 1.0/sdk 1.0                                   oak
   Jdk 1.1                                                ---------
  J2SE1.2                                               playground
  J2SE 1.3                                             kestrel
  J2SE 1.4                                             Merlyn
  JSE5                                                     Tiger
  JSE6                                                    Mustang
  JSE7                                                    Dolphin
============================================================================================
                                                                     JAVA
                                                                         |
                                                                         |
                  -------------------------------------------------------------------------------------------------------
                  |                                                        |                                                                      |
                  |                                                        |                                                                      |
               JSE                                                JEE                                                                JME

============================================================================================
    JAVA FEATURES 
   -----------------------------
    1. Simple
    2. Object oriented
    3.Platform Independent
   4.Portable
   5.Architecture neutral
   6.Multi-Threading
   7.Robust
   8.Compiler and Interpreter
    9.N/w based
   10. Dynamic
   11.Distributed
   12.Secured

  OOP LANGUAGE
  ------------------------
        Object based language and object oriented language difference

        Q.  What are conditions to call one language is pure  oop's?
         A).     1. Encapsulation
                   2. Abstraction
                   3. Polymorphism
                   4. Inheritance
                   5. All predefined types are objects (java not support)
                   6. All operations are performed by sending messages to objects
                   7. All user defined type’s objects
                   Ex:ruby,small talk,Eiffel

        Q.  What is difference between loosely and strongly typed coupled languages?
       A)  C,c++,java,.net this are strongly typed languages because before uses of variable it's type.Declaration is very important without type declaration we cannot able use that variable    more over it can be supporting related values only  JavaScript is loosely typed language the variable declaration is not compulsory and it can  be able to handle any type of values
            Var a;
             a=10;
             document.write (a);
             a="cherry";
========================================================================================
    Data Types:
         Java having 2 types of data types: they are
               1.    Primitive data type
               2.   Reference data type

       PRIMITIVE TYPES:
         Java having 8 primitive data types.  They are
            Numeric DataTypes:  byte   short    int  long
            Floating Point DataTypes:   float   double                             
            Non-Numeric DataTypes:     char   boolean(for logical values)
==========================================================================================
      byte :
         Size:      8 bits or 1byte
         Range:  -128 to 127
         This datatype is the best suitable if you are handling data of streams from a file or network
         byte b=100;   //valid
         byte b=200;   //invalid
         Compile time errorpossible loss of precision
     Found:int                             
                                        Required: byte          
            
 =========================================================================================    
      short :
         Size:       16 bits or 2bytes
         Range:    -2^15 to 2^15-1    i.e. -32768 to 32767
           This data type is very rarely used types in java but best suitable for 16 bit processors.
========================================================================================
       int :
        Size:           -32 bits or 4 bytes
        Range:       -2^31 to 2^31-1 or -2147483648 to +2147483647
           In C language the size of int is varied from platform to platform.
          The C program worrest  for 32 bit processor cannot run on 16 bit processor. Hence the      chance of failing of c program is very high of we change platform.As a result C is not considered as Robust Language But in the case of java the size of any data type is fixed for any platform,hence the chance of failing the java program very less As a result java is  considered as robust language
========================================================================================
      long :
        Size:           64 bits or 8 bytes
        Range:       -2^63 to +2^63-1
         If int is not enough for to hold big values like amount of distance traveled by light in 1000      days we should for long data type

========================================================================================
  Floating point data type:
    float size:                  4 byte or 32 bits
    float range:              -3.4 e 38 to 3.4 e 38
    double size:             8 bytes or 64 bits
    double range:         -1.7 e 308 to 1.7 e 308
              These datatypes are representing for real numbers.For 6-7 decimal places of accuracy we should go for float data type so this less accuracy.For 14-15 decimal places of accuracy we   should go for double datatype so this is more accuracy.float is single precision where as   double is double precision
========================================================================================
      boolean :
         The size of the boolean is not applicable (It purely depends on the underlying JVM)
         Range: not applicable(But allowed values are true or false)
         TRUE or FALSE are not violation leads
         CTE: cannot resolve the symbol
==========================================================================================
       char :
       Size:       2 bytes
       This is provide il8n. Providing Unicode’s for all the worldwide character sets(range 0 to 65535)

 =========================================================================================
      Reference Data type:
                   We can take the any user define class or predefined class as data type
                   The default value for reference data type is null
============================================================================================
          class:
       class is a template, it contains variables and methods
        it is just a imagination so class does not exist physically
                                                         By using class keyword we can define classes in java

            Syntax:
                         class    <class name (identifier)>
                            {
                                Variables;
                                Methods;
                              }
             Example: 
                           class    Student     //Student  is  class name
                             {
                                    int     sno;       // sno , name are variables 
                                   String   name;
                                    public  void  read() //  read() is method name
                                    {
                                         System.out.println("Student is Reading");
                                      } // method close
                                }  //  class  close
=========================================================================================
             Object:
       u The instance of the class is called object
      u     Each object contains state (instance variables), Behavior (methods),  Reference (name)
                           u        By using new keyword we can create the objects in java

               Syntax:
                       Classname         object name  = new     Classname();

               Example :
                     Student     s1= new   Student();   //  here  " s1"  object name  and   Student     is  classname
==========================================================================================
         JVM ARCHITECTURE :



=======================================================================================





No comments:

Post a Comment