Welcome Guest   Login   Sep 21, 2017
Chapter 1
Introduction to programming languages & Java

Evolution of ‘C’ Based Programming Languages.

The 1960s gave birth to structured programming. This is the method of programming championed by languages such as C. By use of structured languages, it was for the first time possible to write moderately complex programs fairly easily. However, even with structured programming methods, Once a project reaches certain size, its complexity exceeds what a programmer can manage. By the early 1980s, many projects were pushing the structured approach past its limits. To solve this problem, a new way to program was invented. This method is called Object Oriented Programming (OOP). OOP is a programming methodology that helps organise complex programs through the use of inheritance, encapsulation, and polymorphism.

In the final analysis, although C is one of the world’s great programming languages, there is a limit to its ability to handle complexity. Once a program exceeds somewhere between 25000 and 100,000 lines of code, it becomes so complex that it is difficult to grasp as a totality. C++ allows this barrier to be broken and helps the programmer comprehend and manage larger programs.

Concepts of OOPS

As you know, all computer programs consist of two elements: code and data. Furthermore, a program can be conceptually organised around its code or around its data. That is, some programs are written around "what is happening" and others are written around "who is being affected." These are the two paradigms that govern how a program is constructed. The first way is called the process-oriented model.

This approach characterises a program as a series of linear steps (that is, code). The process-oriented model can be thought of as series of linear steps (that is, code). The process-oriented model can be thought of code acting on data. Procedural languages such as C employ this model to considerable success. However problems appear as program grows larger and more complex.

To manage increasing complexity, the second approach, called object-oriented programming, was conceived. Object-Oriented program can be characterised as data controlling access to code. As you will see, by switching the controlling entity to data, you can achieve several organisation benefits.

Abstraction :an essential element of object-oriented programming is abstraction. Humans manage complexity through abstraction. For example, people do not think of a car as a set of tens of thousands of individual parts. They think of it as well-defined object with its own unique behaviour. This abstraction allows people to use a car to drive to the grocery store without being overwhelmed by the complexity of the parts that from the car. They can ignore the details of how the engine, transmission, and braking systems work. Instead they are free to utilise the object as a whole.

A powerful way to manage abstraction is through the use of hierarchical classification. This allows you to layer the semantics of complex systems, braking them into more manageable pieces. From the outside, the car is a single object. Once inside, you see that the car consists of several subsystems: steering, brakes, sound system, seat belts, heating, cellular phone, and so on. In turn, each of these subsystems is made up of more specialised units. For instance, the sound system consist of a radio, a CD player, and /or tape player. The point is that you manage the complexity of the car( or any other complex system) through the use of hierarchical abstraction.

The OOP principles

All object-Oriented programming languages provide mechanisms that help you implement the object-oriented model. They are encapsulation, inheritance.


Class is collection of properties and the methods which are shared by so many objects.


An instance of class is called object. Which is having unique characteristics.


Encapsulation is the mechanism that binds together code and the data it manipulates, and keep both safe from outside interference and misuse. One way to think about encapsulation is a protective wrapper that prevents the code and data from being arbitrarily accessed by other code defined outside the wrapper. Access to the code and data inside wrapper is tightly controlled through a well-defined interface.

The power of encapsulated code is that everyone knows how to access it and thus can use it regardless of the implementation details and without fear of unexpected side effects.

In Java the basis of encapsulation is the class. A class defines the structure and behaviour (data and code) that will be shared by a set of objects. Each object of a given class contains the structure and behaviour defined by the class, as if it were stamped out by a mold in the shape of the class. For this reason, objects are sometimes referred to as instance of class. Thus, a class is a logical construct; an object has physical reality.

When you create a class, you will specify the code and data that constitute that class. Collectively, these elements are called members of the class. Specifically the code that operates on that data is referred to as member variables or instance variables. The code that operates on that data is referred to as member variables or instance variables. The code that operates on that data is referred to as member methods or just methods. (If you are familiar with C/C++, it may help to know that what a Java programmer calls a method a C/C++ programmer calls a function.) In properly written Java programs, the methods define how the member variables can be used. This means that the behaviour and interface of a class are defined by the methods that operate its instance data.


