online file11

105
 Preface  Training plays a very important role in the engineering course of the student because this helps him/her in gaining tremendous knowledge & experience as he /she can learn about the bundle of things which can’t be learn in campus, so these training schedules are added in the course by various universities

Upload: akshima-dogra

Post on 06-Apr-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 1/105

 Preface

 

Training plays a very important role in theengineering course of the student because this helps

him/her in gaining tremendous knowledge &experience as he /she can learn about the bundle of 

things which can’t be learn in campus, so these

training schedules are added in the course byvarious universities

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 2/105

 ACKNOWLEDGEMENT 

ENTRANCE…Hard work…gradual progress andsecond year. That’s how I have reached this level

and now I stand at the two years which I have spentin this college.

Training is agglomeration of the theoretical and

 practical and technical concepts, which enhances our 

skills in the field of technology.We sincerely acknowledge our thanks to the teachers

for their guidance and motivation throughout the

training and project work.

We would also like to record our gratitude to Ms.

Rajveer for giving us a chance for a successful

training here.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 3/105

Last, but not the least, I would like to thanks all our companions for their help which was in abundance

TABLE OF CONTENTS 

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 4/105

CONTENTS 

1.Introduction………………………………………………….1.1 Abstract  1.2 Objective

1.3 Areas of Application1.4 About JAVA

2.System Analysis………………………………………………2.1 Feasibility Study

2.2 Hardware & Software Requirements

3 System Design………………………………………………..

3.1 Modules and their description3.2 Flowchart 3.3 0 level DFD

3.4 E-R diagram

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 5/105

4.Conclusion & FutureScope…………………………………..4.1 Conclusion

4.2 Future Scope & Application Area4.3 Advantages4.4 Limitations

 References & Bibliography

INTRODUCTION

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 6/105

1.1 ABSTRACT

ONLINE TEST is a software in which we have

specified some questions, a timer runs for given time

and within that period one has to answer for all those

questions, some buttons are presented at the bottom

of the window like start button, previous , next ,

finish.

When we click the start button the online test get

started, you will have to answer 25 questions within 10 minutes, the timer runs.

If you do not wish to answer a particular question

you can move on to next question by pressing next

  button or if you wish to move to the previous

question that you had skipped you can make this

move by previous button.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 7/105

The environment used for this project is JAVA. This

 project is based on core JAVA. The software used

for this java SDK1.5, Window XP operating system.

1.2 OBJECTIVES

This concept of online test fulfils the following

requirements:

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 8/105

➢It provides a less expensive as well as an

effective method of performing examinations.

➢It provides best facilities for the students to

answer the question only with a single click.

➢It saves time as well as money.

➢It lessens the student’s and teacher’s frustration.

1.3 AREAS OF APPLICATION

Across the globe: This project finds itapplication in conducting examination over 

the globe.

➢ Student’s needs: It saves time as well as

money. It lessens student’s frustration.

 

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 9/105

SYSTEM ANALYSIS

2.1 FEASIBILITY STUDY

Feasibility study defines all the requirements to

 performance characteristics of system.

For system to be feasible, the design needs to

undertake various factors or performance

requirements by which the system will be operated.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 10/105

A feasibility study is short, focused study which

aims at selecting the best system that meets

  performance requirements. Information is gathered

regarding the general requirements of the proposed

system.

If feasibility study is to serve as the decision

document, it answers a number of questions.

Like

✔ Is it beneficial?

✔Does it save time and money?

✔Can it be integrated with other systems alreadyin place?

Planning resources is a very vast concept and we are

 beginners, thus including each and every aspects of 

web, Integrate and automate them in every respect

was not feasible for us.Hence we perform feasibility

study to make our project compatible for present

environment. The concept of Online Testis newer.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 11/105

The project is built with the help of  JAVA

technology which is reliable and efficient platform

to work upon. This concept saves time and lessens

the teacher’s and student’s frustration.

2 .1.1 Technical feasibility

Technical feasibility takes of the all the issuesconcerned with the design and the development part

of the project. It concerns itself with the software,

hardware and the platform related issues. The

following are the technical specifications for our 

 project.

The project would require a lot of space for storage

of static as well as dynamic content.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 12/105

As the number of project available increases the

space required for storing them increases.

2.1.2 Economic feasibility

➢It provides an efficient and reliable platform to

work upon.➢It saves time and is thus a faster means of 

examination.

➢It is less costly than the other means of 

examination.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 13/105

2.2 HARDWARE AND SOFTWARE

REQUIREMENT

Software Requirements

Operating System : Window 2000/XPFront End : JAVA sdk1.5

Hardware Requirements

Machine : Pentium 4

Speed : 233 MHz and above

Hard Disk : 10GB

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 14/105

RAM : 256MB

 

SYSTEM DESIGN

3.1 MODULES AND THEIR DESCRIPTOIN

3.1.1 Administrator module

The administration process can be complex and must

 be properly planned and managed to ensure a

successful project. Administrators are a professionalteam trained to follow a project plan that has been

designed specifically for you. Administrator 

develops software and enhances it

 process.Administrator in online test project based on

Core Java enters questions and answers in an array.

He created software for online test in which he

created a window which is partitioned into four 

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 15/105

 parts: North, South, East, and West.North Window:

He has provided a Welcome note for the user with

user name and timer runs after clicking start

 button.South Window: He has created buttons to

start the test, to move to the next question, to finish

the test and two buttons to navigate back to previous

or next question after finishing the test to check the

answers.East window: Questions are displayed in

this window.West window: Options are given in this

window with check boxes, check boxes are checked

for the correct answer.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 16/105

3.1.1.1 Entering Questions and Answers

While creating software for online test, He has

entered questions only in an array and placed them

to the East window. And options to choose correct

answer are in West window.

1. Enter questions for test2. Enter answer options for Users

3.Check questions and Display

3.1.2 User module

User only has to enter the name and proceed to

answer the questions. User click the start button and

timer starts, user have only ten minutes to answer all

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 17/105

the questions. After answering all the questions, user 

click finish after the test and answer will be

displayed for all the questions. Users click check 

 previous or check next for checking correct answer.

1.Enter name

2. Answer the questions

2.Finish the test and Check correct for correct

answer

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 18/105

2.2.1Flowchart

 Enter user name       Start  Proceed?   NoYes           Press OK   Press cancel   Click Start to          Run the timerT   Window 

displayed If Questions answered in given time? vvein    NOYeClick Finish to

Check result  Timer 

    over      overOve

 End 

start 

Created arrays for Ques and ans

 Entering ques for users and itsanswers

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 19/105

2.3 Flow chart 

E-R DIAGRAM

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 20/105

ONLINE TESTQUESTIONSINSTRUCTIONS

 NAMEMAR KS

%AGE

GIVESCANDIDAT

E

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 21/105

CONCLUSION AND FUTURE SCOPE

4.1 CONCLUSION

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 22/105

Computerization is needed in this Shrinking world,

where centralization is also required with

globalization. Conducting online test is a step in this

direction to ease the current structure of 

examination. This way of conducting test on one of 

the most secure operating system and with highly

sophisticated technology is cost effective and save

time too.

This way of conducting test not only save time but

also lessens student’s and teacher’s frustration. It isan easier way of giving examination, any person

across the globe can appear for the examination.

4.2 FUTURE SCOPE

It has vast future scope, as it is not made for clientserver level so we can make it for client server leveltoo.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 23/105

Every type of exam can be conducted online and itwill lessen the teacher’s frustration.We can also conduct tests for various subjects and

various difficulty levels.

4.3 Advantages of the software

• Since this software is designed in java, it isPlatform independent..

• Successfully handles the problem.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 24/105

• Reliability gives consistent results.• System is robust.

4.4 Limitations of the software

• All the questions have to be scrolled once before

