You don’t have to be great to start, but you have to start to be great.
--Your friends at LectureNotes

Note for Object Oriented Programming Using JAVA - OOPJ by FUN WITH KM

  • Object Oriented Programming Using JAVA - OOPJ
  • Note
  • Biju Patnaik University of Technology BPUT - BPUT
  • Computer Science Engineering
  • B.Tech
  • 11 Topics
  • 1741 Offline Downloads
  • Uploaded 1 year ago
Fun With Km
Fun With Km
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

Lecture #1 Java History: Java is a general-purpose, object-oriented programming language developed by Sun Microsystems of USA in 1991.Originally called Oak by James Gosling (one of the inventor of the language). Java was invented for the development of software for consumer electronic devices like TVs, tosters, etc. The main aim had to make java simple, portable and reliable. Java Authors: James , Arthur Van , and others JAVA Features: Features of Java are as follows: 1. Compiled and Interpreted 2. Platform Independent and portable 3. Object- oriented 4. Robust and secure 5. Distributed 6. Familiar, simple and small 7. Multithreaded and Interactive 8. High performance 9. Dynamic and Extensible 1. Compiled and Interpreted Basically a computer language is either compiled or interpreted. Java comes together both these approach thus making Java a two-stage system. Java compiler translates Java code to Bytecode instructions and Java Interpreter generate machine code that can be directly executed by machine that is running the Java program. 2. Platform Independent and portable Java supports the feature portability. Java programs can be easily moved from one computer system to another and anywhere. Changes and upgrades in operating systems, processors and system resources will not force any alteration in Java programs. This is reason why Java has become a trendy language for programming on Internet which interconnects different kind of systems worldwide. Java certifies portability in two ways. First way is, Java compiler generates the bytecode and that can be executed on any machine. Second way is, size of primitive data types are machine independent. 3. Object- oriented Java is truly object-oriented language. In Java, almost everything is an Object. All program code and data exist in objects and classes. Java comes with an extensive set of classes; organize in packages that can be used in program by Inheritance. The object model in Java is trouble-free and easy to enlarge. 4. Robust and secure Java is a most strong language which provides many securities to make certain reliable code. It is design as garbage –collected language, which helps the programmers virtually from all memory management problems. Java also includes the concept of exception handling, which detain serious errors and reduces all kind of threat of crashing the system. Security is an important feature of Java and this is the strong reason that programmer use this language for programming on Internet. The absence of pointers in Java ensures that programs cannot get right of entry to memory location without proper approval.

Text from page-2

5. Distributed Java is called as Distributed language for construct applications on networks which can contribute both data and programs. Java applications can open and access remote objects on Internet easily. That means multiple programmers at multiple remote locations to work together on single task. 6. Simple and small Java is very small and simple language. Java does not use pointer and header files, goto statements, etc. It eliminates operator overloading and multiple inheritance. 7. Multithreaded and Interactive Multithreaded means managing multiple tasks simultaneously. Java maintains multithreaded programs. That means we need not wait for the application to complete one task before starting next task. This feature is helpful for graphic applications. 8. High performance Java performance is very extraordinary for an interpreted language, majorly due to the use of intermediate bytecode. Java architecture is also designed to reduce overheads during runtime. The incorporation of multithreading improves the execution speed of program. 9. Dynamic and Extensible Java is also dynamic language. Java is capable of dynamically linking in new class, libraries, methods and objects. Java can also establish the type of class through the query building it possible to either dynamically link or abort the program, depending on the reply. Java program is support functions written in other language such as C and C++, known as native methods.

Text from page-3

Lecture #2 Comparison in Java and C++ Java Virtual machine: As we know that all programming language compilers convert the source code to machine code.Same job done by Java Compiler to run a Java program, but the difference is that Java compiler convert the source code into Intermediate code is called as bytecode. This machine is called the Java Virtual machine and it exits only inside the computer memory. Following figure shows the process of compilation. The Virtual machine code is not machine specific. The machine specific code is generated. By Java interpreter by acting as an intermediary between the virtual machine and real machines shown below

Text from page-4

Java Object Framework act as the intermediary between the user programs and the virtual machine which in turn act as the intermediary between the operating system and the Java Object Framework. Fig: Layers of Interaction for Java programs Java Environment: Java environment includes a number of development tools, 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 JDK comes with a set of tools that are used for developing and running Java program. It includes: 1. Appletviewer( It is used for viewing the applet) 2. Javac(It is a Java Compiler) 3. Java(It is a java interpreter) 4. Javap(Java diassembler,which convert byte code into program description) 5. Javah(It is for java C header files) 6. Javadoc(It is for creating HTML document) 7. Jdb(It is Java debugger) For compiling and running the program we have to use following commands: a) javac (Java compiler) In java, we can use any text editor for writing program and then save that program with ―.java extension. Java compiler convert the source code or program in bytecode and interpreter convert ―.java file in ―.class file. Syntax: C:\>javac filename.java If my filename is ―abc.java then the syntax will be C:\>javac abc.java b) java(Java Interpreter) As we learn that, we can use any text editor for writing program and then save that program with ―.java extension. Java compiler convert the source code or program in bytecode and interpreter

Lecture Notes