Monday, 12 September 2016

JAVA BLOG_4

DATATYEPES

------------------------------------------------------------

Program:

 class DataTypeDemo
{
    public static void main(String args[])
    {
        int i=1;
        char c='j';
        float f=0.2f;
        double d=1.2;
        long l=1233444;
        short s=12;
        boolean b=true;

        System.out.println("i:"+i);
        System.out.println("c:"+c);
        System.out.println("f:"+f);
        System.out.println("d:"+d);
        System.out.println("l:"+l);
        System.out.println("s:"+s);
        System.out.println("b:"+b);

    }
}

------------------------------------------------------------------------------------------------------

Output:

 i:1
c:j
f:0.2
d:1.2
l:1233444
s:12
b:true

 

JAVA BLOG_3

                          VARIABLES

          Variable is name of reserved area allocated in memory which memory is called as RAM . 

        Ex:: int data=1;//data is variable.

 

  • Types of Variables

    1)local variable

    2)Instance variable

    3)static variable

     

    Local Variable -:

                   A variable that is declared inside the method called local variable.

     

    Instance Variable -:

                       A variable that is declared inside the class but outside the method is called instance variable.It is not declared as static.

     

    Static Variable -:

                         A variable that is declared as static is called static variables.It cannot be local

     

     -------------------------------------------------------

    Program:

             class VariableDemo
             {
                    int a=1;
                    /*
                   (int a) is a not-static data member so it
                   gives Exception while excecuting the
                   Program.

                 so main method is a static method so 
                 only static data members can be 
                 initialized in main method.

                 if we want to execute instance non 
                 static data member then you have to 
                 create object for that not static member
                 then it will excecute successfully  
                  */

                 static int b=2;

                 public static void main(String args[])
                {
               VariableDemo n = new VariableDemo();
                     int c=3;
                     System.out.println("a:"+n.a);
                     System.out.println("b:"+b);
                     System.out.println("c:"+c);
                 }

         }

             

 

 

Saturday, 10 September 2016

JAVA BLOG_2

BLOG-2: 
            
Java Syntax Learning!
  Syntax:::

    class CLASS_NAME
    {
        public static void main(String args[])
        {
        //Execution of code.......
        }
    } 


  Learn  Syntax:::

                  Here,

                       class is a keyword for defining the classname.

                       CLASS_NAME is  a class's name which you   
                       want to set, but set appropriate classname 
                       related to your program so you can easily find it.

Main Method:: public static void main(String args[])

                     "public" means that main() can be called from 
                    anywhere.

                   "static" means that main() doesn't belong to a

                    specific object.

                    "void" means that main() returns no value.


                    "main" is the name of a function. main() is

                     special because it is the start of the program.

                    "String[]" means an array of String.


                    "args" is the name of the String[] (within the

                    body of main()). "args" is not special; you can
                    name it anything else and the program would
                    work the same.


EXECUTION:

                  Open Command Promp and write::

          To Compile :: javac CLASS_NAME.java
          To Run  :: java CLAS_NAME

Program::

AIM      ::::::::::::::::::Write Hello World in JAVA::::::::::::::::::::

INPUT-
---------------------------------------------------------------------------------

    class JavaDemo    {        public static void main(String args[])        {            System.out.println("Hello World");        }    }


---------------------------------------------------------------------------------
Explanation-

What is " System.out.println(); "?
                  
                               System is a class in the java.lang package. out is a static member of the   
                  System class, and is an instance of java.io.PrintStream .out is an object of the 
                  System class. println is a method of java.io.PrintStream . This method is
                  overloaded to print message to output destination, which is typically a console or file.

                  Firstly, compile the program of  (.java) file, It is converted into (.class) file
                  by compiler. Then run (.class) file and your code will be generated 
                  successfully. If (.class) file is not created then check the Exception of the program
                  and solve it and compile again.

---------------------------------------------------------------------------------------------------------------------------       
OUTPUT-

                         javac JavaDemo.java
                         java JavaDemo

                         Hello World 
 -----------------------------***************************************--------------------------------                 

JAVA BLOG_1






Let's Start an Awesome language Called "Java"!

           In this blogs by blog you can learn Java Easily with Deep Theory and Examples and another Topic related Programs so you can easily understand what the topic Means.......

 

Blog-1:::DEFINATIONS OF JAVA

               What is Java?

                         Java is a programming Language which is developed by
               Sun-Microystem in 1995.

                         Java is a Programming Language and a platform for building
               different types of applications and websites.

                         Java is a high level,robust,secured and object-oriented Programming
               language.

                  Simply,"JAVA IS A PROGRAMMING LANGUAGE AND PLATFORM 
             FOR BUILDING WEBSITES AND APPLICATIONS".

             What is Platform?

                 Any hardware or software environment in which a program 
               runs, is known as a platform. Since Java has its own runtime environment
              (JRE) and API, it is called platform.

               What is JVM?

                       A Java virtual machine (JVM) is an abstract computing machine that
             enables a computer to run a Java program. There are three notions of the  
           JVM: specification, implementation and instance.
                    The specification is a document that formally describes what is required
            of a JVM implementation.

                     What is JDK? 
                  The Java Development Kit (JDK) is a software development environment
           used for developing Java applications and applets. It includes the Java Runtime 
         Environment (JRE), an interpreter/loader (java), a compiler (javac), an archiver (jar),
         a documentation generator (javadoc) and other tools needed in Java development.

 
              What is JRE?
                 
                       The Java Runtime Environment (JRE) is a set of software tools for
              development of Java applications. It combines the Java Virtual Machine (JVM),
             platform core classes and supporting libraries. JRE is part of the Java Development
             Kit (JDK), but can be downloaded separately.


                    What is Interpreter in JAVA?
                 A Java interpreter executes lines of byte code as commands to be executed. 
              The byte code is executed. The JVM takes the byte code and generates machine code.
              The byte code is compiled to machine code, and the machine code is executed.

 
             What is archiver (Jar) in JAVA?
                 File archive, data compression. Extended from. ZIP. In software, 
            JAR (Java Archive) is a package file format typically used to aggregate many Java
          class files and associated metadata and resources (text, images, etc.) into one file to
          distribute application software or libraries on the Java platform.    


             What is JAVADOC in java?
               Javadoc is a documentation generator created by Sun Microsystems for the
             Java language (now owned by Oracle Corporation) for generating API documentation
             in HTML format from Java source code.  


           How this all Actually Works?




                            firstly java source code is converted into Bytecode file by the translator 
                 named  “Compiler”. 
                          The byte code file gets name with .class extension and javac (java compiler) 
                is the tool to compile the .java file.
                Then,
                        java is a tool use to invoke Java Interpreter “JVM”. Now, the work of JVM starts.     

          When JVM invoke,

                      1. a subprogram in JVM called Class loader (or system class loader) starts and 
               load the bytecode into OS memory( or RAM).

                     2. another subprogram Bytecode Verifier verify and ensure that the code do not 
               violate the security rules. That’s why the java program is much secured and virus free.

                    3. Then last subprogram Execution Engine finally converts bytecodes into 
             machine  code. The name of that engine are in use today is JIT Just In Compiler.


-------------------------------********************************---------------------------------------------