clicking the finish button• A user must have fundamental knowledge as to

how to use the application

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 25/105 End 

 ABOUT JAVA

Java technology is both a programming languageand a platform.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 26/105

The Java Programming Language

The Java programming language is a high-levellanguage that can be characterized by all of thefollowing buzzwords:

• Simple• Architectureneutral

• Object

oriented

• Portable

• Distributed• High

 performance•

Multithreaded• Robust

• Dynamic • Secure

Each of the preceding buzzwords is explained in The  Java Language Environment , a white paper written by James Gosling and Henry McGilton. In the Java programming language, all source code is firstwritten in plain text files ending with the .javaextension. Those source files are then compiledinto .class files by the javac compiler. A .class filedoes not contain code that is native to your 

 processor; it instead contains bytecodes — themachine language of the Java Virtual Machine1 

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 27/105

(Java VM). The java launcher tool then runs your application with an instance of the Java VirtualMachine.

An overview of the softwaredevelopment process.

Because the Java VM is available on many different

operating systems, the same .class files are capableof running on Microsoft Windows, the Solaris TM

Operating System (Solaris OS), Linux, or Mac OS.Some virtual machines, such as the Java HotSpotvirtual machine, perform additional steps at runtimeto give your application a performance boost. This

include various tasks such as finding performance bottlenecks and recompiling (to native code)frequently used sections of code.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 28/105

Through the Java VM, the same

application is capable of running onmultiple platforms.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 29/105

The Java Platform

A platform is the hardware or software environment

in which a program runs. We've already mentionedsome of the most popular platforms like MicrosoftWindows, Linux, Solaris OS, and Mac OS. Most

 platforms can be described as a combination of theoperating system and underlying hardware. The Java

 platform differs from most other platforms in that it's

a software-only platform that runs on top of other hardware-based platforms.

The Java platform has two components:

• The Java Virtual Machine 

• The Java Application Programming Interface(API)

The general-purpose, high-level Java programminglanguage is a powerful software platform. Every fullimplementation of the Java platform gives you thefollowing features:

• Development Tools: The development tools  provide everything you'll need for compiling,running, monitoring, debugging, anddocumenting your applications. As a newdeveloper, the main tools you'll be using are the

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 30/105

  javac compiler, the java launcher, and the javadoc documentation tool.

• Application Programming Interface (API):The API provides the core functionality of theJava programming language. It offers a widearray of useful classes ready for use in your ownapplications. It spans everything from basicobjects, to networking and security, to XMLgeneration and database access, and more. The

core API is very large; to get an overview of what it contains, consult the Java SE Development Kit 6 (JDK TM 6) documentation.

• Deployment Technologies: The JDK software provides standard mechanisms such as the JavaWeb Start software and Java Plug-In software

for deploying your applications to end users.• User Interface Toolkits: The Swing and Java

2D toolkits make it possible to createsophisticated Graphical User Interfaces (GUIs).

• Integration Libraries: Integration libraries suchas the Java IDL API, TM API, Java Naming and

Directory InterfaceTM ("J.N.D.I.") API, Java RMI,and Java Remote Method Invocation over InternetInter-ORB Protocol Technology (Java RMI-IIOP

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 31/105

Technology) enable database access andmanipulation of remote objects.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 32/105

Why Java's a Better Programming Language

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 33/105

If that were all Java was, it would still be moreinteresting than a <marquee> or <frame> tag in

some new browser beta, but there's a lot more. Java

isn't just for web sites. Java is a programminglanguage that can do almost anything a traditional

 programming language like FORTRAN, Basic or C++ can do. However Java has learned from themistakes of its predecessors. It is considerably easier to program and to learn than those languages without

giving up any of their power.The Java language shares many superficialsimilarities with C, C++, and Objective C. For instance, loops have identical syntax in all four languages, However, Java is not based on any of these languages, nor have efforts been made to make

it compatible with them.Java is sometimes referred to as C++++--. JamesGosling invented Java because C++ provedinadequate for certain tasks. Since Java's designerswere not burdened with compatibility with existinglanguages, they were able to learn from the

experience and mistakes of previous object-orientedlanguages. They added a few things C++ doesn'thave like garbage collection and multithreading (the++) and they threw away C++ features that had

 proven to be better in theory than in practice like

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 34/105

multiple inheritance and operator overloading (the--). A few advanced features like closures and

 parameterized types that the Java team liked were

nonetheless left out of the language due to timeconstraints. There's still argument over whether theright choices were made. Parameterized types(templates to C++ programmers) may be added in alater revision of Java.

Java has learned a lot from previous languages. Let's

look at some of the advantages Java offers programmers.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 35/105

Java is Simple

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 36/105

Java was designed to make it much easier to write bug free code. According to Sun's Bill Joy, shippingC code has, on average, one bug per 55 lines of 

code. The most important part of helping programmers write bug-free code is keeping thelanguage simple.

Java has the bare bones functionality needed toimplement its rich feature set. It does not add lots of syntactic sugar or unnecessary features. The

language specification for Java is only about eighty pages long compared to a couple of hundred pagesfor C and even more for C++. Despite its simplicityJava has considerably more functionality than C.

Because Java is simple, it is easy to read and write.Obfuscated Java isn't nearly as common as

obfuscated C. There aren't a lot of special cases or tricks that will confuse beginners.

About half of the bugs in C and C++ programs arerelated to memory allocation and deallocation.Therefore the second important addition Java makesto providing bug-free code is automatic memory

allocation and deallocation. The C library memoryallocation functions malloc() and free() are

gone as are C++'s destructors.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 37/105

Java is an excellent teaching language, and anexcellent choice with which to learn programming.The language is small so it's easy to become fluent

in it. The language is interpreted so the compile-link-run cycle is much shorter. (In fact, the link 

 phase is eliminated entirely.) The runtimeenvironment provides automatic memory allocationand garbage collection so there's less for the

 programmer to think about. Java is object-oriented

(unlike Basic) so the beginning programmer doesn'thave to unlearn bad programming habits whenmoving into real world projects. Finally, it's verydifficult (if not quite impossible) to write a Java

 program that will crash your system, something thatyou can't say about any other language.

Java is Object-Oriented

Object oriented programming was the catch phrase

of computer programming in the 1990's. Althoughobject oriented programming has been around in oneform or another since the Simula language wasinvented in the 1960's, it really took hold in modernGUI environments like Windows, Motif and the

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 38/105

Mac. In object-oriented programs data is represented by objects. Objects have two sections, fields(instance variables) and methods. Fields tell you

what an object is. Methods tell you what an objectdoes. These fields and methods are closely tied tothe object's real world characteristics and behavior.When a program runs messages are passed back andforth between objects. When an object receives amessage, it responds accordingly as defined by its

methods.Object oriented programming is alleged to have anumber of advantages including:

• Simpler, easier to read programs

• More efficient reuse of code

• Faster time to market

• More robust, error-free code

In practice object-oriented programs have been justas slow, expensive and buggy as traditional non-object-oriented programs. In large part this is

 because the most popular object-oriented language is

C++. C++ is a complex, difficult language thatshares all the obfuscation of C while sharing none of C's efficiencies. It is possible in practice to writeclean, easy-to-read Java code. In C++ this is almostunheard of outside of programming textbooks.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 39/105

Java is Platform Independent

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 40/105

Java was designed to not only be cross-platform insource form like C, but also in compiled binaryform. Since this is frankly impossible across

 processor architectures, Java is compiled to anintermediate form called byte-code.

A Java program never really executes natively on thehost machine. Rather a special native program calledthe Java interpreter reads the byte code and executesthe corresponding native machine instructions. Thus

to port Java programs to a new platform, all youneed to do is run it with an interpreter written for thenew platform. You don't even need to recompile.Even the compiler is written in Java. The byte codesare precisely defined, and remain the same on all

 platforms.

