5 minute read

Real time systems

4. Eneapsulation:

Data Cncapsulation is most important feature ofclass.

Advertisement

The process of combining data and methods (functions) in a single unit is known as Encapsulation.

The data ofaclass is aecessed by only the methods of same class. .By using encapsulation. we can accomplish data hiding.

5. Inheritance:

The process ofereating a new class from old class is called inheritance. Inheritance is very useful to add additional features to an existing class without moditying it,. .The new class will have the combined features ofnew class and old class. .New class is called derived classorsubclassand old class is calledsuperclassorz baseclass.

Bird

Feathers eggs

Flying Non-Flying

Robln Crow

Kiwi

6. Polvmorphism: Polymorphism means the ability to take more than one form with asinglename. "Polymorphism" comes from the "Greek' word. "Poly" means "many" and "morphism"

means "forms". i.e., many forms. It's a quality that allows one name to be used in two more purposes. An action is depends on the type ofthedata. There are two types ofpolymorphisms. 1. Compile-time polymorphism.

Shape

Draw()

2. Run time polymorphism.

Circle object Box object Triangle object

Draw(circle)

Draw(box) Draw (Triangle)

7. Dynamicbinding

Dynamic binding means inking Uhe code at the tme of executing the progran. lt is associated wvith polymorphism and inheritance 8. Messagepassing

A message for an object is nothing but request lo execute a procedure.

Message passing specifies name ol the object, naine of the method (message) and th information to be sen.

Employe $olary (name)j

Objoct mossago information

Features ofJava

The following are most important features of Java. 1. Compiled and Interpreted. 8. High Performance. 2. Platform-Independent and Portable. 9. Dynamic and Extensible. 3. Object Oriented 10. Ease of Development 4. Robust and Secure. 11. Scalabilityand Performance

5. Distributed. 12. Monitoring and manageability

6-Simple Smalland Pamiliar. 13 DesktopClient-

7. Multithreaded and Interactive. 1. Compiled andinterpreted: Usually, a computer language is either complied or interpreted.

But Java is both compiled and interpreted language. The Java compiler translates "source code" into "Byte code", and the java interpreter translates "Byte code" into "Machine code". 2. Platform independentand portable: The most important feature of Java language is

Portable i.e.,Javaprogramscaneasilymoved from_one_computer toanother,anywhereand anytime. Byte code instructions of java programs are executed in any platform using

JVM, hence java is platform independent. 3. Object oriented: Java is purely object oriented programming language. Because, all the program code and data must resides with in the class. 4. Robust andSecure: Java is the Robust and Secure language. Because, It has strict compile time and runtime checking for errors. Java also supports exception handling to handle runtime errors. 5. Distributed: Java is designed as a distributed language to create network based applications (Client/Server applications). 6. Familiar,Simpleand Small: Java is simple and small language. Because, many fearures of c&care reduced injava. All over the world, many no.olpersons are using Java. So that.

Java is a familiar language. 7. Multithreaded and interactive: Java supports multithreading concept. i.e.. t execuies

9. Dynamieand exICnsible: Java is a dynamic language. because if is capahie of dyrumie linking. Java supports native methods to extend the programs, devetoped in C arnd C* JavaHistory

Java 8 A generai purpose object oTriented programming language devetopcd by sun

Microsysiemsof USA in 1991

Origimally java was called OAK" by James Gosling. onc of the inventors of java

languag2c

Java as developed lor consumer eicctronic devices like TVs.VCR s arnd such oner electronic machines. The main goal of java team is developing of simple. portable and highly reiable language. JavaMilestones:

Year

1990 Development Sun Microsystems decided to develop special software to manipulate consum er clectroniedevices.

1991 Most popular OOPs language Oak was introduced. 1992 Green Project team by sun, demonstrated the application of tocontrolalist ofhomeappliances. World Wide Web appeared on the Internet and transformed their new language the text-based 1993 internet ntoa graphicalrich environment. 1994 A Web browsercalled "Hot Java"wasdevelopment.

1995 Oak was renamed as Java. 1996 Sun releases Java Development Kit 1.0 (JDK 1.0) 1997 Sun releases Java Development Kit 1.1 (JDK 1.1) Sun releases Java2 with version 1.2 ofthe Software Development kit 1.2 (SDK

1998

1999

| 1.2) Sun releases Java 2 Platform, Standard Edition (J2SE) and Enterprise Edition J2EE

2000 J2SE with SDK 1.3 was released. 2002 J2SE with SDK 1.4 was released. 2004 J2SE with JDK 5.0 (J2SE 5.0) was released.

Structure ofJava Program

Java is a general purpose objecl-oriented programming language developed by SunMicro Systems in 1991. Java is the first programming language that is or Sofiware. Programs developed in java can not dependent be executed on on any particular any system. Hardware

Intorface Statoments Optional

Class Detnition

Optional

man) Method elass maint) method detnition Essenttal

Java Program Structure

1. Documentation Section: The documentation section contains set of comment lines

Comment lines are non-executable statements that are ignored by the compiler.

The documentation section contains - the name of the program, author and other details.

Java supports 2 types ofcomment lines. They are a) Single line comment // b) Multiple line comment /*. .*/ 2. Package Statements: The first statement in a Java program is the package statement. This statement declares the package, and informs the compiler that the classes defined here belongs to this package.

The package statement is optional.

Example: package student; 3. Import Statements: An import statement is similar to Hinclude statement in C or C++ language. The import statement instructs the interpreter, to allocate memory for the specifiedclasses.

Ex: importjava.lang.System; Importjava.util.*; 4. Interface Statenments: An interface is like a class, which includes a group of abstract methods. This section is used to declare an interface.

This is used only when we want to implement multiple inheritance in a java program. 5. ClassDefinition: A Java program can contain multiple classes. Classes are the primary and essential elements ofa program. The complexity of the program depends on the number of classes used in the program. 6. maint0method Class: Every java program contains a main() method. The main() method createsobjectsofvariousclasses and establishes communication between them.

This article is from: