Java Language Basics

Views:
 
Category: Education
     
 

Presentation Description

A presentation for some basics of core java.

Comments

Presentation Transcript

The JAVA Language Basics: 

The JAVA Language Basics By : Arpit Porwal

Introduction: 

Introduction Developed By : James Gosling Owner : Sun Microsystems Released in : 1995 Stable Release : Java Standard Edition 7 (1.7.0) (July 28, 2011; 3 months ago) OS : Cross Platform (Multi Platform) Extensions : .java, .class, .jar

Features: 

Features Simple Secure Portable Object-oriented Robust Multithreaded

Versions of JAVA: 

Versions of JAVA Major release versions of Java, along with their release dates: JDK 1.0 (January 23, 1996) JDK 1.1 (February 19, 1997) J2SE 1.2 (December 8, 1998) J2SE 1.3 (May 8, 2000) J2SE 1.4 (February 6, 2002) J2SE 5.0 (September 30, 2004) Java SE 6 (December 11, 2006) Java SE 7 (July 28, 2011)

JAVA Platform: 

JAVA Platform It is Platform Independent. It compiles Java language code in Java bytecode , not in Machine code. A major benefit of using bytecode is porting.

Bytecode: 

Bytecode A special machine language that can be understood by the Java Virtual Machine (JVM) Independent of any particular computer hardware, so any computer with a Java interpreter can execute the compiled Java program, no matter what type of computer the program was compiled on

Automatic Memory Management: 

Automatic Memory Management Java uses an automatic garbage collector to manage memory in the object lifecycle. Java does not support C/C++ style pointer arithmetic. Memory is not allocated to an object while it is created.

JAVA Syntax: 

JAVA Syntax Largely derrived from C++. An object-oriented structure. Primitive Datatypes which are not class for performance reasons. Unlike C++, Java does not supports operator overloading. Java uses similar commenting methods to C++.

Commenting Methods: 

Commenting Methods There are three different styles of comments: A single line style marked with two slashes (//). A multiple line style opened with /* and closed with */. The Javadoc commenting style opened with /** and closed with */.

A Simple JAVA Program: 

A Simple JAVA Program class Hello { public static void main(String args []) { System.out.println (“Hello World”); } }

Parts of the Program: 

Parts of the Program The program shown in previous slide is known as “Hello World Program”. It is the most simple program in which only one line is printed. It consist of some keywords which are described in next slides.

Phases of a Java Program: 

Phases of a Java Program The following figure describes the process of compiling and executing a Java program

Common parts of program: 

Common parts of program Public : Access Specifier Static : Access Modifier Void : Return Type String args [] : Command Line Arguments System : Class Out : Object of class “System” println : Function called by object “Out” Hello World : Group of characters known as String

Keyword : class: 

Keyword : class It is used to declare that a new class is being defined. “Hello” is an identifier that is the name of the class. The entire class definition, including all of its members, will be between the opening curly brace ({) and the closing curly brace (}).

Keyword : Public: 

Keyword : Public It is an access specifier . Allows the programmer to control the visibility of class members.

Keyword : Static: 

Keyword : Static It is an access modifier. Increases functionality of the function. It allows the function to be called in three ways.

Keyword : void: 

Keyword : void It is a return type. It tells the compiler that the function “main()” does not return a value.

Keyword : System: 

Keyword : System It is a pre-defined class in “ java.lang ” package. It provides access to the system. It deals directly with console and hardware.

Keyword : Out: 

Keyword : Out It is an object of “print stream” class defined in “System” class. It connects class “System” to the console .

Keyword : println(): 

Keyword : println () It is a method of “print stream” class. It is used for taking an output from the code or printing a string.

Some abbreviations: 

Some abbreviations JDK : JAVA Development Kit JVM : JAVA Virtual Machine JRE : JAVA Runtime Environment javac : JAVA Compiler

Virtual Machines: 

Virtual Machines JVM : JAVA Virtual Machine : Used to develop desktop applications KVM : Kilobyte Virtual Machine : Used to develop mobile applications CVM : Card Virtual Machine : Used to develop programs for electronic items DVM : Delwik Virtual Machine : Used to develop android applications

Points to be remembered: 

Points to be remembered Java programs need to be compiled only once. When a class is defined as public, class name and file name must be same. ”;” can be put anywhere before a new statement. Java does not support operator overloading. Operator “+” is by default overloaded in JAVA.