The second important part of Java's cross-platformsavvy is the elimination of undefined andarchitecture dependent constructs. Integers arealways four bytes long, and floating point variablesfollow the IEEE 754 standard for computer arithmetic exactly. You don't have to worry that the

meaning of an integer is going to change if youmove from a Pentium to a PowerPC. In Javaeverything is guaranteed.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 41/105

However the virtual machine itself and some parts of the class library must be written in native code.These are not always as easy or as quick to port as

 pure Java programs. This is why for example, there'snot yet a version of Java 1.2 for the Mac.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 42/105

Java is Safe

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 43/105

Java was designed from the ground up to allow for secure execution of code across a network, evenwhen the source of that code was untrusted and

 possibly malicious.

This required the elimination of many features of Cand C++. Most notably there are no pointers in Java.Java programs cannot access arbitrary addresses inmemory. All memory access is handled behind thescenes by the (presumably) trusted runtime

environment. Furthermore Java has strong typing.Variables must be declared, and variables do notchange types when you aren't looking. Casts arestrictly limited to casts between types that makesense. Thus you can cast an int to a long or a

byte to a short but not a long to a Boolean or 

an int to a String.Java implements a robust exception handlingmechanism to deal with both expected andunexpected errors. The worst that a Java programcan do to a host system is bringing down the runtimeenvironment. It cannot bring down the entire system.

Most importantly Java applets can be executed in anenvironment that prohibits them from introducingviruses, deleting or modifying files, or otherwisedestroying data and crashing the host computer. A

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 44/105

Java enabled web browser checks the byte codes of an applet to verify that it doesn't do anything nasty

 before it will run the applet.

However the biggest security problem is not hackers.It's not viruses. It's not Visual Basic wormstransmitted by Outlook Express. It's not eveninsiders erasing their hard drives and quitting your company to go to work for your competitors. No, the

 biggest security issue in computing today is bugs.

Regular, ordinary, non-malicious, unintended bugsare responsible for more data loss and lost

 productivity than all other factors combined. Java, by making it easier to write bug-free code,substantially improves the security of all kinds of 

 programs.

Java is High Performance

Java byte codes can be compiled on the fly to codethat rivals C++ in speed using a "just-in-time

compiler." Several companies are also working onnative-machine-architecture compilers for Java.These will produce executable code that does notrequire a separate interpreter, and that is

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 45/105

indistinguishable in speed from C++. While you'llnever get that last ounce of speed out of a Java

 program that you might be able to wring from C or 

FORTRAN, the results will be suitable for all butthe most demanding applications.

As of May, 1999, the fastest VM, IBM's Java 1.1VM for Windows, is very close to C++ on CPU-intensive operations that don't involve a lot of disk I/O or GUI work; C++ is itself only a few percent

slower than C or FORTRAN on CPU intensiveoperations.

It is certainly possible to write large programs inJava. The Hot Java web browser, the JBuilder integrated development environment and the javaccompiler are large programs that are written entirely

in Java.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 46/105

Java is Multi-Threaded

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 47/105

Java is inherently multi-threaded. A single Java program can have many different processesexecuting independently and continuously. Three

Java applets on the same page can runsimultaneously with each getting equal time fromthe CPU with very little extra effort on the part of the programmer. This makes Java incrediblyresponsive to user input. It also helps to contribute toJava's robustness and provides a mechanism

whereby the Java environment can ensure that amalicious applet doesn't steal all of the host's CPUcycles.

Unfortunately multithreading is so tightly integratedwith Java, that it makes Java rather difficult to portto architectures like Windows 3.1 or the PowerMac

that don't natively support preemptive multi-threading.

There is another cost associated with multi-threading. Multi-threading is to Java what pointer arithmetic is to C; that is, a source of devilishly hardto find bugs. Nonetheless, in simple programs it's

 possible to leave multi-threading alone and normally be OK.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 48/105

Java is Dynamica ly linked)

Java does not have an explicit link phase. Javasource code is divided into .java files, roughly one

 per each class in your program. The compiler compiles these into .class files containing byte code.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 49/105

