Escolar Documentos
Profissional Documentos
Cultura Documentos
i) Java History
ii) Introducing Java
iii) Characteristics of Java
iv) Java Environment
v) Java Program Structure
vi) Java Development Kit (JDK)
vii) Compiling and Running Java Programs (Applet and
Application)
viii) Characteristics of OOP (Class, Encapsulation,
Polymorphism, Inheritance etc.)
ix) Java Class Library
JAVA HISTORY
Back in 1990, a gentleman by the name of James Gosling was
given the task of creating programs to control consumer
electronics. Gosling and his team of Sun Microsystems started
designing their software using C++. Gosling quickly found that
C++ was not suitable for the projects he and his team had in
mind. They ran into trouble with complicated aspects of C++
such as multiple inheritance of classes and with program bugs
such as memory leaks .
Although Gosling did not care for the complexity of languages
such as C++, he did like the basic syntax and object-oriented
features of the language. When Gosling completed his language-
design project, he had a new programming language that he
named "Oak". By the time Sun discovered that the name "Oak"
was already claimed and they changed the name to "Java".
INTRODUCING JAVA
Java Environment
Java Program Structure
Compiling and running Java programs
Using console mode
1. Select the Start/Programs/MS-DOS prompt command
from the Start menu. A DOS window appears.
2. Change to the directory by typing cd\jdkl.3\bin at the
DOS prompt.
3. Type javac filename.java and press Enter to compile,
where filename.java is the name of the
java-source file (Application/Applet).
4. Type java filename and press Enter to run java
application.
But to run java applet create a HTML file
with .html extension as follows:
• <HTML>
• <APPLET CODE="filename.class" WlDTH=100
HEIGHT=200>
• </APPLET>
• </HTML>
• Now type appletviewer filename and press Enter.
Using TextPad
– Write the source code you want to compile.
– Save it with filename.java
– Click Tools from menubar and then click compile java.
– If it is java application click run java application from
Tools menu.
– If it is java applet click run java applet from Tools
menu.
Program 1:
• Encapsulation
• Inheritance
• Polymorphism
Encapsulation: Encapsulation enables you to hide inside the objects both the data fields
and the methods that act on that data. In strict object-oriented design, an object's data is
always private to the object.
Inheritance: Inheritance enables you to create a class that is similar to a previously defined
class, but one that still has some of its own properties. Think of how human children inherit
many of their characteristics from their parents. But the children also have characteristics
that are uniquely their own. In object-oriented programming, you can think of a base class
as a parent and a derived class as a child.