You are on page 1of 13

Chapter -2

WORKING WITH BASICS

By:A.J.Patankar
Features of Java
Compiled and Interpreted
Platform Independent and Portable
Object Oriented
Robust and Secure
Distributed
Dynamic and Extensible
Scalability and Performance
Supplementary Character Support.
How Java differs from C++
Java does not support Operator Overloading
Java doesn’t have template classes
Java doesn’t support multiple Inheritance.
Java doesn't support global variables
Java doesn’t use Pointers
Destructor function is replaced by finalize()
No header files in Java
Java Environment
JDK comes with a collection of tools that are used for
developing and running java programs includes

Applet Viewer
javac (Java Compiler)
Java (Java Interpreter)
Javap(Java disassembler)
Javah (for C header files)
javadoc
Jdb (Java debugger)
Process of Building and Running Java
Application Program
Text Editor

Java Source Code

javac

Java class file

java

Java Program o/p


Application Programming Interface
Java Standard Library (API) includes many
classes and methods grouped together in to
functional packages
Language Support Package
Utility Package
Input/Output Package.
Networking Package
AWT Package
Applet Package
Overview of Java
Java is general purpose programming
language we can develop 2 types of java
programs:

Standard Java Application.


Web Applet.
Java Virtual Machine (JVM)
All language Compilers translate source
code into machine code.
Java Compiler (JVM) Produces an
Intermediate code known as a bytecode.
This Byte code can be executed on any
machine or any OS to get desired output.
Java Compiler Bytecode
Java Program
(JVM)

Bytecode Java Interpreter Machine Code


Simple Java Program
File: HelloWorld.java

class HelloWorld
{
public static void main (String args[ ])
{
System.out.println(“Hello World!!”);
}
}
Simple Java Program
public static void main (String args[ ]) :
public: Access Specifier defines main as
public type. (Unprotected).
Static: Method belongs to the entire class

and not a part of any object.


void: main method does not return any
value.
String args[ ]:Accept Command line
arguments of String type.
Simple Java Program
System.out.println(“Hello World!!”);:
This sentence is similar to printf() statement in C
and cout<< construct of C++
Every method in Java must be part of an object
println method is member of out object
Which is in static data member of System class
Which prints string Hello World!!.
Simple Java Program
// File: RoomArea.java
class Room
{
float length;
float breadth;
void getdata(float a ,float b)
{
length=a; breadth=b;
}
}
Class RoomArea
{
public static void main (String args[ ])
{
float area;
Room r1=new Room();
r1.getdata(14,10)
area=r1.length*r1.breadth;
System.out.println(“Area=“+area);
}
}
Simple Java Program
1. Write a program in java to display nos. 1 to
50 with some Text message.

2. Write a program in Java to display nos.


divisible by 4.

3. Write program in Java to display fibbonacci


series.

You might also like