Each .java file generally produces exactly one .classfile. (There are a few exceptions we'll discuss later,non-public classes and inner classes).

The compiler searches the current directory and afew other well specified places to find other classesexplicitly referenced by name in each source codefile. If the file you're compiling depends on other,non-compiled files, then the compiler will try to findthem and compile them as well. The Java compiler is

quite smart, and can handle circular dependencies aswell as methods that are used before they'redeclared. It also can determine whether a sourcecode file has changed since the last time it wascompiled.

More importantly, classes that were unknown to a

 program when it was compiled can still be loadedinto it at runtime. For example, a web browser canload applets of differing classes that it's never seen

 before without recompilation.

Furthermore, Java .class files tend to be quite small,a few kilobytes at most. It is not necessary to link in

large runtime libraries to produce an executable.Instead the necessary classes are loaded from theuser's local system.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 50/105

Java is Garbage CollectedYou do not need to explicitly allocate or deallocatememory in Java. Memory is allocated as needed,

 both on the stack and the heap, and reclaimed by thegarbage collector when it is no longer needed. Thereare no malloc(), free(), or destructor methods.

There are constructors and these do allocate memoryon the heap, but this is transparent to the

 programmer.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 51/105

Most Java virtual machines use an inefficient, mark and sweep garbage collector. Some more recentvirtual machines have improved matters quite a bit

 by using generational garbage collection.

To sum up, Java is a safe, robust, garbage-collected,object-oriented, high-performance, multi-threaded,interpreted, architecture-neutral, cross-platform,

 buzzword-compliant programming language.

AWT

The Abstract Window Toolkit (AWT) packageenables you to create GUIs in your applets andapplications. Different Windows API from different

 platforms were looked at and components wereidentified that were common to all of them. TheAWT API communicates with the platform's nativeAPI's as to give your application the native look andfeel. Because they associate with their own native

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 52/105

screen resources, AWT components are calledheavyweight components. Swing components do notassociate with native resources and are called

lightweight components. The AWT consists of components, both container and non-container ones(eg. Button, Checkbox, Choice, ...) Container components (eg. Frame, Dialog, Window, Panel)control the layout of other components. Ascontainers are themselves components, they can be

 placed inside other containers. Check out these linksand subcategories on how to create and work withthese containers and components.

Subcategories

• Button• Canvas

• Checkbox andRadioButton

• Choice

• Color 

• Data Transfer (java.awt.datatransfer.*)

• Dialog

• Insets• Input Method

Framework 

• Label

• LayoutManagers

• List

• Menu,MenuItem

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 53/105

• Drag and Drop(java.awt.dnd.*)

Event• Font

• Frame

• Graphics

• Robot

• Scrollbar 

• ScrollPane• Textfield,

TextArea

• Toolkit

Swing 

Swing is not an acronym. It packages a set of GUIcomponents. Unlike AWT components, that areassociated to native screen resources (heavyweight),Swing components draw themselves on the screen(lightweight). This results in slower execution but aSwing application will look the same on all

 platforms. Because Swing supports pluggable look-and-feel, you could have a Windows look in your Unix environment (if you would ever want that).Check out the numerous subcategories for codeexamples for each component!

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 54/105

Subcategories

•  javax.swing.border.*

•  javax.swing.text.*

•  javax.swing.undo.*

• JComponent

• Top-Level Containers

(JApplet, JDialog,JOptionPane, JFrame)

• General-PurposeContainers (JPanel,JScrollPane,JSplitPane,

JTabbedPane,JToolBar)

• Special-PurposeContainers (JDesktop,JInternalFrame,JLayeredPane,

JRootPane)

• Atomic Controls(JButton,JCheckBox,JRadioButton,JComboBox,JList, JMenu,

JSlider,JTextField)

• UneditableAtomic Controls(JLabel,JProgressBar,

JToolTip)• Editable Atomic

Controls(JColorChooser,JFileChooser,JTable,

JTextArea,JEditorPane,JTree)

• HTMLEditorKit

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 55/105

• RTFEditorKit

• Swing Events

• Swing Look andFeel

FEATURES OF JAVA

• Secure

• Portable

• Object-oriented

• Robust

• Multithread

• Architectural neutral

• 

Interpreted

• High-performance

• Distributed

• Dynamic language

Simple

Java was designed to be easy for professional programmers to learn and use effectively. Because

Java inherits the C/C++ syntax and many of the object-oriented features of C++, most

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 56/105

 programmers have little trouble learning Java. Also some of the more confusing features of C++

are either left out in Java or implemented in an cleaner, more approachable manner.

Secure

Whenever we download a program on our computers from Internet we expose our system to

viral infections. Prior to Java people did not frequently download executable programs from the

Internet and if they did so scanned their computers for possible viral infections. Apart from

viruses another type of malicious program that might be downloaded from the Internet may

collect private information like passwords or other personal information by reaching the local

file systems of the computer. Java answers both these concerns  by providing a firewall between

a networked program and your  computer. Java  provides this protection by limiting its

applications to Java run time environment and not allowing it to access other parts of the

computer .

Portable

Since there are many different kind of computers and operating systems connected to the Internet

around the world it is absolutely necessary that applications available on the Internet are

executable on these configurations. The ability of Java to provide platform independent

applications greatly solves this problem, thus making Java programs portable.

Object-Oriented

Java is an Object-Oriented programming language. The object-oriented feature of Java is not

optional as in case of C++. Though most of the object-Oriented features of Java are derived from

C++ but they are more strictly implemented in Java as compared to C++.

Robust

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 57/105

The multiplatformed environment of the Internet places extraordinary demand on a  program,

 because the program must run reliably on a variety of systems. Thus the ability to create robust

 programs was given a high priority in the design of the Java.

Multithreaded

Java supports multithreaded programming, which allow you to write programs that do many

things simultaneously. The Java run time system comes with an elegant and sophisticated

solution for multiprocess synchronization.

Architecture-Neutral

The main objective in the designing of Java was to create architecture-neutral programs. The

designers wanted to create programs that are written once and could be executed anytime,

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 58/105

anywhere. To achieve this objective the designers had to take many hard decisions in the design

of Java language and Java Virtual Machine.

Interpreted and High Performance

Java enables to create cross-platform programs by compiling into an intermediate code called

Java Byte code. This code can be interpreted on any machine that provides Java Virtual

Machine.

Distributed

Java is designed for the distributed environment of the Internet. The Java was developed to

handle the environments of the Internet in an elegant and efficient manner.

Dynamic

Java programs carry with them substantial amount of run –time type information that is used to

verify and resolve access to objects at run time. This makes it possible to dynamically link code

in a safe and expedient manner.

Object-Oriented Features Of Java

Encapsulation

Encapsulation is the mechanism that binds together code and the data it manipulates, and keeps

 both safe from outside interface and misuse. One way to think about encapsulation is as 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 the wrapper is tightly controlled

through a well-defined interface.

Inheritance

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.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 59/105

Polymorphism

Polymorphism is a feature that allows one interface to be used for general class of actions. The

specific action is determined by the exact nature of the situation. More generally, the concept of 

 polymorphism is often expressed by the phrase ”one interface, multiple methods.” This means

that it is possible to design a generic interface to a group of related activities.

What Makes Java Different From Other Languages?

Most of the computer languages either compiled or interpreted, however Java differs from other 

computer languages in the manner that Java programs are both compiled and interpreted before

execution. The Java programs are first compiled and converted into an intermediate code called

Java Byte Code. This Byte code is then interpreted to generate the final executable code.

 

This process of converting Java into an intermediate code before execution helps in making Java

 platform independent since any machine having Java Virtual Machine can interpret and execute

this Java Byte Code.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 60/105

 Java Bytecode

Bytecode is a highly optimized set of instructions designed to be executed by the Java run-time

system, which is called the Java Virtual Machine. That is in its standard form Java Virtual

Machine is an interpreter for Bytecode. Translating Java programs into Bytecode helps make it

mush easier to run a program in a wide variety of environments. This is due to the fact that to run

a Java program on any platform we only need to implement the Java Virtual Machine. So once

Java run time package exists for a given system any Java program can run on it. The fact that a

Java program is interpreted also help to make it secure. Because the execution of ever Java

 program is under JVM, the JVM can contain the program and prevent its side effects outside the

system. Thus Java Bytecode makes Java both Secure and Portable.

 Difference Between Java And C 

• There are no header files in java.

• Java does not include the C’s unique statement keywords goto, size of, and typedef.

• Java does not contain the data types struct, union and enum.

• Java does not support an explicit pointer type.

• Java does not define the type modifiers keywords auto, extern, register, signed and unsigned.

 Difference Between Java And C++

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 61/105

• Java does not support operator overloading.

• Java does not have template classes as in C++.

• There are no header files in java.

• Java does not use pointers.

• Java does not support global variables, every variable and method is declared within a class and

forms part of that class.

What Makes Java Important For The Internet?

The Internet helped catapult Java to the forefront of programming and in return Java has had a

 profound effect on the Internet. The reason for this is quite simple: Java expands the universe of 

the objects that can move freely in the cyberspace. Since one of the basic requirements of the

Internet is platform independent programs and Java enables in creation of such programs so Java

 becomes an obvious choice for writing applications for the web. Apart from platform programs

Java applications also provide a sense of security, since Java programs are strictly confined in the

Java run time environment so they have a little chance of causing any adverse side effect on the

system. This ability of Java to provide portable and secure programs are its two traits that make it

of great importance to the Internet.

Two Types Of Programs In Java

Java is used to create two types of programs Application and Applets. An application is a

 program that runs on your computer under the operating system of that computer. Thus an

application created in Java is more or less like a program created in C or C++. When used to

create applications Java is not much different from any other languages. However it the ability of 

Java to create applets that make it really important. An applet is an application to designed to be

transmitted on the Internet and executed by the Java compatible web browser. An applet is an

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 62/105

intelligent program that reacts to the user  input and not running the same animation or sound

over and over.

How to run a java program on the system?

To run the Java program, the Java development environment is required.

Example: J2SE 5 developer’s kit (JDK 5) given by Sun Microsystems. It is a current product.

The current version of Java is J2SE 5 (Java 2 platform standard edition). It has features of 

earlier editions like Java 1.0, Java 1.1 etc plus some new features

Implementing Java Programs

Following are the steps in creating Java Applications:

Programs are written in any text editor.

Example:

 public class HelloWorldApp

{

 public static void main(String[] args)

{

// Display "Hello World!"

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 63/105

System.out.println("Hello World!");

}

}

Save Program as <class name>.java this file is called Source File.

Use compiler (javac) to compile the program

 javac <filename>.java. This creates a file called test class named <filename>.class.

To run program use interpreter (java)

 java <filename>

Following are the steps in creating Java Applets:

Programs are written in any text editor.

Example:

 public class HelloWorld extends Applet

{

public void paint(Graphics g)

{

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 64/105

// Display "Hello World!"

g.drawString("Hello world!", 50, 25);

}

}

2) Use compiler (javac) to compile the program

 javac <filename>.java. This creates a file called test class named <filename>.class.

3) Run the program.

 Although you can view your applets using a Web browser, you may find it easier to test your 

applets using the simple appletviewer application that comes with the JavaTM Platform. To view

the HelloWorld applet using appletviewer, enter at the  prompt:

appletviewer Hello.html

 Now you should see:

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 65/105

Basics Of Java Programming Language

