You are on page 1of 4

*History of java:-the sun microsystem engineers, patric and james designed a project named gree project.

They designed a portable language that was small in nature, with low memory requirements & could be used to generate intermediate code and can interpret the converted code to machine language. They devolped a language with these features, was initially called the oak, which was based on the C++. Letter in 1995 the language was added with oops features and renamed as java *Features of java:- (1)Compiled and interpreted:-it is both compiler and interpreter.compiler translate the source code into compiled format or byte code. These instruction can be executed by using the JVM on any sys irrespective of hardware and OS.(2)Platform-independent and portable:- portability is another feature of the java. It can be easily transferred from one comp, to another and can be executed anywhere and anytime. i.r.o OS.(3)Oo approach:- java is and OO language that supports various OOProgramming features such as polymorphism, data abstraction,and inheritance, it enables the user to store the program code and data in the form objecs and classed.(4)Robust and Secure:- Exception handling , which detects the errors and exceptions and reduces the possibility of run time errors is supported feature of the java. It also supports the feature of garbage collection. It ensures that the downloaded applet is vireus-free.(5)Simple and distribute:- the java language is near to the C++ and C. As the suntex of the java is similar to that. Java is easy to learn for the C++ and c users.it does not supports the feature of pointers,inheritance, as it increases the complexity of the program. (6)Small and Familiar:- oops concept of inheritance allowa the programmers and developers to re-use the per defined classes and objects in the programming code. Reusability of the code inthe programs makes programming simple and easier.(7)Multi treaded and interactive :- it allows the user to simultaneously perform multiple taskes. Multi threading allow to start multiple tasks that execute on different threads. Use o multimedia in java makes the application even more interesting. (8)High performance:- as the programs are first converted into bytecode and which are easily translated in to machine language enables the developer to create high performance application.fast execution at low memory. *JVM:- the JVM hides the details of implementation between the hardware requirements and OS which plays an important role in making the java language portable and independent platform. It provides the compatibility between the compiled java program and the sys, where the program is executed. java programs are compiled into class files using the executable file, javac. A java compiler generated the byte code and and loads it in JVM using the jvm class loaders. The jvm class loaders load the class files and execute a java program on any OS such as unix system. *Java Objects:- (1)Encapsulation:- the wrapping of the data and methods into a single entity is termed as encapsulation. The data is accessed only by the method which are encapsulated in the class. Encapsulation provide an interface between the data objects and the java program. (2)Inheritance:- provides a mechanism to acquire properties of one object of a class from the objects of another class. inheritance provides reusability of codes in the programs as it allows user to add additional features to an existing class without changing the class. The class that inherits the instance variables and methods from another class is termed as the sub class. (3)Polymorphism:- the polymorphism technique allows the java compiler to convert the variable of integer type in to floating point value.it allows the operators and function to be used in the different forms depending up on the parameters and operands. (4)Dynamic binding:-in the dynamic binding the code that will be executed in response to a method call is determined at runtime. There may be two or more function with the same name in the class but the function that will be executed is determined using the number and type of parameters and the value each function returns. (5)Msg passing:- the java objects communicate with each other using the feature of massage passing.in the feature one obj sends a msg and some information to another obj. The msg is the mane of a method in the masgrecieving obj and information is the value passed as parameter to that obj.also called sending obj. *The java enviorment:- Java development kit:-java tools include java compiler, interpreter, disassemble and debugger. JRE is a software that is used to execute the java program.it contails the following tools to run and execute java programs: Java devolpment kit:-Javac is a java compiler that translate the java source code to java class files.(2)Applet viewer allows user to run java applets(3)it is a interpreter that executes various application and applets by interpreting the byte codes fles.(4)javah is used for including the header files in a java program(5) javap acts as a disassembler and is used to convert bytecode files in to program.(6)javadoc creates documentation of the java source code files in the htmlformat.(7)jdb is a java debugger that located errors in a java program. Java standard library:- it includes a standard library which is one of the most attractive features of the java as it contains various classes to support all the major functions of java.(1)language supports classes which support adv features in java.(2)utility classes that are used for various functions(3)input and output classes which are used to read data from various in put devices and to create data on various output devices.(4)networking classes which