Inheritance is the process by which one object acquires the properties of another object. This is important because it supports the concept of hierarchical classification. Most knowledge is made manageable by hierarchical ( that is top-down) classification. For example, a Golden Retriever is a part of the classification dog, which in turn is part of the mammal class, which is under the largest class animal.

Without the use of hierarchies, each object would need to define all of its characteristics explicitly. However, by use of inheritance, an object need only define those qualities that make it unique within its class. It can inherit its general attributes from its parent. Thus, it is the inheritance mechanism that makes it possible for one object to be a specific instance of a more general case. Let’s take a closer look at this process.

Most people naturally view the world as made up of objects that are related to each other in hierarchical, way, such as animals, mammals, and dogs. If you wanted to describe animals in an abstract way, you would say they have some attributes, such as size intelligence, and type of skeletal system. Animals also have certain behavioural aspects; they eat, breathe, and sleep. This description of attributes and behaviour is the class definition for animals.

Since mammals are simply more precisely specified animals, they inherit all of the attributes from animals. A deeply inherited subclass all of the attributes from each of its ancestor in the class hierarchy.


Polymorphism (from the Greek, meaning "many forms") is a feature that allows one interface to be used for a general class of actions. The specific action is determined by the exact nature of the situation.

Importance of Java

In the same way that a cup of coffee will jolt most people into action, the Java programming language moves the Internets World Wide Web into action by jolting static Web pages into dynamic, multimedia-rich presentations, Java brings a new level of interactivity to the Web. You could say that Java is to the Web as a Carpenter's tools are to building a house. Java provides the Web publisher with the tools necessary to control what a user experiences on the Web.

Now, don't get worried. Just as building a house can be hard work, programming can be difficult. However, just like a carpenter can go to the hardware store and purchase prefabricated doors, sinks, and bathtubs, the Java developer can use ready-made modules (known as objects or classed) to incorporate fancy multimedia effects into Web pages with minimal programming knowledge. This is the great advantage of being an object-oriented programming system, of which Java takes full advantage.

Java works in conjunction with the hypertext markup language (HTML) to allow the publication of information on the Web. HTML is actually a pretty limited method of controlling the display of information, but Java goes many miles

beyond what plain HTML provides.

Java is the first programming language developed for a network computer system, like Internet.