Data Types

Every variable must have a data type. A variable's data type determines the values that the

variable can contain and the operations that can be performed on it. The Java programming

language has two categories of data types: primitive and reference.

The following table lists, by keyword, all of the primitive data types supported by the Java

 platform, their sizes and formats, and a brief description of each.

Primitive Data Type

Keyword Description Size/Format

(integers)

Byte Byte-length integer 8-bit two's complement

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 66/105

Short Short integer 16-bit two's complement

Int Integer 32-bit two's complement

Long Long integer 64-bit two's complement

(real numbers)

Float Single-precision floating point 32-bit IEEE 754

Double Double-precision floating point 64-bit IEEE 754

(other types)

Char A single character 16-bit Unicode character  

BooleanA boolean value (true or 

false)true or false

Operators

An operator performs a function on one, two, or three operands. An operator that requires one

operand is called a unary operator. For example, ++ is a unary operator that increments the valueof its operand by 1. An operator that requires two operands is a binary operator. For example, =

is a binary operator that assigns the value from its right-hand operand to its left-hand operand.

And finally, a ternary operator is one that requires three operands. The Java programming

language has one ternary operator, ?:, which is a shorthand if-else statement.

The unary operators support either prefix or postfix notation. Prefix notation means that

the operator appears before its operand:

operator op //prefix notation

Postfix notation means that the operator appears after  its operand:

op operator //postfix notation

All the binary operators use infix notation, which means that the operator appears

 between its operands:

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 67/105

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 68/105

Relational and Conditional Operators

Operator Use Description

>  op1 > op2 Returns true if op1 is greater than op2 

>=  op1 >= op2 Returns true if  op1 is greater than or 

equal to op2 

<  op1 < op2 Returns true if op1 is less than op2 

<=  op1 <= op2Returns true if op1 is less than or equal to

op2 

==  op1 == op2 Returns true if op1 and op2 are equal

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 69/105

Shift and Logical Operators

A shift operator performs bit manipulation on data by shifting the bits of its first operand

right or left. The next table summarizes the shift operators available in the Java

 programming language.

 SHIFT OPERATORS 

 Assignment Operators 

Control Flow Statements

When you write a program, you type statements into a file. Without control flow statements, the

interpreter executes these statements in the order they appear in the file from left to right, top to

 bottom. You can use control flow statements in your programs to conditionally execute

Operator Use Description

<<  op1 << op2 Shift bits of  op1 left by distance op2;

fills with zero bits on the right-hand side

>>  op1 >> op2 

Shift bits of op1 right by distance op2;

fills with highest (sign) bit on the left-

hand side

>>>  op1 >>> op2 Shift bits of op1 right by distance op2;

fills with zero bits on the left-hand side

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 70/105

statements, to repeatedly execute a block of statements, and to otherwise change the normal,

sequential flow of control.

The Java programming language provides several control flow statements, which are listed in the

following table.

Exception Handling Statements

It determines that the error is unrecoverable, provide a gentle exit The Java programming

language provides a mechanism known as exceptions to help programs report and handle errors.

When an error occurs, the program throws an exception. What does this mean? It means that the

normal flow of the program is interrupted and that the runtime environment attempts to find an

exception handler—a block of code that can handle a particular type of error. The exception

handler can attempt to recover from the error or, if  from the program.

Three statements play a part in handling exceptions:

Statement Type Keyword

looping while, do-while, for 

decision making if-else, switch-case 

exception handling try-catch-finally, throw 

 branching break, continue, label:, return

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 71/105

The try statement identifies a block of statements within which an exception might be

thrown.

The catch statement must be associated with a try statement and identifies a block of 

statements that can handle a particular type of exception. The statements are executed if 

an exception of a particular type occurs within the try block.

The finally statement must be associated with a try statement and identifies a block of 

statements that are executed regardless of whether or not an error occurs within the try

 block.

Here's the general form of these statements:

try {

statement(s)

}

catch (exceptiontype name)

{

statement(s)

}

Finally

{

statement(s)

}

Multithreaded Programming

What is a Thread?

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 72/105

A thread is similar to the sequential programs described previously. A single thread also

has a beginning, a sequence, and an end. At any given time during the runtime of the

thread, there is a single point of execution. However, a thread itself is not a program; a

thread cannot run on its own. Rather, it runs within a program.

The following figure shows this relationship.

The real excitement surrounding threads is not about a single sequential thread. Rather,

it’s about the use of multiple threads running at the same time and performing different

tasks in a single program. This use is illustrated in the next figure.

A Web browser is an example of a multithreaded application. Within a typical browser, you canscroll a page while it’s downloading an applet or an image, play animation and sound

concurrently, print a page in the background while you download a new page, or watch three

sorting algorithms race to the finish.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 73/105

Java enables us to create multithreaded applications i.e. java enables us in creating

applications that can perform many tasks one time. The thread follows various steps during its

execution. These steps are called as life cycle of Java.

The Life Cycle of a Thread

The following figure shows the states that a thread can be in during its life and illustrate which

method calls cause a transition to another state.

Interfaces

In general, an interface is a device or a system that unrelated  entities use to interact. According

to this definition, a remote control is an interface between you and a television set, the English

language is an interface between two people, and the protocol of behavior enforced in the

military is the interface between people of different ranks. Within the Java programming

language, an interface is a type, just as a class is a type. Like a class, an interface defines

methods. Unlike a class, an interface never implements methods; instead, classes that implement

the interface implement the methods defined by the interface. A class can implement multiple

interfaces.

You use an interface to define a protocol of behavior that can be implemented by any

class anywhere in the class hierarchy. Interfaces are useful for the following:

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 74/105

1) Capturing similarities among unrelated classes without artificially forcing a class

relationship.

2) Declaring methods that one or more classes are expected to implement.

Revealing an object's programming interface without revealing its class.

Modelling multiple inheritance, a feature that some object-oriented languages support

that allows a class to have more than one super class.

Packages

To make types easier to find and to use, to avoid naming conflicts, and to control access,

 programmers bundle groups of related types into packages. A package is a collection of related

types providing access protection and namespace management. Note that types refer to classes,

interfaces, enums and annotations. The types that are part of the Java platform are members of 

various packages that bundle classes by function: fundamental classes are in java.lang, classes

for reading and writing (input and output) are in java.io, and so on. You can put your types in

 packages, too.

You should bundle these classes and the interface in a package for several reasons:

You and other programmers can easily determine that these types are related.

You and other programmers know where to find types that provide graphics-related

functions.

The names of your types won't conflict with types names in other packages, because the

 package creates a new namespace.

You can allow types within the package to have unrestricted access to one another yet

still restrict access for types outside the package.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 75/105

Various Java packages

1 java.lang 

2 java.util 

3 java.applet 

4 java.io

5 java.net  

6 java.awt  

 

GUI and Event handling:-

Frames

/*

* GUIFrame

* An extension of Frame that uses a WindowAdapter to

* handle the WindowEvents and is centered.

*/

import java.awt.*;

import java.awt.event.*;

 public class GUIFrame extends Frame {

 public GUIFrame(String title) {

super(title);

setBackground(SystemColor.control);

addWindowListener(new WindowAdapter() {

//only need to override the method needed

 public void windowClosing(WindowEvent e) {

dispose();

System.exit(0);

}

});

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 76/105

}

/* Centers the Frame when setVisible(true) is called */

 public void setVisible(boolean visible) {

if (visible) {

Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

setLocation((d.width - getWidth())/2,

(d.height - getHeight())/2);

}

super.setVisible(visible);

}

}

Event handling

Button button;

int count;

Label clicksLabel;

 public ButtonEventTest() {

super("Button Event Test");

 button = new Button("Button");

 button.addActionListener(this);

add(button, BorderLayout.CENTER);

count = 0;

clicksLabel = new Label();

updateLabel();

add(clicksLabel, BorderLayout.SOUTH);

setSize(200, 200);

setVisible(true);

}