allow communication between different computers over a network(5)applet that allows user to download and jun java programs on a clint browser(6)abstract window toolkit that is used for creating platform independent GUI applications. *Applets:-it is a java program that is compiled on one computer and can be run on other computers through java enabled web browser or applet viewer. Applets brings live contents such as news, animation or scorecard o the static web pages that can be loaded from the internet.these are secure(1) they never run any local executable program.(2)they cannot communicate with any other ost but te originating hose(3)can not get any information about the local computer.(the local computer acts as a client and the remote computer acts as a server which are inter connected through the internet. Local applet:-the applet developed and stored on the same computer is called a local applet. Remote.applet:- the applet which is developed and stored on one computer and run on remote computer over the internet is called a remote applet. Applets Application Don not use the main () method for initiating the Use the main () method for the initiating the execution of the code execution of the code. Cannot communicate with other server on the network Communicated with other server on the network Run from inside a web page using html tags Run independently Do not use libraries from other languages such as c or Use libraries from other languages c++ Con not un any program from the local computer Can run a program from the local computer *Life cycle of an applet:-there are four states in the lifecycle of an applet-(init(), start(), stop(),destroy(),)new born, funning, idle, and dead. The newborn sate consists of a newly loaded applet that is initialising its resources. in the running state an applet is being executed and it is displays the text or image that applet contains. it is said to be in idle state or stop when is initialised but not currently in the running state. when the destroy method is invoked the applet acquires a dead state and releases all the resources. *Exception handling code syntax:- java has five keywords for exception handling:-try,catch,throw, throws and finally.the keyword try creates the try block, which is used for monitoring java statements that might throw and exception . the catch block follows the try block and handles the exceptions thrown in the try block. The throw keyword is used to generate a built-in or user defined exception . the throws keyword is used along with java methods to check whether the methods have exception that are listed along with the throw key word. the finally block contains java statements that run when an exception is thrown or not thrown. Using finally statement:-it is used to create a finally block that are run in both cases, when an exception is thrown and also when an exception is not thrown.the finally block contains the java code statement that need to be run after a try block. The syntax is as follows: Try {/*statement to be monitored */} Catch(exception e) {/*exception handler */} Finally {/* mandatory code statement */} *Exceptions:- an exception is a condition that is caused by a run time errors in the program, when the java interpreter encounters an error such as dividing an integer by zero, it created an exception object and throws it .if the exception obj is not caught and handled properly, it will display an error. We should try to catch the exception object thrown by the error condition and the display an appropriate message for taking corrective action this task is known as exception handling. (1)find the problame (Hit the exception)(2)inform that an error has occurred(throw the exception)(3)receive the error information(Catch)(4)take corrective action(Handle) Exception type Cause of exception Arithmetic exception Caused by math errors, such as division by 0 Array index out of bounds Caused by bad array indexes Array store exc. Caused when program tries to store the wrong type of data I/O exc. Caused by general I/O failure Null pointer exc. Caused by referencing a null object Out of memory When there is not enough memory to allocate Security Caused when an applet tries to perform an action not allowed Stack over flow When system runs out of stack space String index out of bound When a program attempts to access a nonexistent character in a string

*The event delegation approach:- the event delegation model defines the standards and mechanisms to handle events in java. it is made up of three components(1)source helps generate an event(2)event describes the change in the source and is generated by the source(3)event listener receives and processes and event.------an event delegatin model facilitates to a listener to receive an event notification after registering with the source. Events are the objects in an event delegation model that are generated when the end user interacts with the AWT components, such as buttons, checkboxes and text fields.events are also generated from end user input through the keyboard and mouse.the internal state of an object can be changed by an event that is generated by source.the source also registers event listeners so that the events listeners can receive notification when an event generated. Event listeners implement methods, receive events and perform actions corresponding to events. *Java data base connectivity(JDBC):- it helps connect a relational data base to the java application regardless of where the application is running and where the database is stored.jdbc executes SQL statements and also call stored database procedures. One important feature of jdbcis location indipendance. Java programs with database access can be written and deployed as in application.jdbc consists of a high level this thin and multiple low level drivers for connection to different databases. There are four drivers defined by jdbc(1)type 1 drivers require an open data base connectivity driver for the data base to be installed. This type of driver works by translating the submitted queries into equivalent odbc queries and forwards hem via native api calls directly to the odbc drivers.(2)drivers are native api that uses a vendor specific driver or database api to interact with the database.(3)drivers are open protocol net drivers, which are not vendor specific and work by forwarding database requests to a remote database source sing a net server component. This type of driver can access any type of database.(4) drivers are proprietary protocol net drivers which have the same configuration as a type 3 but use a wire protocol specific to a particular vendor and hence can access only that venors database. *JDBC functions:- (1)establishes a database connection.(2)optional interrogates the database for capability subset.(3)optionally retrieves schema metadata information.(4)constructs an SQL statement object and sends queries or database tasks(5)executes the database tasks or process resultsets(6)closes the statement object and resultset(7)closes the connection. *JDBC/ODBC BRIDGE:- the bridge provides a platform for multiple database interaction because ODBC is a Microsoft standard product for communicating with databases. It provided accessibility to remote ODBC data source in the java application and applets on any jvm.jdbc api is responsible for transferring data between an application and database. *Client/ server architecture :-the client/server architecture is the most commonly used networking architecture . it consists of a server multiple clients and network resources such as printer and scanners. The clients can share the network resources using the server.the following are the types of servers:- (1)computer server enables the clients in the network to perform various computations. (2) print servers manage the collection of printers in a network(3)disk server provide network disk space that is shared by the clients of the network(4)web servers enables you to access the internet........ Client is a simple component that accesses the resources of the server. In a client/server architecture the client program requests information from the server. the server returns the requested information and also performs the requested action for the client. *URL:- uniform resource locator represents the address of a web page which enables you to find a resource on the internet. You can access a specific web site by typing its url in the address bar of the web browser. A url is represented as a string that explains the full location of the resource you are using on the internet. Components are:- file name, directory name, host name , access method. *Proxy server:- it acts as an interface between user computer and the web server while connecting to the internet.web browser such as internet explorer or google chrome for displaying web pages.the proxy server is responsible for responding to requests for web pages. The proxy server searches for the requested web page in its local cache. If the proxy server finds the requested web page then the requested page is displayed in ur browser. If it is unavailable the proxy server forwards the request to the web server for the requested page. proxy servers enables you to use services such as www, ftp, email .messaging and remote administration tools. *Adv of proxy server:- improves the response time while using internet by reducing the delay in accessing the resources.(2)enables you to restrict the access to certain web sites(3)protects the ip address of your computer by sending its own ip address for accessing the internet.(4)helps in acting as a fire wall for the network(5)protects the unauthorised access to the network(6) easy to implement and maintain. *Errors:-an error is a bug that interrupts the execution of a program. errors may broadly be classified in to two categories:- (1)complier time error:-all syntax error will be detected and displayed by the java compiler and therefore these errors are known as compile time error. Whenever the compiler displays an error it will not create the dot(.)class file . the most common problem are first missing semicolons and second missing brackets in classes and methods third missing spilling of identifiers and keywords fourth missing double courts in string and five use of undeclared variable.(2) Run time errors:-a program may compile successfully creating the dot(.)class

file but may not run properly such programs may produce wrong result due to wrong logic or may terminate due to errors such as stack overflow. Most common errors are:deviding an integer by zero, second accessing an element that is out of the fonts of an array, third passing a parameter that is not a valid one. *Difference between java and C++ Java C++ It does not support multiple inheritance It support multiple inheritance It does not support templates classes It support Java does not support operator over loading It support Java does not use pointes It uses It does not use header files It uses It does not use pre-processor directed It uses Java is purely OO language It is partially OOL It is secure language,virus does not effect on it It is not.w

2,4,6,8..10 even Class even {public static voidmain(String args[]) {int i; For (i=2;i<=10;i+2) {system.out.println(i);}}}

{Int i,j; For(i=1;i<5;i++) { For(j=1;j<5;j++) {system.out.println( ); System.out.println(j);} System.out.println(\n);}}} Import.java.awt.*; Import.java.applet.applet; Public class font extends applet { font f; Public void init U {set background (color red); F=new font(fixed sys,font.bold,50);} Public void paint(graphics g) {g.set font(f); g.set color(color.pink); g.draw strint(welcome name,50,60;}} <html><head><title>applet</title></head> <body> <applet code= font.classwidth=400, height =500></applet></body></html>

2,3,4...; Square Class square {public static voidmain(String args[]) {int i; For(i=1;i<=10;i++) {int a; a=i*i; system.out.println(a);}}} Class factorial {public static voidmain(string args[]) {int i, fact=1; For(i=1;i<5;i++) {fact=fact*i; System.out.println(fact)}}} Import.java.awt*; Import.java.applet.applet; Public class password extend.applet; { label=new label(enter the name); Add<lb>; Text field txt=new text field(20); Add(txt); Label password=new label(enter the password) Add(password); Text field tex password=new text field(20); Text password.set echorchor(*); Add(text password)}}} <html><head><title>applet</title></head> <body> <applet code= password.classwidth=500, height= 600></applet></body></html>

You might also like