Wikipedia

Search results

Monday, 21 October 2013

Java Concepts

 java important to selenium because it is a platform language.

Java is guaranteed to be Write Once, Run Anywhere.

Java is:
  • Object Oriented: In Java, everything is an Object. Java can be easily extended since it is based on the Object model.
  • Platform independent: Unlike many other programming languages including C and C++, when Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the web and interpreted by virtual Machine (JVM) on whichever platform it is being run.
  • Simple:Java is designed to be easy to learn. If you understand the basic concept of OOP Java would be easy to master.
  • Secure: With Java's secure feature it enables to develop virus-free, tamper-free systems. Authentication techniques are based on public-key encryption
  • Robust:Java makes an effort to eliminate error prone situations by emphasizing mainly on compile time error checking and runtime checking.
  • Multithreaded: With Java's multithreaded feature it is possible to write programs that can do many tasks simultaneously. This design feature allows developers to construct smoothly running interactive applications.
  • Interpreted:Java byte code is translated on the fly to native machine instructions and is not stored anywhere. The development process is more rapid and analytical since the linking is an incremental and light weight process.
  • High Performance: With the use of Just-In-Time compilers, Java enables high performance.
  • Distributed:Java is designed for the distributed environment of the internet.
  • Dynamic: Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time.

    Simple Java Program

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

    //
     System.out.println helps to output will be printed in the next line.
     
 Java Basics:

In Java program it can be defined as a collection of objects that communicate via invoking each others methods. Lets look into what is Class,Object,Methods and instance variables.

  • Object - Objects have states and behaviors . An object is an instance of a class.
  • Class - A class can be defined as a template/ blue print that describes the behaviors/states that object of its type support.
  • Methods/Functions - A method is basically a behavior. A class can contain many methods. It is in methods where the logic's are written, data is manipulated and all the actions are executed.
  • Instance Variables - Each object has its unique set of instance variables. An object's state is created by the values assigned to these instance variables.

    Java Data Types:

    Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.
     
    Based on the data type of a variable, the operating system allocates memory and decides what can be stored in the reserved memory. Therefore, by assigning different data types to variables, you can store integers, decimals, or characters in these variables.

    Let us now look into detail about the  primitive data types.

    1)int:
    Int data type is a 32-bit signed two's complement integer.
     Ex:int i = 100;
    The default value is 0.
    2) Long:
    Long data type is a 64-bit signed two's complement integer. 
    Ex: long x = 100000L
    Default value is 0L.
    3)double:
    double data type is a double-precision 64-bit
    This data type is generally used as the default data type for decimal values  and integers
    Ex:double d = 154.1
    4)Char:
     char data type is a single 16-bit Unicode character.
    Char data type is used to store any character
    Ex: char C ='b';
    5)boolean:
    There are only two possible values: true and false. 
    Default value is false.
    specially used in If statement
    Ex:boolean = false;
    5)String:
     Ex:String str = "I am writing java program";

     
      Next post we will Discuss about String Class

No comments:

Post a Comment