The best revenge is massive SUCCESS
--Your friends at LectureNotes

Note for Java Programming - JAVA By Anirudh Sharma

  • Java Programming - JAVA
  • Note
  • Patna University - PU
  • Computer Science Engineering
  • 3 Topics
  • 105 Offline Downloads
  • Uploaded 1 year ago
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

INTRODUCTION OF JAVA:Java is a general purpose complete object oriented language, developed by “SUNMICRO system” of “USA” in 1995. Initially it was called as “oak” by “JAMES GOSLING” one of the inventors of the language. Java was designed for the development of software for consumer electronic devices like tv, vcr, toasters and such other electronic machines. The java team which included “PATRIC NAUGHTON” discovered that the existing language like “c” and “c++” had limitation in term of both reliability and portability. So they moded their new language java on c and c++ but removed a no. Of feature of c and c++ thus java has been introduced as simple, reliable, portable and powerful language. The following table shows the development phase of java :- Year 1990 1991 1992 1993 1994 1995 1996 Development Sun-micro system decided to develop this software for electronic devices. The team of programmers leaded by “JAMES GOSLING”. After the exploring the features of c++, the team announced a new language named “oak”. Sun-micro system demonstrated this language as a “green project” on home applications devices. This language was the establish the compatibility with internet. The team developed a web browser called “hot java” to locate and run approte programs on internet. “oak” was renamed as java. Java is just a name and is not an acronym. Java establishes itself not only as leader for internet programming but also a complete object oriented programming. Thus we can say that java is a complete object oriented language which developed by sunmicro system in 1995. The popular developers of java was “James gosling” and “Patrice naughton”

Text from page-2

It is called as fully oops language because no any program can be done without the use of class and object. Even the main method of java also resides within a class. Thus we can say that java does not support the concept of global functions/method. At list, one class must be used in every program of java therefore it is known as fully object oriented languages JAVA V/S C++ :Java is differing from C++ in several ways as follows:a) There are no header files in java b) Java does not support pointers c) Java does not support global variable and methods. Every variable and method is declared within a class and form part of that class. d) Java does not support operator overloading. e) Java does not support multiple inheritances of classes. It is implemented by using a new feature called interface. f) Java has both translators (compiler and interpreter) where as c++ only on translator (compiler). g) Java has no own editor where as c++ has own editor. h) Java is architecture independent language. i) Java is neither a super set nor a subset of c, c++. JAVA AND INTERNET :Java is strongly associated with the internet because of the fact that first application program written in java was “hot java” a web browser to run applets on internet. Inter user can use java to create applets program and run them locally using java enabled browser such as hot java. It is also used a java enabled browser to download and palpate located on a computer in the internet and run it on his local computer. Internet user can also setup their websites containing java applets that could be used by other remote users of internet so, we can say that java is popularly known as internet language.

Text from page-3

Java environment :It includes a large number of development tools and hundreds of classes and methods. The development tools are part of the system known as java development kit (JDK) and the classes and methods are part of the java standard library (JSL) also known as the application programming interface (API). Java development kit (JDK) :- The java development kit comes with a collection tools that are used for developing and running java program they included:➢ Applet views :- for viewing java applet ➢ Java c :- java compile ➢ Java a :- java interpreter ➢ Java p :- java disassemble ➢ Java h :- java c header file ➢ Java doc :- for creating HTML documents ➢ Java b :- java debugger All these tools are available in the “bin” directory of “jdk” Thus, we can say that “jdk” is the software for which holds all the tools and components for creating and executing java program. It can in difference version like 1.0, 1.1, 1.2, 2.0, 2.1, 2.8 etc. the latest version of “jdk” is 1.8.0. ❖ Installing JDK :C:\program file\java> Saving, compiling and running java program :➢ Saving :Since java has no own editor so, its program can be written in any text editors like notepad, WordPad, dos etc. its program files is saved with main class named having the extension “.java”. This file is called as source file. A class in which main method resides is called as main class. ➢ Compiling :-

Text from page-4

After creating “.java” file we must have to compile it at first. To compile the java program, we use java compiler (javac) as follows:Start run cmd c:\administrator\....\....\>cd\ enter c:\>cd jdk1.8 c:\jdk1.8\bin>javac filename.java compilation During compilation phage, compiler checks the syntactical as well as linking errors. If our program has any errors and warnings then compiler displays all the error and warning with their error messages and statements on dos screen. The error position is indicated by sign (^) Example:Error: statement missing (;) C=a+b^ 1 error, 0 warnings. If our program has no any errors then the source code is converted into intermediate code which is not dependent on any machine this code is called as byte code. Byte code is just like a machine code but not a complete machine code. It is not dependent on any processor architecture like IBM, apple making toss etc. This code is applicable for any types of machine. That’s why java is called as architectural independent language. If compilation is successful then prompt will appear without any message. C:\jdk1.8\bin>javac sum.javaenter C:\jdk1.8\bin> {compile successful} Interpretation (running phase) :- After successful compilation, java program must be passed through java interpreter (javap). The java interpreter uses the byte code from the “JVM” created by compiler and then its creates the executable file of java according the processor type in which it is executing. The extension of the executable file of java is “.class”. To interpret java program, we use the following command:-

Lecture Notes