TEAM LinG - Live, Informative, Non-cost and Genuine!

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 77/105

 public static void main(String args[]) {

new ButtonEventTest();

}

 private void updateLabel() {

String text = "Number of times clicked: ";

clicksLabel.setText(text + String.valueOf(count));

}

 public void actionPerformed(ActionEvent e) {

count++;

updateLabel();

}

}

The Java Platform

A platform is the hardware or software environment in which a program runs. We've already

mentioned some of the most popular platforms like Windows 2000, Linux, Solaris, and MacOS.

Most platforms can be described as a combination of the operating system and hardware. The

Java platform differs from most other platforms in that it's a software-only platform that runs on

top of other hardware-based platforms.

The Java platform has two components:

• The Java Virtual Machine (Java VM)

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 78/105

• The Java Application Programming Interface (Java API)

The Java API is a large collection of ready-made software components that provide many useful

capabilities, such as graphical user interface (GUI) widgets. The Java API is grouped into

libraries of related classes and interfaces; these libraries are known as packages.

 Native code is code that after you compile it, the compiled code runs on a specific hardware

 platform. As a platform-independent environment, the Java platform can be a bit slower than

native code. However, smart compilers, well-tuned interpreters, and just-in-time bytecode

compilers can bring performance close to that of native code without threatening portability. The

Java compiler allows you to cascade references to class and instance methods and variables

together, resulting in constructs like the one that appears in the sample program.

Inheritance 

Generally speaking, objects are defined in terms of classes. You know a lot about an object by

knowing its class. Even if you don't know what a penny-farthing is, if I told you it was a bicycle,

you would know that it had two wheels, handle bars, and pedals.

Object-oriented systems take this a step further and allow classes to be defined in terms of other 

classes. For example, mountain bikes, racing bikes, and tandems are all kinds of bicycles. In

object-oriented terminology, mountain bikes, racing bikes, and tandems are all  subclasses of the

 bicycle class. Similarly, the bicycle class is the superclass of mountain bikes, racing bikes, andtandems.

This relationship is shown in the following figure.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 79/105

   Relationship Object Oriented 

Each subclass inherits state (in the form of variable declarations) from the superclass. Mountain

 bikes, racing bikes, and tandems share some states: cadence, speed, and the like. Also, each

subclass inherits methods from the superclass. Mountain bikes, racing bikes, and tandems share

some behaviors: braking and changing pedaling speed, for example.

However, subclasses are not limited to the state and behaviors provided to them by their 

superclass. Subclasses can add variables and methods to the ones they inherit from the

superclass. Tandem bicycles have two seats and two sets of handle bars; some mountain bikes

have an extra set of gears with a lower gear ratio.

Subclasses can also override inherited methods and provide specialized implementations for 

those methods. For example, if you had a mountain bike with an extra set of gears, you would

override the "change gears" method so that the rider could use those new gears.

You are not limited to just one layer of inheritance. The inheritance tree, or class hierarchy, can

 be as deep as needed. Methods and variables are inherited down through the levels. In general,

the farther down in the hierarchy a class appears, the more specialized its behavior.

The Object class is at the top of class hierarchy, and each class is its descendant (directly or 

indirectly). A variable of type Object can hold a reference to any object, such as an instance of a

class or an array. Object provides behaviors that are required of all objects running in the Java

Virtual Machine. For example, all classes inherit Object's to String method, which returns a

string representation of the object.

Inheritance offers the following benefits:

• Subclasses provide specialized behaviors from the basis of common elements provided

 by the superclass. Through the use of inheritance, programmers can reuse the code in the

superclass many times.

• Programmers can implement superclasses called  abstract classes that define "generic"

 behaviors. The abstract superclass defines and may partially implement the behavior, but

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 80/105

much of the class is undefined and unimplemented. Other programmers fill in the details

with specialized subclasses

InterfaceIn English, an interface is a device or a system that unrelated entities use to interact. According

to this definition, a remote control is an interface between you and a television set, the English

language is an interface between two people, and the protocol of behavior enforced in the

military is the interface between people of different ranks. Within the Java programming

language, an interface is a device that unrelated objects use to interact with each other. An

interface is probably most analogous to a protocol (an agreed on behavior). In fact, other object-

oriented languages have the functionality of interfaces, but they call their interfaces protocols.

The bicycle class and its class hierarchy defines what a bicycle can and cannot do in terms of its

"bicycleness." But bicycles interact with the world on other terms. For example, a bicycle in a

store could be managed by an inventory program. An inventory program doesn't care what class

of items it manages as long as each item provides certain information, such as price and tracking

number. Instead of forcing class relationships on otherwise unrelated items, the inventory

 program sets up a protocol of communication. This protocol comes in the form of a set of 

constant and method definitions contained within an interface. The inventory interface would

define, but not implement, methods that set and get the retail price, assign a tracking number, andso on.

To work in the inventory program, the bicycle class must agree to this protocol by implementing

the interface. When a class implements an interface, the class agrees to implement all the

methods defined in the interface. Thus, the bicycle class would provide the implementations for 

the methods that set and get retail price, assign a tracking number, and so on.

You use an interface to define a protocol of behavior that can be implemented by any class

anywhere in the class hierarchy. Interfaces are useful for the following:

• Capturing similarities among unrelated classes without artificially forcing a class

relationship.

• Declaring methods that one or more classes are expected to implement.

• Revealing an object's programming interface without revealing its class.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 81/105

Object

Objects are key to understanding object-oriented technology. You can look around you now and

see many examples of real-world objects: your dog, your desk, your television set, your bicycle.

These real-world objects share two characteristics: They all have  state and behavior . For 

example, dogs have state (name, color, breed, hunger) and behavior (barking, fetching, and

wagging tail). Bicycles have state (current gear, current pedal cadence, two wheels, number of 

gears) and behavior (braking, accelerating, slowing down, changing gears). Software objects are

modeled after real-world objects in that they too have state and behavior. A software object

maintains its state in one or more variables. A variable is an item of data named by an identifier.

A software object implements its behavior with methods. A method is a function (subroutine)

associated with an object.

Definition: An object is a software bundle of variables and related methods.

You can represent real-world objects by using software objects. You might want to represent

real-world dogs as software objects in an animation program or a real-world bicycle as software

object in the program that controls an electronic exercise bike. You can also use software objects

to model abstract concepts. For example, an event  is a common object used in GUI window

systems to represent the action of a user pressing a mouse button or a key on the keyboard.

The following illustration is a common visual representation of a software object:

Visual Representation of software object 

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 82/105

Everything that the software object knows (state) and can do (behavior) is expressed by the

variables and the methods within that object. A software object that modeled your real-world

 bicycle would have variables that indicated the bicycle's current state: its speed is 10 mph, its

 pedal cadence is 90 rpm, and its current gear is the 5th gear. These variables are formally known

as instance variables because they contain the state for a particular bicycle object, and in object-

oriented terminology, a particular object is called an instance.

 Bicycle modeled as a software object 

In addition to its variables, the software bicycle would also have methods to brake, change the

 pedal cadence, and change gears. (The bike would not have a method for changing the speed of 

the bicycle, as the bike's speed is just a side effect of what gear it's in, how fast the rider is

 pedaling, whether the brakes are on, and how steep the hill is.) These methods are formally

known as  instance methods because they inspect or change the state of a particular bicycle

instance.

The object diagrams show that the object's variables make up the center, or nucleus, of the

object. Methods surround and hide the object's nucleus from other objects in the program.

Packaging an object's variables within the protective custody of its methods is calledencapsulation  this conceptual picture of an object-a nucleus of variables packaged within a

 protective membrane of methods-is an ideal representation of an object and is the ideal that

