Contents
Introduction Need of C++ The use of structured programming language (like C) enabled the programmers to write, for the first time, moderately complex programs fairly easily. However, even with structured programming methods, once a project reaches a certain size, its complexity exceeds what a programmer can manage. By the early 1980's many projects were pushing the structured approach past its limits. To solve this problem, a new way to program was invented, called Object Oriented Programming (OOP). OOP is a programming methodology that helps organize complex programs through the use of Inheritance, Encapsulation and Polymorphism.Reasons to prefer Java over C++
Need of Java Java is an Object oriented language. The Syntax of Java is similar to C++, but Java avoids Pointers, multiple inheritance, goto statement and operator overloading. It provides efficient features to handle these issues. Features of C++ that slow down application development cycle have been omitted in Java, like Java has a garbage collector, so unlike C++ in Java we don't need to deallocate the memory, or worry about memory fragmentations. Parts of Java Sun Microsystems Inc., has divided Java into 3 parts as follows: 1. Java SE: It is the Java Standard Edition that contains basic core Java classes. This edition is used to develop standard applets and applications. 2. Java EE: It is the Java Enterprise Edition and it contains classes that are beyond Java SE. Infact, we need Java SE in order to use many of the classes in Java EE. Java EE. Java EE mainly concentrates on providing business solutions on a network. 3. Java ME: It stands for Java Micro Edition. Java ME is for developers who develop code for portable devices, such as a PDA or a cellular phone. Code on these devices needs to be small in size and should take less memory. -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Setting the Classpath in WINDOWS After installing the Java software jdk1.5.0 in C:\Program Files\ follow the below steps: {FOR WORKING JAVA SET THE PATH LIKE BELOW} Variablename: JAVA_HOME Variablevalue: C:\Program Files\Java\jdk1.5.0 variablename: CLASSPATH Variablevalue: C:\Program Files\Java\jdk1.5.0\bin;. Variablename: CATALINA_HOME Variablevalue: ..
1. What is the difference between a class and an object? 2. What is the difference between object oriented programming languages and object based programming languages? Object based programming languages follow all the features of OOPS, except Inheritance. For eg., JavaScript and VBScript will come under object based programming languages. 2. A Simple Java program: Example.java /* This is a simple java program Compiling the program: c:\>javac Example.java Java compiler creates the file called Example.class that contains the byte code version of the program. c:\>java Example (output-Result of run) c:\>java -p Example (to see the byte code) In java, all program activity occurs within xxxe. This is one reason why all java programs are (at least a little bit) object oriented. All java applications begin execution by calling main(). PrintStream obj. println("welcome to Java"); void: Simply tells the compiler that main() does not return a value. 2. Java documentation Comments: These comments start with /** and end with */. These comments are used to provide description for every feature in a Java program. This description proves helpful in the creationof .html file called API(Application Programming Interface) document. Java documentation comments should be used before every feature in the program as shown here: /** description about package */ package packagename package packagename description about package --------------------------------------- /** description about a class */ class classname class classname description about a class { --------------------------------------- class code; /** description about a method */ void methodname() { void methodname method code description about a method } ------------------------------------- } Java program API documentation javadoc <filename>.java |