Sei sulla pagina 1di 28

Programming is coding, modeling, simulating or presenting the solution to a problem, by representing facts, data or information using pre-defined rules

and semantics, on a computer or any other device for automation. Java is both a programming language and a platform. Like any other programming language, we can use Java to write or create various types of computer applications. Thus, Java fits the definition of a programming language.

1991 1993 1995 1996 1997

James Gosling develops Oak language for programming intelligent consumer electronic devices.

World Wide Web explodes Java formally announced. Java Development Kit (JDK) 1.0 ships. JDK 1.1 launched. Java Servlet API released. 1998 JDK 1.3 launched. 1998 Sun announces a JDK 1.2 for linux. 1999-2000 JDK 1.3 released. J2EE, J2SE, J2ME appear. 2002 Java support for Web services officially released via the JavaTM Web services Developer Pack.

2004
2006

Java 2 Platform, Standard Edition 5 is released.


The NetBeans IDE (Integrated Development Environment) 5.0 is released.

BlueJ is an Integrated Development Environment for the Java programming language, developed mainly for educational purposes, but also suitable for small-scale software development

JAVA COMPILER
(translator)

JAVA BYTE CODE


(same for all platforms)

JAVA INTERPRETER
(one for each different system)

Windows XP

Macintosh

Solaris

Windows 7

CHARACTERISTICS OF JAVA
Write Once Run Anywhere (WORA) Light Weight Code Security Built-in Graphics Object-oriented language Supports multimedia Platform Independent Open Product.

An object can be thought of as an entity having a specific identity, specific characteristics and specific behavior. Examples of real world objects are orange, table, chair, fan, book etc.

Data Abstraction refers to the act of representing essential features without including the background details and explanations. To understand abstraction, let us take one example of Switch Board. You only press certain switches according to your requirement. What is happening inside, how it is happening etc. you neednt know. This is abstraction; you know only the essential things to operate on switch board without knowing the background details and explanations.

The wrapping up of data and functions (that operate on that data) into a single unit (called class) is known as encapsulation.

A method is an operation associated to an object. The behavior of an object is represented through associated functions, which are called methods.

A class represents a set of objects that share common characteristics and behavior. In object oriented programming, objects are defined by defining a class for them.

The class is an object factory. It contains all the statements needed to create an object, its attributes, as well as the statements to describe the operations that the object will be able to perform.

A class represents a set of objects that share common characteristics and behaviour. In object oriented programming, objects are defined by defining a class for them. For e.g., parrot is a class, but a parrot namely, Mithu residing with Sharmas, is an object of parrot class type. Same way, Human beings is a class and you (your specific name) are one object of this class type.

Basically the class is an object maker or object factory. It contains all the statements needed to create an object, its attributes, as well as the statements to describe the operations that the object will be able to perform. By utilizing this and by providing initial values depicting an objects state, new objects can be created from the class as and when required. For example, for a student, there can be many classes represent various abstractions e.g., there would a separate class for result tracking system, a separate class for extracurricular activities, and so on.

When a class is defined, we can create as many objects as needed. All these objects materialize the abstraction represented by the class. These objects are called instances of this class. All the instances created with a given class will have the same structure and behaviour. They will only differ regarding their state.

Keywords are the words that convey a special meaning to the language compiler. These are reserved for special purpose and must not be used as normal identifier names. Some examples are : if, else, char, break, private, public, for, goto, while, float etc.

Identifiers are fundamental building blocks of a program and are used as the general terminology for the names given to different parts of the program i.e. variables, objects, classes, functions, arrays etc. Some examples of identifiers are : Myfile, MYFILE, A_to_Z, FILE13, _NAME

Literals (i.e. constants) are data items that are fixed data values. Java allows six kinds of literals: Integer-literal Floating-literal Boolean literals Character literal String-literal the null literal

Java allows us to have certain non graphic characters in character constants. Non graphic characters are those characters that cannot be typed directly from the keyboard e.g. backspace, tabs, carriage return etc. These nongraphic characters can be represented by using escape sequences where an escape sequence is represented by a backslash ( \ ) followed by one or more characters. Some escape sequences allowed in Java are given below :

An operator is a symbol or letter which causes the compiler to take an action and yield a value. The operations being carried out are represented by operators. An operator acts on different data items/entities called Operands. Examples of Unary Operators are:-

Unary Operator(+) Unary Operator(-) Addition Operator(+) Subtraction Operator(-) Multiplication Operator(*) Division Operator(/) Modulus Operator(%)

Java provides ++ and -- operators. These operators are called increment and decrement operators. The increment operator ++ adds 1 to its operand. ++ x means x + 1 x ++ means x + 1 - - x means x 1 x - - means x 1

These operators exist in 2 types Prefix Postfix


Prefix means before its operand. For example ++ x --x Postfix means after its operand. For example x ++ x--

UNARY ARITHMETIC OPERATORS Operators that act on one operand are referred to as Unary Operands. It may be + or -. Unary + The operator unary + must have arithmetic type and the result comes in the value. If x = 10 then + x means 10 If x = -10 then + x means 10 Unary The operator unary (minus) must have arithmetic type and the result comes in negative. If x = 10 then x means 10 If x = 10 then x means 10

Operators that acts upon two operands are referred to as Binary Operators. It may be +, -, *, /, %. Operation Addition Subtraction Multiplication Division Operators Meaning Symbol + * / Addition or Plus Subtraction or Minus Multiplication Slash of Division Example A+B AB A*B A/B

Remainder

Modulus Remainder

or A % B

WAP Program to display a Hello World and Welcome to Java programming message in different lines. public class HelloWorld { void main( ) { System.out.println("Hello World"); System.out.print("Welcome to Java Programming"); } }

WAP to accept two numbers from user and display their sum, difference, product, quotient and remainder. public class Operator { void main(int a,int b) { System.out.println("Sum of "+a+" and "+b+" is : "+(a+b); System.out.println("Difference of "+a+" and "+b+" is : "+ (a-b); System.out.println("Product of "+a+" and "+b+" is : "+a*b); System.out.println("Quotient of "+a+" and "+b+" is : "+a/b); System.out.println("Remainder of "+a+" and "+b+" is : (a%b); } }

WAP to accept the name, basic salary, HRA and DA of an employee and calculate and display the net salary of the employee public class Salary { void main(String name,int bs,int hra,int da) { int ns; ns = bs + hra + da; System.out.println("Basic Salary : "+bs+"\nHRA : "+hra+"\nDA : "+da); System.out.println("The Net Salary of "+name+" is : "+ns); } }

WAP to display the area and perimeter of a rectangle. public class Rectangle { void main(int len,int br) { int area,peri; area=len*br; peri=2*(len+br); System.out.println("Length of rectangle is : "+len); System.out.println("Breadth of rectangle is : "+br); System.out.println("Area of rectangle is : "+area); System.out.println("Perimeter of rectangle is : "+peri); } }

WAP to display the area and circumference of a circle public class Circle { void main(double rad) { double pi,area,cmf; pi=(double)22/7; area=pi*rad*rad; cmf=2*pi*rad; System.out.println("Radius of circle is : "+rad); System.out.println("Area of circle is : "+area); System.out.println("Circumference of circle is : "+cmf); } }

WAP to accept temperature in Fahrenheit and convert it into Celsius public class Temperature { void main(double F) { double C; C=(F-32)/1.8; System.out.println("Temperature in Fahrenheit : "+F); System.out.println("Temperature in Celsius : "+C); } }

MADE BY :ADITYA SANGHI IX-B

Potrebbero piacerti anche