designers of object-oriented systems strive for. However, it's not the whole story. Often, for 

  practical reasons, an object may wish to expose some of its variables or hide some of its

methods. In the Java programming language, an object can specify one of four access levels for 

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 83/105

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 84/105

 

Class Implementation

 

Objects vs. Classes

You probably noticed that the illustrations of objects and classes look very similar. And indeed,

the difference between classes and objects is often the source of some confusion. In the real

world, it's obvious that classes are not themselves the objects they describe: A blueprint of a

 bicycle is not a bicycle. However, it's a little more difficult to differentiate classes and objects insoftware. This is partially because software objects are merely electronic models of real-world

objects or abstract concepts in the first place. But it's also because the term "object" is sometimes

used to refer to both classes and instances.

In the figures, the class is not shaded, because it represents a blueprint of an object rather than an

object itself. In comparison, an object is shaded, indicating that the object exists and that you can

use it.

Message

A single object alone is generally not very useful. Instead, an object usually appears as a

component of a larger program or application that contains many other objects. Through the

interaction of these objects, programmers achieve higher-order functionality and more complex

 behavior. Your bicycle hanging from a hook in the garage is just a bunch of titanium alloy and

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 85/105

rubber; by itself, the bicycle is incapable of any activity. The bicycle is useful only when another 

object (you) interacts with it (pedal).

Software objects interact and communicate with each other by sending messages to each other.

When object A wants object B to perform one of B's methods, object A sends a message to

object B

 Sending of message between objects

Sometimes, the receiving object needs more information so that it knows exactly what to do; for 

example, when you want to change gears on your bicycle, you have to indicate which gear you

want. This information is passed along with the message as parameters.

The next figure shows the three components that comprise a message:

1. The object to which the message is addressed (Your Bicycle)

2. The name of the method to perform (change Gears)

3. Any parameters needed by the method (lower Gear)

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 86/105

 

Components of a message

These three components are enough information for the receiving object to perform the desired

method. No other information or context is required.

Messages provide two important benefits.

• An object's behavior is expressed through its methods, so (aside from direct variable

access) message passing supports all possible interactions between objects.

Objects don't need to be in the same process or even on the same machine to send and receive

messages back and forth to each other.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 87/105

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 88/105

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 89/105

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 90/105

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 91/105

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 92/105

SYSTEM DEVELOPMENT LIFE CYCLE 

Software development life cycle (SDLC) as name suggests is a set of some pre specified steps

that are followed while software development and it consists of some phases that are followed

and they are as follows:-

Fig. software development phases/steps

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 93/105

Steps of SDLC are:-

1) ANALYSIS:- At this stage we analyze the problem for which we are developing the

software and try to see all the requirements that we will have to satisfy in order to reach a to a

understanding of the scope of the software that is under production. This gives us the view of 

what are the things to be kept in mind while programming so that we have an actual idea of 

what the user desires from the software and what else can be done to make it better and

 provide it a more comfortable environment for the user.

2) DESIGN :- Now, in this step we design the outlook of the software that how it will appear 

like the frames that will be seen by the user. We can say that we basically make a interface

 between the user and the coding that makes it easier for the user to work using the program

without having the burden to face the codes and be scared.

This phase is also a step of decision making where we decide the features we will have in

our software and make its design to have a idea how the software will work and proceed.

3) IMPLEMENTATION :- In this step we have the base of the software. Here we do the

coding now in this step its very essential to be very logical cover up any exceptions and any

error that might come up. By now we have a clear view of what we want the software to do

and how it should look so we start with the coding to make that design come together into a

single working collection of programs we call software.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 94/105

Fig. waterfall model (a methodology of software development)

4) TESTING/VERIFICATION:-  Now as the name suggests this step is the verification of 

whatever we have done yet to see if everything is working fine and for this we do testing

where we use test suite to see how our software reacts to situations quite similar to practical

scenarios. Test suite is a collection of test cases focusing on different sections of software.

Test cases are actually the values or conditions which are used to test the critical areas or 

 break points of software to see if those critical codes or sections cause any error or give

expected values. Here we make list of test cases and their theoretical answers that we expect

the software to show then we see the actual values and then see what can be done to remove

the difference between the expected and actual values.

5) MAINTANENCE:-This is the last step where we actually take care of the installation and

acceptance of the software, this is very important that the software is satisfying all the test

cases prerequisite to acceptance of software by customer. So this step basically includes theacceptance by customer and then installation of software to the customer’s server or system

and then any suitable promise or agreement or maintenance for a specific time period that

was promised before.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 95/105

So as explained above software development life cycle (SDLC) is a complete life-cycle of 

software from an idea in someone’s mind to fully-fledged software making lives easier and it has

many forms and methodology like ITERATION MODEL, WATERFALL MODEL and so on.

System/Information Engineering and Modeling

As software is always of a large system (or business), work begins by establishing the

requirements for all system elements and then allocating some subset of these requirements to

software. This system view is essential when the software must interface with other elements

such as hardware, people and other resources. System is the basic and very critical requirement

for the existence of software in any entity. So if the system is not in place, the system should be

engineered and put in place. In some cases, to extract the maximum output, the system should

 be re-engineered and spruced up. Once the ideal system is engineered or tuned, the development

team studies the software requirement for the system.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 96/105

In case of our project we studied many existing file transfer systems and were ultimately able to

design our project ‘ONLINE TEST’which includes features like: Encryption during file transfer,

user authentication and security while file transfer.

Software Requirement Analysis

This process is also known as feasibility study. In this phase, the development team visits the

customer and studies their system. They investigate the need for possible software automation in

the given system. By the end of the feasibility study, the team furnishes a document that holds

the different specific recommendations for the candidate system. It also includes the

 personnel assignments, costs, project schedule, target dates etc.... The requirement gathering

 process is intensified and focussed specially on software. To understand the nature of the

 program(s) to be built, the system engineer or "Analyst" must understand the information domainfor the software, as well as required function, behavior, performance and interfacing. The

essential purpose of this phase is to find the need and to define the problem that needs to be

solved .

After the feasibility study, we opted for JAVA as front-end for our project and ORACLE for 

 back-end. The reasons for opting JAVA :

• Platform independent

• Machine independent

System Analysis and Design

In this phase, the software development process, the software's overall structure and its nuances

are defined. In terms of the client/server technology, the number of tiers needed for the package

architecture, the database design, the data structure design etc... are all defined in this phase. A

software development model is thus created. Analysis and Design are very crucial in the whole

development cycle. Any glitch in the design phase could be very expensive to solve in the later

stage of the software development. Much care is taken during this phase. The logical system of 

the product is developed in this phase

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 97/105

Code Generation

The design must be translated into a machine-readable form. The code generation step performs

this task. If the design is performed in a detailed manner, code generation can be accomplished

without much complication. Programming tools like compilers, interpreters, debuggers etc...

are used to generate the code. Different high level programming languages like C, C++, Pascal,

Java are used for coding. With respect to the type of application, the right programming

language is chosen i.e JAVA in case of our project.

Testing

Once the code is generated, the software program testing begins. Different testing methodologies

are available to unravel the bugs that were committed during the previous phases. Differenttesting tools and methodologies are already available. Some companies build their own testing

tools that are tailor made for their own development operations.

Maintenance

The software will definitely undergo change once it is delivered to the customer. There can bemany reasons for this change to occur. Change could happen because of some unexpected inputvalues into the system. In addition, the changes in the system could directly affect the softwareoperations. The software should be developed to accommodate changes that could happen duringthe post implementation period

6. Software testing

Software testing  is the process used to measure the quality of developed computer software.

Usually, quality is constrained to such topics as correctness, completeness, security, but can also

include more technical requirements as described under the ISO standard ISO 9126, such as

