Saturday, August 11, 2012

0

Learn Java Chapter 1

  • Saturday, August 11, 2012
  • vinod
  • Share

  • Download java

    Java is a object oriented programming language developed by Sun Microsystem of USA in 1991.The goal is to make a simple language ,portable and reliable.Java team included existing programming features like C and C++ but they removed number of features of C and C++ that they consider aas source of problems and thus made java really simple,portable,reliable.Java has different milestone from90's.Java include many features their aim is to design a language which could offer solution to some of the problems encountered in modern programming.

    1. Dynamic and Extensible
    2. Perfomance
    3. Distributed
    4. secured
    5. Object-Oriented
    6. Compile and Interpreted
    7. Simple
    8. Multithreaded
    9. Intractive
    There are some features that differ from C and C++ let's look
    JAVA and C:
    • Java does not contain the data types struct and union
    • Java does not support explict pointer type
    • we cannot use #define,#include statements
    • Java add new operator such as instanceof and >>>
    • Java adds Break and Continue statement
    JAVA and C++:

    • Java does not have pointers
    • Java does not support operator overloading
    • Java does not have template classes
    • We cannot use #include statements
    • We have to use finalize()function instead of destructor
    Java is a object-oriented programming language.Java can develop 2 types of programs

    • Standalone
    • Web applets
    Stand alone are written in java to carry out certain task on a local computer.We can execute the program in 2 steps
    • Compling the bytecode using javac program name.java
    • Executing the bytecode program java program name
    Now we can write a simple program to print sharealltricks


    class Program1
    {
    public Static void main(String args[])
    {
    System.out.println("Sharealltricks"); // Display the string.
    }
    }


    NOTE:
    • Java is case sensitive
    • Class name and the file name should be same Here the file name should be given as Program1

    Class Declaration:

    Class Program1
    We must declare a class it is an object oriented language and hence all must be declare inside the class.
    Class definition begins with brace [{ ] and ends with a closing [}] in the case of c++ we use [;] semicolon

    Main Line:

    This is similar to main() function in c++ Every java program must include the main() method.This is the atarting point for the interpreter to begin the execution java can have more number of classes but it 1 of them should be a main.
    "public static void main(String args())"
    Finally the System.out.print it is the output statement this is similar to cout<sharealltricks statement


    Post a Comment

    Followers

    Subscribe