Post on 19-May-2015
description
OVERVIEW OF
LANGUAGE
Contents
• Introduction
• Simple Java Program
• More of Java
• An application With Two classes
Introduction
• JAVA is a general purpose object oriented language.
• We can develop two types of JAVA programs:-
• Stand-alone Application:- these are java programs that are used to carry out a certain task at a stand- alone local computer.
• Web Applets:- Web applets are the small java programs used to develop web applications.
Introduction continue..
• Executing a Stand- alone application involve two
steps
• Compile the source code into byte code(javac compiler).
• Executing the byte code program(java interpreter).
• Executing a Web Applets also involve two steps
• Compile the source code into byte code(javac compiler).
• Executing the byte code with java enabled browser.
Simple Java Program
• Let us look at a simple code that would print the words Hello World.
public class MyFirstJavaProgram
{
/* This is my first java program.
This will print 'Hello World' as the output */
public static void main(String []args)
{
System.out.println("Hello World");//prints Hello World
}
}
Simple Java Program
• Let us look at a simple code that would print the words Hello World.
public class MyFirstJavaProgram Class Declaration
{
/* This is my first java program.
This will print 'Hello World' as the output */
public static void main(String []args)
{
System.out.println("Hello World");//prints Hello World
}
}
Simple Java Program
• Let us look at a simple code that would print the words Hello World.
public class MyFirstJavaProgram Class Declaration
{ Opening Brace
/* This is my first java program.
This will print 'Hello World' as the output */
public static void main(String []args)
{
System.out.println("HelloWorld");//prints HelloWorld
}
}
Simple Java Program
• Let us look at a simple code that would print the words Hello World.
public class MyFirstJavaProgram Class Declaration
{ Opening Brace
/* This is my first java program.
This will print 'Hello World' as the output */
public static void main(String []args) the main line
{
System.out.println("HelloWorld");//prints HelloWorld
}
}
Simple Java Program
• Let us look at a simple code that would print the words Hello World.
public class MyFirstJavaProgram Class Declaration
{ Opening Brace
/* This is my first java program.
This will print 'Hello World' as the output */
public static void main(String []args) the main line
{
System.out.println("HelloWorld");//prints HelloWorld output line
}
}
More of java
import java.lang.Math;
public class Exercise
{
public static void main(String[] args)
{
double x = 16;
double y;
y= Math.sqrt(x);
System.out.println("The square root of " +y);
}
}
More of java
import java.lang.Math;
public class Exercise
{
public static void main(String[] args)
{
double x = 16;
double y;
y= Math.sqrt(x); math function
System.out.println("The square root of " +y);
}
}
An application With Two classesclass Room{
float length;float breadth;void getdata(float a, float b){
length= a;breadth= b;
}}
Continue..
class RoomArea
{
public static void main(String args[])
{
float area;
Room room1= new Room (); //creates an object room1
room1.getdata(14,10);//assign value to length and breadth
area = room1.length * room1.breadth;
System.out.println(“Area =”+area);
}
}