capability, reliability, efficiency, portability, maintainability, compatibility, and usability.

Testing is a process of technical investigation, performed on behalf of stakeholders, that is

intended to reveal quality-related information about the product with respect to the context in

which it is intended to operate .

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 98/105

White box, black box, and grey box testing

White box and black box testing are terms used to describe the point of view that a test engineer 

takes when designing test cases. Black box testing treats the software as a black-box without any

understanding as to how the internals behave. Thus, the tester inputs data and only sees the

output from the test object. This level of testing usually requires thorough test cases to be

 provided to the tester who then can simply verify that for a given input, the output value (or 

 behavior), is the same as the expected value specified in the test case.

White box testing, however, is when the tester has access to the internal data structures, code,

and algorithms. For this reason, unit testing and debugging can be classified as white-box testing

and it usually requires writing code, or at a minimum, stepping through it, and thus requires more

skill than the black-box tester. If the software in test is an interface or API of any sort, white-box

testing is almost always required.

In recent years the term grey box testing has come into common usage. This involves having

access to internal data structures and algorithms for purposes of designing the test cases, but

testing at the user, or black-box level. Manipulating input data and formatting output do not

qualify as grey-box because the input and output are clearly outside of the black-box we are

calling the software under test. This is particularly important when conducting integration testing 

 between two modules of code written by two different developers, where only the interfaces are

exposed for test.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 99/105

Grey box testing could be used in the context of testing a client-server environment when the

tester has control over the input, inspects the value in a SQL database, and the output value, and

then compares all three (the input, sql value, and output), to determine if the data got corrupt on

the database insertion or retrieval.

Verification and validation

Software testing is used in association with verification and validation (V&V). Verification is the

checking of or testing of items, including software, for conformance and consistency with an

associated specification. Software testing is just one kind of verification, which also uses

techniques such as reviews, inspections, and walkthroughs. Validation is the process of checking

what has been specified is what the user actually wanted.

1. Verification: Have we built the software right? (i.e. does it match the specification).

2. Validation: Have we built the right software? (i.e. Is this what the customer wants?)

Levels of testing

1. Unit testing tests the minimal software component, or module. Each unit (basic

component) of the software is tested to verify that the detailed design for the unit has been

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 100/105

correctly implemented. In an Object-oriented environment, this is usually at the class level, and

the minimal unit tests include the constructors and destructors.

2. Integration testing exposes defects in the interfaces and interaction between integrated

components (modules). Progressively larger groups of tested software components

corresponding to elements of the architectural design are integrated and tested until the software

works as a system.

3. Functional testing tests at any level (class, module, interface, or system) for proper 

functionality as defined in the specification.

4. System testing tests a completely integrated system to verify that it meets its

requirements.

5. System integration testing verifies that a system is integrated to any external or third

 party systems defined in the system requirements.

6. Acceptance testing can be conducted by the end-user, customer, or client to validate

whether or not to accept the product. Acceptance testing may be performed as part of the hand-

off process between any two phases of development.

1.

2.

3.  Alpha testing is simulated or actual operational testing by potential users/customers

or an independent test team at the developers' site. Alpha testing is often employed for off-the-

shelf software as a form of internal acceptance testing, before the software goes to beta testing.

4.  Beta testing  comes after alpha testing. Versions of the software, known as  beta 

versions, are released to a limited audience outside of the company. The software is released to

groups of people so that further testing can ensure the product has few faults or  bugs. Sometimes,

 beta versions are made available to the open public to increase the feedback field to a maximal

number of future users.

It should be noted that although both Alpha and Beta are referred to as testing it is in fact use

immersion. The rigors that are applied are often unsystematic and many of the basic tenets of 

testing process are not used. The Alpha and Beta period provides insight into environmental and

utilization conditions that can impact the software.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 101/105

After modifying software, either for a change in functionality or to fix defects, a regression test 

re-runs previously passing tests on the modified software to ensure that the modifications haven't

unintentionally caused a regression of previous functionality. Regression testing can be

 performed at any or all of the above test levels. These regression tests are often automated.

SMOKE TESTING

Smoke testing is a term used in  plumbing, woodwind repair, electronics, and computer software 

development. It refers to the first test made after repairs or first assembly to provide some

assurance that the system under test will not catastrophically fail. After a  smoke test proves that

the pipes will not leak, the keys seal properly, the circuit will not burn, or the software will not

crash outright, the assembly is ready for more stressful testing.

• In  plumbing, a   smoke test forces actual smoke through newly plumbed pipes to find

leaks, before water is allowed to flow through the pipes.

• In woodwind instrument repair, a smoke test involves plugging one end of an instrument

and blowing smoke into the other to test for leaks. (This test is no longer in common use)

• In electronics, a smoke testing is the first time a circuit is attached to power, which will

sometimes produce actual smoke if a design or wiring mistake has been made.

• In computer programming and software testing, smoke testing is a preliminary to further 

testing, which should reveal simple failures severe enough to reject a prospective

software release. In this case, the smoke is metaphorical.

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 102/105

TESTING MECHANISM USED

In a software development project, errors can be injected at any stage during development.

Testing is the phase where the errors remaining from all the previous phases must be detected.

Hence testing performs a very critical role for quality assurance and for ensuring the reliability of 

software.

During testing, the program to be tested is executed with a set of test cases, and the output of the

 program for the test cases is evaluated to determine if the program performing as expected.

Testing forms the first step in determining the errors in a program.

Testing a large system is a complex activity, and like any complex activity it has to be broken

into smaller activities. Due to this, for a project, incremental testing is generally performed, in

which components and subsystems of the system are tested separately before integrating them to

from the system for system testing. This form of testing though necessary to ensure quality for a

large system introduces new issues of how to select components for testing and how to combinethem to form the subsystem and the system. In other words, integration of the various

components of the system is an important issue that the testing phase has to deal with. For this

reason, this phase is also called "integration and testing".

In testing, system behaviour is observed, and by observing the behaviour of a system or a

component during testing, we determine whether or not there is a failure. Because of this

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 103/105

fundamental reliance on external behaviour observation, testing can only reveal the presence of 

faults and not their absence. So during the testing process, only failures are observed, which

reduces the presence of faults.

TOP-DOWN AND BOTTOM-UP APPROACHES

In incremental testing, some parts of the system are first tested independently. Then these parts

are combined to form a sub system, which is then tested independently. This combination can be

done in two ways: either only the modules that have been tested independently are combined or 

some new untested modules are combined with tested modules. In this way, there are two

common ways modules can be combined, as they are tested, to form a wording program:

TOP-DOWN APPROACH

In top-down strategy, we start by testing the top of the hierarchy of modules, and we

incrementally add modules that it calls and then test the new combined system. In this approach,

a module cannot be tested on isolation because they invoke some other modules. Top-down is

advantageous if major flaws occur towards the top of the hierarchy.

BOTTOM-UP APPROACH

The bottom-up approach starts from the bottom of the module hierarchy. First the modules at the

very bottom, which have no subordinates, are tested. Then these modules are combined with

higher-level modules for testing. At any stage of testing all the subordinate modules exist and

have been tested earlier. Bottom-up is advantageous if major flaws occur towards the bottom.

 

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 104/105

 BIBLOGRAPHY

BOOKS:

The Complete Reference Java2By:-Herbert Schildt

Programming with JavaBy:-E Balagurusamy

WEBSITES:

www. java.sun.com

www.google.co.in 

en.wikipedia.org

8/3/2019 Online File11

http://slidepdf.com/reader/full/online-file11 105/105

CONCLUSION

The project entitled “ONLINE TEST” has beensuccessfully complied and made to run using the

following main components of core Java:

EVENT HANDLING

EXCEPTION HANDLING

LAYOUTS

SWINGS