Sun Microsystems originally developed Java as language to control set-top television boxes. (Set-top boxes are similar to cable television boxes that sit on top of your television and help you control what you see on the TV. However, the set-top boxes provide much more interactivity and power than today's cable TV. Boxes.) Sun wanted to develop an operating environment for consumer devices that presents information via cable television. The original project began in 1991 and was referred to as the "Green" team. Headed by James Gosling, this small team of people designed and implemented Java outside of Sun's main headquarters near Stanford University in Palo Alto, California.

When members of the team first began planning the Green project, they realised that any system of controlling consumer electronic devices would have to be platform-independent: it could not rely on specific microprocessors or hardware. The developers wanted a system that could run just as well on a Sony VCR, an Apple Newton PDA ( personal digital Assistant), a wireless telephone, or maybe even a personal computer.

The team was successful in developing this project. The operating system was implemented in proprietary PDA known as *7 (Star Seven). By the end of 1991, Gosling had a beta version of the operating system that he called 'Oak' (named for the tree outside his office window). At the time, the company wanted to market the technology in a similar method to how Dolby Labs has successfully marketed its noise reduction system for stereo equipments. The team wanted to license Oak to large number of different companies-- even companies that might compete against one another.

Developing a software for consumer electronics devices turned out to be much more of a challenge than developing software of computers. When researching the difference between the consumer electronic market and the personal computer market, the Green team found that consumer devices generally have much longer life than computer products. For example, there are working toasters that are 10,20, maybe 50 years old. You can still plug this unit into an electrical socket and insert slices of bread. However software generally improves every couple of years, if not every year. The team found that software for consumer electronic devices would have to be backward compatible in order to be commercially feasible.

Also, the team found that software used in consumer electronics must be extremely reliable, much more so than most computer software. If a consumer product fails, the manufacturer usually has to replace the entire machine. This is not something any manufacturer enjoys.

In the meantime, the Green team was now incorporated as a separate company from Sun, known as First Person Inc. The team found out that Time Warner was developing a video-on-demand service that required set-top boxes. Because the group had developed Oak in a device-independent manner, it saw this as the perfect opportunity. Although the team completed a working prototype, the folks at Time-Warner ultimately ended up going with another company's technology. Looking back, it was probably all the better because the Time-Warner video-on-demand service turned out to be disaster.

Around the same time, Sun almost cut a deal with 3DO, a company selling an expensive CD-ROM game machine. it took only ten days to get Oak running on one of the 3DO boxes, but the companies could never negotiate an agreement. Again, this probably turned out to be all the better because 3DO has still not made any large penetration into the game market.

As the Internet and Web were becoming popular in 1993, the Green team realised that it could use a platform-neutral programming language, like Oak, for programming Web applications.

Bill Joy, the cofounder of Sun, finally got involved and wrote a new plan for the technology for interface into the internet. In early 1995, the company discovered that someone had already filed a trademark for the name Oak, so the language was renamed to Java. Rumours have circulated that the letters stand for 'Just Another Valueless Acronym', but the company denies this. Instead, it says that the inspiration struck one day during a trip to the local coffee shop, which sounds likely enough.

As the plan went into action, the team created a new Web browser originally called WebRunner, later named as HotJava. The team then set out to license the Java language to other companies that create Web browser.

Features of Java

Sun Microsystems describes Java as "a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high-performance, multithreaded, and dynamic language." Whew, that sure is a mouthful. Let's iron this down to the important features that we can make use of now.

Java allows a programmer to pack a good amount of functionality into a relatively small package that can run anywhere in a highly distributed network, such as Internet. This is cool because it is a language designed to support networking -- something that other computer language don't even take into account.

The Java language supports the following major features :

  • Interactive multimedia
  • Platform independence
  • Several Layer of security
  • Software distribution and installation
Interactive Multimedia : Multimedia is simply the integration of software, text, static graphics images, audio, and digital video. The Web browser accesses a helper application to play the audio or display the video information. A Java applet could be developed that would transfer the data in the background and then display it in the main Web browser Window. Using Java, you have many ways to make audio and video playback better.

Platform Independence : You already know that Java was designed to work on many different types of computer systems, but this is a lot easier to talk about that to implement. Here's why. for a program to run on a computer, it must first be translated from a language like Pascal or C++ into the machine's native tongue (this is done by something called a compiler). Because this translation process is time consuming, most software comes already compiled. This means that different versions must be created for different computers. Java averts this problem by using an intermediate binary language. The result is that small applet can move around the Internet without regard to the kind of hardware used. If you need to watch an animation that requires a particular program to run it, your machine will pick up the Java coded applet along with the animation files and run it. It doesn't mater what hardware your machines uses.

A Java applet must execute on may different platforms. The method chosen to realise this aim is an architecture-neutral binary representation. These architecture-neutral binary codes contain computer instruction that possess no allegiance to or dependence on a specific computer architecture.

You convert your Java programs into platform-independent binary byte codes, which a platform-specific Java run-time system the interprets. The developer must maintain only one source of Java program for many different platforms. For example, you develop a Java applet and then compile it. You then run the same program on a PC, Mac, or UNIX system, which contains the Java run-time environment ( part of the Web browser). Thereby, developers can more quickly create application for the web that more users can access.

Security : Java is designed for network applications. A user has to worry about any executable code that he or she receives from the network because the program could be infected with a computer virus. Java applications are guaranteed to be tamper-resistant and virus free because they cannot access system memory the way programs written in C or C++ can. Java also features several layers of security, including the following :

  • A byte code verification system : This checks the Java applet for language compliance. Even though the compiler generates correct code, the code could have been intentionally ( or unintentionally) changed between compile-time and run-time. Security safeguards prevents this from happening.
  • File access restriction : If a Java applet attempts to access a file that it doesn't have permission to, a dialog box appears that allows the user to stop or abort applet execution.
  • Run-time class verification : This system checks Java applets for function names and access restrictions during applet loading. This is a good means of security.
Future versions of Java are supposed to include public key encryption routines to verify the source of the Java applet as well as its integrity after passing through a network. This encryption technology could be the key to secure financial transactions across the Internet.

Software Distribution & installation : Distribution of information for sharing is an essential characteristic of any client-server information system. Java contains a library of routines to interface to TCP/IP protocols. Through these routines, you can easily move messages and files around the Internet. You do this when a Java application opens a URL to request information from the Web. Specifically, Java includes support for access to information on the Web through transfer formats like HTTP (hypertext transfer protocol) and FTP(file transfer protocol).

Lately, folks have been talking about a new type of software distribution, which works something like this. Today, if you want the latest version of software product, you go to the local software superstore and purchase it. You do this if the application is a word processor, which you use everyday, or a desktop publishing application, which you might use once a year.

Some proponents of Java envision a time when the Web will be the spot to download hundreds of different applications -- most likely specialised applets that are not used on a regular basis but could be extremely useful. Users could connect to the computer with this specialised software and for a small fee use it as if they owned it. This would remove the need to buy ten pounds of software and upgrade it every time a new version comes out.

Uses for Java

Java might be great as an object oriented language that can turn computer programmers' heads, but Java, more importantly, has some solid uses. The following categories explain some of the largest application categories :

  • Developer tool kits
  • Educational applications
  • Enhanced Web Pages
  • Games and entertainment
  • Internet and Web access agents
  • Productivity tools
Developer tool kits : developer tool kits are applets designed to help users create tools for the development and deployment of knowledge and information based systems. These could be something like a drag-and-drop development tool, an online knowledge base, or a Java development tool that provides a visual interface to applet development, much like Visual Basic. Applet built into the Netscape Navigator browser that displays a real-time status of Java applets.

Educational application : Education applets are designed to help users gain insight. An educational applet can behave like scientific instruments or interpret and display input data so that students can focus on the meaning of scientific principles. With the integration of audio and video, the resulting educational applet could be an effective means for learning. Imagine the possibilities if our educational system could grasp this technology.

Enhancing Web Pages : The greatest use so far for Java is in adding flair to Web pages. This means making use of all those great multimedia features to make Web pages come alive. At the very least, a Web designer can add animated words, like "What's New!" to draw attention to them and to make the new information really stand out on a page.

Games and Entertainment : The developer can also create applet to provide an environment for entertainment purposes, providing the user with an interactive experience. Tic-tac-toe and hangman probably seem like poor reasons to use an expensive computer, but these are only examples. More games will certainly become available. Multiple-player Internet-based games could become a reality. Of course, these applets would probably make use of multimedia features that Java provides for enhancing Web pages. Hopefully, this category will overlap with educational applets because the best type of educational experience is an entertaining one.

Internet and Web access agents : Another interesting type of Java applet is one that retrieves information from a network, making it possible to take over a user's display and exhibit a series of network resources. The big talk these days is about a type of Internet agent that would watch the types of home pages you view on regular day-to-day basis and would then find others related to the ones that already interest you. As the system begins to learn about your interests, it can start fetching your favourite Web pages for you.

Productivity Tools : productivity tools are specialised home applets or business applications that provide an interface to programs for information processing. The biggest picture would be applet like specialised spreadsheets, word processing, and presentation packages. However, on smaller basis, the applet could be something as simple as returning a customised database query.

My New Blog

My Award winning Whitepaper

Contradicting Light
My Personal Blog

Trace Mobile Location

My Book Reviews

Tech Jokes Worth Reading
www.deepjava.com 1999-2017 (C) Developed and maintained by D-Kay Consultancy