Showing posts with label JAVA. Show all posts
Showing posts with label JAVA. Show all posts

Introduction of Java

Java programming language was originally developed by Sun Microsystems, which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems.s Java platform (Java 1.0 [J2SE]).
As of December 08 the latest release of the Java Standard Edition is 6 (J2SE). With the advancement of Java and its wide spread popularity, multiple configurations were built to suite various types of platforms. Ex: J2EE for Enterprise Applications, J2ME for Mobile Applications.
Sun Microsystems has renamed the new J2 versions as Java SE, Java EE and Java ME respectively. Java is guaranteed to be Write Once, Run Anywhere
Java is:
Object Oriented : In java everything is an Object. Java can be easily extended since it is based on the Object model.
Platform independent: Unlike many other programming languages including C and C++ when Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the web and interpreted by virtual Machine (JVM) on whichever platform it is being run.
Simple :Java is designed to be easy to learn. If you understand the basic concept of OOP java would be easy to master.
Secure : With Java.s secure feature it enables to develop virus-free, tamper-free systems. Authentication techniques are based on public-key encryption.
Architectural- neutral :Java compiler generates an architecture-neutral object file format which makes the compiled code to be executable on many processors, with the presence Java runtime system.
Portable :being architectural neutral and having no implementation dependent aspects of the specification makes Java portable. Compiler and Java is written in ANSI C with a clean portability boundary which is a POSIX subset.
Robust :Java makes an effort to eliminate error prone situations by emphasizing mainly on compile time error checking and runtime checking.
Multi-threaded : With Java.s multi-threaded feature it is possible to write programs that can do many tasks simultaneously. This design feature allows developers to construct smoothly running interactive applications.
Interpreted :Java byte code is translated on the fly to native machine instructions and is not stored anywhere. The development process is more rapid and analytical since the linking is an incremental and light weight process.
High Performance: With the use of Just-In-Time compilers Java enables high performance.
Distributed :Java is designed for the distributed environment of the internet.
Dynamic : Java is considered to be more dynamic than C or C++ since it is designed to adapt to an evolving environment. Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time.
History of Java:
James Gosling initiated the Java language project in June 1991 for use in one of his many set-top box projects. The language, initially called Oak after an oak tree that stood outside Gosling's office, also went by the name Green and ended up later renamed as Java, from a list of random words.
Sun released the first public implementation as Java 1.0 in 1995. It promisedWrite Once, Run Anywhere (WORA), providing no-cost run-times on popular platforms.
On 13 November 2006, Sun released much of Java as free and open source software under the terms of the GNU General Public License (GPL).
On 8 May 2007 Sun finished the process, making all of Java's core code free and open-source, aside from a small portion of code to which Sun did not hold the copyright.

Tools you will need:

For performing the examples discussed in this tutorial, you will need a Pentium 200-MHz computer with a minimum of 64 MB of RAM (128 MB of RAM recommended).
You also will need the following softwares:
Linux 7.1 or Windows 95/98/2000/XP operating system.
Java JDK 5
Microsoft Notepad or any other text editor
This tutorial will provide the necessary skills to create GUI, networking, and Web applications using Java.


Computer Glossary


  • Applet
  • A small Java application that is downloaded by an ActiveX or Java-enabled web browser. Once it has been downloaded, the applet will run on the user's computer. Common applets include financial calculators and web drawing programs.
  • Application
  • Computer software that performs a task or set of tasks, such as word processing or drawing. Applications are also referred to as programs.
  • ASCII
  • American Standard Code for Information Interchange, an encoding system for converting keyboard characters and instructions into the binary number code that the computer understands.
  • Bandwidth
  • The capacity of a networked connection. Bandwidth determines how much data can be sent along the networked wires. Bandwidth is particularly important for Internet connections, since greater bandwidth also means faster downloads.
  • Binary code
  • The most basic language a computer understands, it is composed of a series of 0s and 1s. The computer interprets the code to form numbers, letters, punctuation marks, and symbols.
  • Bit
  • The smallest piece of computer information, either the number 0 or 1. In short ther are called binary digits.
  • Boot
  • To start up a computer. Cold boot.restarting computer after having turned off the power. Warm boot.restarting computer without having turned off the power.
  • Browser
  • Software used to navigate the Internet. Netscape Navigator and Microsoft Internet Explorer are today's most popular browsers for accessing the World Wide Web.
  • Bug
  • A malfunction due to an error in the program or a defect in the equipment.
  • Byte
  • Most computers use combinations of eight bits, called bytes, to represent one character of data or instructions. For example, the word .cat. has three characters, and it would be represented by three bytes.
  • Cache
  • A small data-memory storage area that a computer can use to instantly re-access data instead of re-reading the data from the original source, such as a hard drive. Browsers use a cache to store web pages so that the user may view them again without reconnecting to the Web.
  • CAD-CAM
  • Computer Aided Drawing-Computer Aided Manufacturing. The instructions stored in a computer that will be translated to very precise operating instructions to a robot, such as for assembling cars or laser-cutting signage.
  • CD-ROM
  • Compact Disc Read-Only Memory. An optically read disc designed to hold information such as music, reference materials, or computer software. A single CD-ROM can hold around 640 megabytes of data, enough for several encyclopedias. Most software programs are now delivered on CD-ROMs.
  • CGI
  • Common Gateway Interface. A programming standard that allows visitors to fill out form fields on a Web page and have that information interact with a database, possibly coming back to the user as another Web page. CGI may also refer to Computer-Generated Imaging, the process in which sophisticated computer programs create still and animated graphics, such as special effects for movies.
  • Chat
  • Typing text into a message box on a screen to engage in dialog with one or more people via the Internet or other network.
  • Chip
  • A tiny wafer of silicon containing miniature electric circuits that can store millions of bits of information.
  • Client
  • A single user of a network application that is operated from a server. A client/server architecture allows many people to use the same data simultaneously. The program's main component (the data) resides on a centralized server, with smaller components (user interface) on each client.
  • Cookie
  • A text file sent by a Web server that is stored on the hard drive of a computer and relays back to the Web server things about the user, his or her computer, and/or his or her computer activities.
  • CPU
  • Central Processing Unit. The brain of the computer.
  • Cracker
  • A person who .breaks in. to a computer through a network, without authorization and with mischievous or destructive intent.
  • Crash
  • A hardware or software problem that causes information to be lost or the computer to malfunction. Sometimes a crash can cause permanent damage to a computer.
  • Cursor
  • A moving position-indicator displayed on a computer monitor that shows a computer operator where the next action or operation will take place.

  • Cyberspace
Slang for internet ie. An international conglomeration of interconnected computer networks. Begun in the late 1960s, it was developed in the 1970s to allow government and university researchers to share information. The Internet is not controlled by any single group or organization. Its original focus was research and communications, but it continues to expand, offering a wide array of resources for business and home users.


  • Database
    A collection of similar information stored in a file, such as a database of addresses. This information may be created and stored in a database management system (DBMS).

  • Debug
    Slang. To find and correct equipment defects or program malfunctions.

  • Default
    The pre-defined configuration of a system or an application. In most programs, the defaults can be changed to reflect personal preferences.

  • Desktop
    The main directory of the user interface. Desktops usually contain icons that represent links to the hard drive, a network (if there is one), and a trash or recycling can for files to be deleted. It can also display icons of frequently used applications, as requested by the user.

  • Desktop publishing
    The production of publication-quality documents using a personal computer in combination with text, graphics, and page layout programs.

  • Directory
    A repository where all files are kept on computer.

  • Disk
    Two distinct types. The names refer to the media inside the container: 

    A hard disc stores vast amounts of data. It is usually inside the computer but can be a separate peripheral on the outside. Hard discs are made up of several rigid coated metal discs. Currently, hard discs can store 15 to 30 Gb (gigabytes)

    A floppy disc, 3.5" square, usually inserted into the computer and can store about 1.4 megabytes of data. The 3.5" square .floppies. have a very thin, flexible disc inside. There is also an intermediate-sized floppy disc, trademarked Zip discs, which can store 250 megabytes of data.


  • Disk drive
    The equipment that operates a hard or floppy disc.

  • Domain
    Represents an IP (Internet Protocol) address or set of IP addresses that comprise a domain. The domain name appears in URLs to identify web pages or in email addresses. For example, the email address for the First Lady is first.lady@whitehouse.gov, .whitehouse.gov. being the domain name. Each domain name ends with a suffix that indicates what .top level domain. it belongs to. These are: ..com. for commercial, ..gov. for government, ..org. for organization, ..edu. for educational institution, ..biz. for business, ..info. for information, ..tv. for television, ..ws. for website. Domain suffixes may also indicate the country in which the domain is registered. No two parties can ever hold the same domain name.

  • Domain name
    The name of a network or computer linked to the Internet. Domains are defined by a common IP address or set of similar IP (Internet Protocol) addresses.

  • Download
    The process of transferring information from a web site (or other remote location on a network) to the computer. It is possible to .download a file. or .view a download.

  • DOS
    Disk Operating System. An operating system designed for early IBM-compatible PCs.

  • Drop-down menu
    A menu window that opens vertically on-screen to display context-related options. Also called pop-up menu or pull-down menu.

  • DSL
    Digital Subscriber Line. A method of connecting to the Internet via a phone line. A DSL connection uses copper telephone lines but is able to relay data at much higher speeds than modems and does not interfere with telephone use.

  • DVD
    Digital Video Disc.Similar to a CD-ROM, it stores and plays both audio and video.

  • E-book
    An electronic (usually hand-held) reading device that allows a person to view digitally stored reading materials.

  • Email
    Electronic mail; messages, including memos or letters, sent electronically between networked computers that may be across the office or around the world.

  • Emoticon
    A text-based expression of emotion created from ASCII characters that mimics a facial expression when viewed with your head tilted to the left. Here are some examples:
    :-) Smiling
    :-( Frowning
    ;-) Winking
    :_( Crying

  • Encryption
    The process of transmitting scrambled data so that only authorized recipients can unscramble it. For instance, encryption is used to scramble credit card information when purchases are made over the Internet.

  • Ethernet
    A type of network.

  • Ethernet card
    A board inside a computer to which a network cable can be attached.

  • File
    A set of data that is stored in the computer.

  • Firewall
    A set of security programs that protect a computer from outside interference or access via the Internet.

  • Folder
    A structure for containing electronic files. In some operating systems, it is called a .directory.

  • Fonts
    Sets of typefaces (or characters) that come in different styles and sizes.

  • Freeware
    Software created by people who are willing to give it away for the satisfaction of sharing or knowing they helped to simplify other people's lives. It may be freestanding software, or it may add functionality to existing software.

  • FTP
    File Transfer Protocol. A format and set of rules for transferring files from a host to a remote computer.


    • Gigabyte (GB)
  • 1024 megabytes. Also called gig.




    • Glitch
  • The cause of an unexpected malfunction.




    • Gopher
  • An Internet search tool that allows users to access textual information through a series of menus, or if using FTP, through downloads.




    • GUI
  • Graphical User Interface. A system that simplifies selecting computer commands by enabling the user to point to symbols or illustrations (called icons) on the computer screen with a mouse.




    • Groupware
  • Software that allows networked individuals to form groups and collaborate on documents, programs, or databases.




    • Hacker
  • A person with technical expertise who experiments with computer systems to determine how to develop additional features. Hackers are occasionally requested by system administrators to try and .break into. systems via a network to test security. The term hacker is sometimes incorrectly used interchangeably with cracker. A hacker is called a .white hat. and a cracker a .black hat.




    • Hard copy
  • A paper printout of what you have prepared on the computer.




    • Hard drive
  • Another name for the hard disc that stores information information in a computer.




    • Hardware
  • The physical and mechanical components of a computer system, such as the electronic circuitry, chips, monitor, disks, disk drives, keyboard, modem, and printer.




    • Home page
  • The main page of a Web site used to greet visitors, provide information about the site, or to direct the viewer to other pages on the site.




    • HTML
  • Hypertext Markup Language. A standard of text markup conventions used for documents on the World Wide Web. Browsers interpret the codes to give the text structure and formatting (such as bold, blue, or italic).




    • HTTP
  • Hypertext Transfer Protocol. A common system used to request and send HTML documents on the World Wide Web. It is the first portion of all URL addresses on the World Wide Web




    • HTTPS
  • Hypertext Transfer Protocol Secure. Often used in intracompany internet sites. Passwords are required to gain access.




    • Hyperlink
  • Text or an image that is connected by hypertext coding to a different location. By selecting the text or image with a mouse, the computer .jumps to. (or displays) the linked text.




    • Hypermedia
  • Integrates audio, graphics, and/or video through links embedded in the main program.




    • Hypertext
  • A system for organizing text through links, as opposed to a menu-driven hierarchy such as Gopher. Most Web pages include hypertext links to other pages at that site, or to other sites on the World Wide Web.




    • Icons
  • Symbols or illustrations appearing on the computer screen that indicate program files or other computer functions.




    • Input
  • Data that goes into a computer device.




    • Input device
  • A device, such as a keyboard, stylus and tablet, mouse, puck, or microphone, that allows input of information (letters, numbers, sound, video) to a computer.




    • Instant messenging (IM)
  • A chat application that allows two or more people to communicate over the Internet via real-time keyed-in messages.




    • Interface
  • The interconnections that allow a device, a program, or a person to interact. Hardware interfaces are the cables that connect the device to its power source and to other devices. Software interfaces allow the program to communicate with other programs (such as the operating system), and user interfaces allow the user to communicate with the program (e.g., via mouse, menu commands, icons, voice commands, etc.).




    • Internet
  • An international conglomeration of interconnected computer networks. Begun in the late 1960s, it was developed in the 1970s to allow government and university researchers to share information. The Internet is not controlled by any single group or organization. Its original focus was research and communications, but it continues to expand, offering a wide array of resources for business and home users.




    • IP (Internet Protocol) address
  • An Internet Protocol address is a unique set of numbers used to locate another computer on a network. The format of an IP address is a 32-bit string of four numbers separated by periods. Each number can be from 0 to 255 (i.e., 1.154.10.266). Within a closed network IP addresses may be assigned at random, however, IP addresses of web servers must be registered to avoid duplicates.




    • Java
  • An object-oriented programming language designed specifically for programs (particularly multimedia) to be used over the Internet. Java allows programmers to create small programs or applications (applets) to enhance Web sites.




    • Javascript/ECMA script
  • A programming language used almost exclusively to manipulate content on a web page. Common Javascript functions include validating forms on a web page, creating dynamic page navigation menus, and image rollovers.








    • kilobyte (K or KB)
  • Equal to 1,024 bytes.

  • Linux
  • A UNIX.-like, open-source operating system developed primarily by Linus Torvalds. Linux is free and runs on many platforms, including both PCs and Macintoshes. Linux is an open-source operating system, meaning that the source code of the operating system is freely available to the public. Programmers may redistribute and modify the code, as long as they don't collect royalties on their work or deny access to their code. Since development is not restricted to a single corporation more programmers can debug and improve the source code faster.

  • Laptop and notebook
  • Small, lightweight, portable battery-powered computers that can fit onto your lap. They each have a thin, flat, liquid crystal display screen.

  • Macro
  • A script that operates a series of commands to perform a function. It is set up to automate repetitive tasks.

  • Mac OS
  • An operating system with a graphical user interface, developed by Apple. for Macintosh. computers. Current System .X.1. (10) combines the traditional Mac interface with a strong underlying UNIX. operating system for increased performance and stability.

  • Megabyte (MB)
  • Equal to 1,048,576 bytes, usually rounded off to one million bytes (also called a .meg.).

  • Memory
  • Temporary storage for information, including applications and documents. The information must be stored to a permanent device, such as a hard disc or CD-ROM before the power is turned off, or the information will be lost. Computer memory is measured in terms of the amount of information it can store, commonly in megabytes or gigabytes.

  • Menu
  • A context-related list of options that users can choose from.

  • Menu bar
  • The horizontal strip across the top of an application's window. Each word on the strip has a context sensitive drop-down menu containing features and actions that are available for the application in use.

  • Merge
  • To combine two or more files into a single file.

  • MHz
  • An abbreviation for Megahertz, or one million hertz. One MHz represents one million clock cycles per second and is the measure of a computer microprocessor's speed. For example, a microprocessor that runs at 300 MHz executes 300 million cycles per second. Each instruction a computer receives takes a fixed number of clock cycles to carry out, therefore the more cycles a computer can execute per second, the faster its programs run. Megahertz is also a unit of measure for bandwidth.

  • Microprocessor
  • A complete central processing unit (CPU) contained on a single silicon chip.

  • Minimize
  • A term used in a GUI operating system that uses windows. It refers to reducing a window to an icon, or a label at the bottom of the screen, allowing another window to be viewed.

  • Modem
  • A device that connects two computers together over a telephone or cable line by converting the computer's data into an audio signal. Modem is a contraction for the process it performs: modulate-demodulate.

  • Monitor
  • A video display terminal.

  • Mouse
  • A small hand-held device, similar to a trackball, used to control the position of the cursor on the video display; movements of the mouse on a desktop correspond to movements of the cursor on the screen.

  • MP3
  • Compact audio and video file format. The small size of the files makes them easy to download and e-mail. Format used in portable playback devices.

  • Multimedia
  • Software programs that combine text and graphics with sound, video, and animation. A multimedia PC contains the hardware to support these capabilities.

  • MS-DOS
  • An early operating system developed by Microsoft Corporation (Microsoft Disc Operating System).

  • Network
  • A system of interconnected computers.

  • Open source
  • Computer programs whose original source code was revealed to the general public so that it could be developed openly. Software licensed as open source can be freely changed or adapted to new uses, meaning that the source code of the operating system is freely available to the public. Programmers may redistribute and modify the code, as long as they don't collect royalties on their work or deny access to their code. Since development is not restricted to a single corporation more programmers can debug and improve the source code faster.

  • Operating system
  • A set of instructions that tell a computer on how to operate when it is turned on. It sets up a filing system to store files and tells the computer how to display information on a video display. Most PC operating systems are DOS (disc operated system) systems, meaning the instructions are stored on a disc (as opposed to being originally stored in the microprocessors of the computer). Other well-known operating systems include UNIX, Linux, Macintosh, and Windows.

  • Output
  • Data that come out of a computer device. For example, information displayed on the monitor, sound from the speakers, and information printed to paper.

  • Palm
  • A hand-held computer.

  • PC
  • Personal computer. Generally refers to computers running Windows with a Pentium processor.

  • PC board
  • Printed Circuit board. A board printed or etched with a circuit and processors. Power supplies, information storage devices, or changers are attached.

  • PDA
  • Personal Digital Assistant. A hand-held computer that can store daily appointments, phone numbers, addresses, and other important information. Most PDAs link to a desktop or laptop computer to download or upload information.

  • PDF
  • Portable Document Format. A format presented by Adobe Acrobat that allows documents to be shared over a variety of operating systems. Documents can contain words and pictures and be formatted to have electronic links to other parts of the document or to places on the web.

  • Pentium chip
  • Intel's fifth generation of sophisticated high-speed microprocessors. Pentium means .the fifth element..

  • Peripheral
  • Any external device attached to a computer to enhance operation. Examples include external hard drive, scanner, printer, speakers, keyboard, mouse, trackball, stylus and tablet, and joystick.

  • Personal computer (PC)
  • A single-user computer containing a central processing unit (CPU) and one or more memory circuits.

  • Petabyte
  • A measure of memory or storage capacity and is approximately a thousand terabytes.

  • Petaflop
  • A theoretical measure of a computer's speed and can be expressed as a thousand-trillion floating-point operations per second.

  • Platform
  • The operating system, such as UNIX., Macintosh., Windows., on which a computer is based.

  • Plug and play
  • Computer hardware or peripherals that come set up with necessary software so that when attached to a computer, they are .recognized. by the computer and are ready to use.

  • Pop-up menu
  • A menu window that opens vertically or horizontally on-screen to display context-related options. Also called drop-down menu or pull-down menu.

  • Power PC
  • A competitor of the Pentium chip. It is a new generation of powerful sophisticated microprocessors produced from an Apple-IBM-Motorola alliance.

  • Printer
  • A mechanical device for printing a computer's output on paper. There are three major types of printers: Dot matrix: creates individual letters, made up of a series of tiny ink dots, by punching a ribbon with the ends of tiny wires. (This type of printer is most often used in industrial settings, such as direct mail for labeling.)

  • Ink jet: sprays tiny droplets of ink particles onto paper.

  • Laser: uses a beam of light to reproduce the image of each page using a magnetic charge that attracts dry toner that is transferred to paper and sealed with heat.

  • Program
  • A precise series of instructions written in a computer language that tells the computer what to do and how to do it. Programs are also called .software. or .applications.

  • Programming language
  • A series of instructions written by a programmer according to a given set of rules or conventions (.syntax.). High-level programming languages are independent of the device on which the application (or program) will eventually run; low-level languages are specific to each program or platform. Programming language instructions are converted into programs in language specific to a particular machine or operating system (.machine language.) so that the computer can interpret and carry out the instructions. Some common programming languages are BASIC, C, C++, dBASE, FORTRAN, and Perl.

  • Puck
  • An input device, like a mouse. It has a magnifying glass with crosshairs on the front of it that allows the operator to position it precisely when tracing a drawing for use with CAD-CAM software.

  • Pull-down menu
  • A menu window that opens vertically on-screen to display context-related options. Also called drop-down menu or pop-up menu.

  • Push technology
  • Internet tool that delivers specific information directly to a user's desktop, eliminating the need to surf for it. PointCast, which delivers news in user-defined categories, is a popular example of this technology.

  • QuickTime.
  • Audio-visual software that allows movie-delivery via the Internet and e-mail. QuickTime mages are viewed on a monitor.

  • RAID
  • Redundant Array of Inexpensive Disks. A method of spreading information across several disks set up to act as a unit, using two different techniques:
  • Disk striping: storing a bit of information across several discs (instead of storing it all on one disc and hoping that the disc doesn't crash).
  • Disk mirroring: simultaneously storing a copy of information on another disc so that the information can be recovered if the main disc crashes.

  • RAM
  • Random Access Memory. One of two basic types of memory. Portions of programs are stored in RAM when the program is launched so that the program will run faster. Though a PC has a fixed amount of RAM, only portions of it will be accessed by the computer at any given time. Also called memory.

  • Right-click
  • Using the right mouse button to open context-sensitive drop-down menus.

  • ROM
  • Read-Only Memory. One of two basic types of memory. ROM contains only permanent information put there by the manufacturer. Information in ROM cannot be altered, nor can the memory be dynamically allocated by the computer or its operator.

  • Scanner
  • An electronic device that uses light-sensing equipment to scan paper images such as text, photos, and illustrations and translate the images into signals that the computer can then store, modify, or distribute.

  • Search engine
  • Software that makes it possible to look for and retrieve material on the Internet, particularly the Web. Some popular search engines are Alta Vista, Google, HotBot, Yahoo!, Web Crawler, and Lycos.

  • Server
  • A computer that shares its resources and information with other computers, called clients, on a network.

  • Shareware
  • Software created by people who are willing to sell it at low cost or no cost for the gratification of sharing. It may be freestanding software, or it may add functionality to existing software.

  • Software
  • Computer programs; also called .applications.

  • Spider
  • A process search engines use to investigate new pages on a web site and collect the information that needs to be put in their indices.

  • Spreadsheet
  • Software that allows one to calculate numbers in a format that is similar to pages in a conventional ledger.

  • Storage
  • Devices used to store massive amounts of information so that it can be readily retrieved. Devices include RAIDs, CD-ROMs, DVDs

  • Streaming
  • Taking packets of information (sound or visual) from the Internet and storing it in temporary files to allow it to play in continuous flow.

  • Stylus and tablet
  • A input device similar to a mouse. The stylus is pen shaped. It is used to .draw. on a tablet (like drawing on paper) and the tablet transfers the information to the computer. The tablet responds to pressure.the firmer the pressure used to draw, the thicker the line appears.

  • Surfing
  • Exploring the Internet.

  • Surge protector
  • A controller to protect the computer and make up for variances in voltage.





  • Telnet
  • A way to communicate with a remote computer over a network.

  • Trackball
  • Input device that controls the position of the cursor on the screen; the unit is mounted near the keyboard, and movement is controlled by moving a ball.

  • Terabytes (TB)
  • A thousand gigabytes.

  • Teraflop
  • A measure of a computer's speed. It can be expressed as a trillion floating-point operations per second.

  • Trojan Horse
  • See virus.

  • UNIX.
  • A very powerful operating system used as the basis of many high-end computer applications.

  • Upload
  • The process of transferring information from a computer to a web site (or other remote location on a network). v. To transfer information from a computer to a web site (or other remote location on a network).

  • URL
  • Uniform Resource Locator. 
  • 1. The protocol for identifying a document on the Web.
  • 2. A Web address (e.g., www.tutorialspoint.com). A URL is unique to each user. See also domain.

  • UPS
  • Universal Power Supply or Uninterruptible Power Supply. An electrical power supply that includes a battery to provide enough power to a computer during an outage to back-up data and properly shut down.

  • USB
  • A multiple-socket USB connecter that allows several USB-compatible devices to be connected to a computer.

  • USENET
  • A large unmoderated and unedited bulletin board on the Internet that offers thousands of forums, called newsgroups. These range from newsgroups exchanging information on scientific advances to celebrity fan clubs.

  • User friendly
  • A program or device whose use is intuitive to people with a nontechnical background.

  • Video teleconferencing
  • A remote "face-to-face chat," when two or more people using a webcam and an Internet telephone connection chat online. The webcam enables both live voice and video.

  • Virtual reality (VR)
  • A technology that allows one to experience and interact with images in a simulated three-dimensional environment. For example, you could design a room in a house on your computer and actually feel that you are walking around in it even though it was never built. (The Holodeck in the science-fiction TV series Star Trek: Voyager would be the ultimate virtual reality.) Current technology requires the user to wear a special helmet, viewing goggles, gloves, and other equipment that transmits and receives information from the computer.

  • Virus
  • An unauthorized piece of computer code attached to a computer program or portions of a computer system that secretly copies itself from one computer to another by shared discs and over telephone and cable lines. It can destroy information stored on the computer, and in extreme cases, can destroy operability. Computers can be protected from viruses if the operator utilizes good virus prevention software and keeps the virus definitions up to date. Most viruses are not programmed to spread themselves. They have to be sent to another computer by e-mail, sharing, or applications. The worm is an exception, because it is programmed to replicate itself by sending copies to other computers listed in the e-mail address book in the computer. There are many kinds of viruses, for example:
  • Boot viruses place some of their code in the start-up disk sector to automatically execute when booting. Therefore, when an infected machine boots, the virus loads and runs.
  • File viruses attached to program files (files with the extension ..exe.). When you run the infected program, the virus code executes.
  • Macro viruses copy their macros to templates and/or other application document files.
  • Trojan Horse is a malicious, security-breaking program that is disguised as something benign such as a screen saver or game.
  • Worm launches an application that destroys information on your hard drive. It also sends a copy of the virus to everyone in the computer's e-mail address book.

  • WAV
  • A sound format (pronounced .wave.) used to reproduce sounds on a computer.

  • Webcam
  • A video camera/computer setup that takes live images and sends them to a Web browser.

  • Window
  • A portion of a computer display used in a graphical interface that enables users to select commands by pointing to illustrations or symbols with a mouse. "Windows" is also the name Microsoft adopted for its popular operating system.

  • World Wide Web ("WWW" or "the Web")
  • A network of servers on the Internet that use hypertext-linked databases and files. It was developed in 1989 by Tim Berners-Lee, a British computer scientist, and is now the primary platform of the Internet. The feature that distinguishes the Web from other Internet applications is its ability to display graphics in addition to text.

  • Word processor
  • A computer system or program for setting, editing, revising, correcting, storing, and printing text.

  • Worm
  • See virus.

  • WYSIWYG
What You See Is What You Get. When using most word processors, page layout programs (See desktop publishing), and web page design programs, words and images will be displayed on the monitor as they will look on the printed page or web page.

Java Useful Resources

 If you want to list down your website, book or any other resource on this page then please contact at webmaster@tutorialspoint.com

What is Java?

Java is:
  • Object Oriented
  • Platform independent:
  • Simple
  • Secure
  • Architectural- neutral
  • Portable
  • Robust
  • Multi-threaded
  • Interpreted
  • High Performance
  • Distributed
  • Dynamic

Java Environment Setup:

Java SE is freely available from the link Download Java. So you download a version based on your operating system.
You can refere to installation guide for a complete detail.

Java Basic Syntax:

  • Object - Objects have states and behaviors. Example: A dog has states-color, name, breed as well as behaviors -wagging, barking, eating. An object is an instance of a class.
  • Class - A class can be defined as a template/ blue print that describe the behaviors/states that object of its type support.
  • Methods - A method is basically a behavior. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed.
  • Instant Variables - Each object has its unique set of instant variables. An object.s state is created by the values assigned to these instant variables.

First Java Program:

Let us look at a simple code that would print the words Hello World.
public class MyFirstJavaProgram{

/* This is my first java program.
* This will print 'Hello World' as the output
*/

public static void main(String []args){
System.out.println("Hello World"); // prints Hello World
}
}
About Java programs, it is very important to keep in mind the following points.
  • Case Sensitivity - Java is case sensitive which means identifier Helloand hello would have different meaning in Java.
  • Class Names - For all class names the first letter should be in Upper Case. 

    If several words are used to form a name of the class each inner words first letter should be in Upper Case.

    Example class MyFirstJavaClass
  • Method Names - All method names should start with a Lower Case letter. 

    If several words are used to form the name of the method, then each inner word's first letter should be in Upper Case.

    Example public void myMethodName()
  • Program File Name - Name of the program file should exactly match the class name. 

    When saving the file you should save it using the class name (Remember java is case sensitive) and append '.java' to the end of the name. (if the file name and the class name do not match your program will not compile).

    Example : Assume 'MyFirstJavaProgram' is the class name. Then the file should be saved as 'MyFirstJavaProgram.java'
  • public static void main(String args[]) - java program processing starts from the main() method which is a mandatory part of every java program..

Java Identifiers:

All java components require names. Names used for classes, variables and methods are called identifiers.
In java there are several points to remember about identifiers. They are as follows:
  • All identifiers should begin with a letter (A to Z or a to z ), currency character ($) or an underscore (-).
  • After the first character identifiers can have any combination of characters.
  • A key word cannot be used as an identifier.
  • Most importantly identifiers are case sensitive.
  • Examples of legal identifiers:age, $salary, _value, __1_value
  • Examples of illegal identifiers : 123abc, -salary

Java Modifiers:

Like other languages it is possible to modify classes, methods etc by using modifiers. There are two categories of modifiers.
  • Access Modifiers : defualt, public , protected, private
  • Non-access Modifiers : final, abstract, strictfp
We will be looking into more details about modifiers in the next section.

Java Variables:

We would see following type of variables in Java:
  • Local Variables
  • Class Variables (Static Variables)
  • Instance Variables (Non static variables)

Java Arrays:

Arrays are objects that store multiple variables of the same type. However an Array itself is an object on the heap. We will look into how to declare, construct and initialize in the upcoming chapters.

Java Enums:

Enums were introduced in java 5.0. Enums restrict a variable to have one of only a few predefined values. The values in this enumerated list are called enums.
With the use of enums it is possible to reduce the number of bugs in your code.
For example if we consider an application for a fresh juice shop it would be possible to restrict the glass size to small, medium and Large. This would make sure that it would not allow anyone to order any size other than the small, medium or large.

Example:

class  FreshJuice{
enum FreshJuiceSize{ SIZE, MEDUIM, LARGE }
FreshJuiceSize size;
}

public class FreshJuiceTest{
public static void main(String args[]){
FreshJuice juice = new FreshJuice();
juice.size = FreshJuice. FreshJuiceSize.MEDUIM ;
}
}
Note: enums can be declared as their own or inside a class. Methods, variables, constructors can be defined inside enums as well.

Java Keywords:

The following list shows the reserved words in Java. These reserved words may not be used as constant or variable or any other identifier names.
abstractassertbooleanbreak
bytecasecatchchar
classconstcontinuedefault
dodoubleelseenum
extendsfinalfinallyfloat
forgotoifimplements
importinstanceofintinterface
longnativenewpackage
privateprotectedpublicreturn
shortstaticstrictfpsuper
switchsynchronizedthisthrow
throwstransienttryvoid
volatilewhile

Comments in Java

Java supports single line and multi-line comments very similar to c and c++. All characters available inside any comment are ignored by Java compiler.
public class MyFirstJavaProgram{

/* This is my first java program.
* This will print 'Hello World' as the output
* This is an example of multi-line comments.
*/

public static void main(String []args){
// This is an example of single line comment
/* This is also an example of single line comment. */
System.out.println("Hello World");
}
}

Data Types in Java

There are two data types available in Java:
  1. Primitive Data Types
  2. Reference/Object Data Types

Primitive Data Types:

There are eight primitive data types supported by Java. Primitive data types are predefined by the language and named by a key word. Let us now look into detail about the eight primitive data types.
  • byte
  • short
  • int
  • long
  • float
  • double
  • boolean
  • char

Reference Data Types:

  • Reference variables are created using defined constructors of the classes. They are used to access objects. These variables are declared to be of a specific type that cannot be changed. For example, Employee, Puppy etc.
  • Class objects, and various type of array variables come under reference data type.
  • Default value of any reference variable is null.
  • A reference variable can be used to refer to any object of the declared type or any compatible type.
  • Example : Animal animal = new Animal("giraffe");

Java Literals:

A literal is a source code representation of a fixed value. They are represented directly in the code without any computation.
Literals can be assigned to any primitive type variable. For example:
byte a = 68;
char a = 'A'
String literals in Java are specified like they are in most other languages by enclosing a sequence of characters between a pair of double quotes. Examples of string literals are:
"Hello World"
"two\nlines"
"\"This is in quotes\""
Java language supports few special escape sequences for String and char literals as well. They are:
NotationCharacter represented
\nNewline (0x0a)
\rCarriage return (0x0d)
\fFormfeed (0x0c)
\bBackspace (0x08)
\sSpace (0x20)
\ttab
\"Double quote
\'Single quote
\\backslash
\dddOctal character (ddd)
\uxxxxHexadecimal UNICODE character (xxxx)

Java Access Modifiers:

Java provides a number of access modifiers to set access levels for classes, variables, methods and constructors. The four access levels are:
  1. Visible to the package. the default. No modifiers are needed.
  2. Visible to the class only (private).
  3. Visible to the world (public).
  4. Visible to the package and all subclasses (protected).

Java Basic Operators:

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

The Arithmetic Operators:

OperatorDescriptionExample
+Addition - Adds values on either side of the operatorA + B will give 30
-Subtraction - Subtracts right hand operand from left hand operandA - B will give -10
*Multiplication - Multiplies values on either side of the operatorA * B will give 200
/Division - Divides left hand operand by right hand operandB / A will give 2
%Modulus - Divides left hand operand by right hand operand and returns remainderB % A will give 0
++Increment - Increase the value of operand by 1B++ gives 21
--Decrement - Decrease the value of operand by 1B-- gives 19

The Relational Operators:

OperatorDescriptionExample
==Checks if the value of two operands are equal or not, if yes then condition becomes true.(A == B) is not true.
!=Checks if the value of two operands are equal or not, if values are not equal then condition becomes true.(A != B) is true.
>Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.(A > B) is not true.
<Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true.(A < B) is true.
>=Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.(A >= B) is not true.
<=Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.(A <= B) is true.

The Bitwise Operators:

OperatorDescriptionExample
&Binary AND Operator copies a bit to the result if it exists in both operands.(A & B) will give 12 which is 0000 1100
|Binary OR Operator copies a bit if it exists in eather operand.(A | B) will give 61 which is 0011 1101
^Binary XOR Operator copies the bit if it is set in one operand but not both.(A ^ B) will give 49 which is 0011 0001
~Binary Ones Complement Operator is unary and has the efect of 'flipping' bits.(~A ) will give -60 which is 1100 0011
<<Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand.A << 2 will give 240 which is 1111 0000
>>Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand.A >> 2 will give 15 which is 1111
>>>Shift right zero fill operator. The left operands value is moved right by the number of bits specified by the right operand and shifted values are filled up with zeros.A >>>2 will give 15 which is 0000 1111

The Logical Operators:

OperatorDescriptionExample
&&Called Logical AND operator. If both the operands are non zero then then condition becomes true.(A && B) is false.
||Called Logical OR Operator. If any of the two operands are non zero then then condition becomes true.(A || B) is true.
!Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false.!(A && B) is true.

The Assignment Operators:

OperatorDescriptionExample
=Simple assignment operator, Assigns values from right side operands to left side operandC = A + B will assigne value of A + B into C
+=Add AND assignment operator, It adds right operand to the left operand and assign the result to left operandC += A is equivalent to C = C + A
-=Subtract AND assignment operator, It subtracts right operand from the left operand and assign the result to left operandC -= A is equivalent to C = C - A
*=Multiply AND assignment operator, It multiplies right operand with the left operand and assign the result to left operandC *= A is equivalent to C = C * A
/=Divide AND assignment operator, It divides left operand with the right operand and assign the result to left operandC /= A is equivalent to C = C / A
%=Modulus AND assignment operator, It takes modulus using two operands and assign the result to left operandC %= A is equivalent to C = C % A
<<=Left shift AND assignment operatorC <<= 2 is same as C = C << 2
>>=Right shift AND assignment operatorC >>= 2 is same as C = C >> 2
&=Bitwise AND assignment operatorC &= 2 is same as C = C & 2
^=bitwise exclusive OR and assignment operatorC ^= 2 is same as C = C ^ 2
|=bitwise inclusive OR and assignment operatorC |= 2 is same as C = C | 2

Misc Operators

There are few other operators supported by Java Language.

Conditional Operator ( ? : ):

Conditional operator is also known as the ternary operator. This operator consists of three operands and is used to evaluate boolean expressions. The goal of the operator is to decide which value should be assigned to the variable. The operator is written as :
variable x = (expression) ? value if true : value if false

instanceOf Operator:

This operator is used only for object reference variables. The operator checks whether the object is of a particular type(class type or interface type). instanceOf operator is wriiten as:
( Object reference variable ) instanceOf  (class/interface type)

Precedence of Java Operators:

Category Operator Associativity 
Postfix () [] . (dot operator)Left to right 
Unary ++ - - ! ~Right to left 
Multiplicative  * / % Left to right 
Additive  + - Left to right 
Shift  >> >>> <<  Left to right 
Relational  > >= < <=  Left to right 
Equality  == != Left to right 
Bitwise AND & Left to right 
Bitwise XOR ^ Left to right 
Bitwise OR | Left to right 
Logical AND && Left to right 
Logical OR || Left to right 
Conditional ?: Right to left 
Assignment = += -= *= /= %= >>= <<= &= ^= |= Right to left 
Comma , Left to right 

The while Loop:

A while loop is a control structure that allows you to repeat a task a certain number of times.

Syntax:

The syntax of a while loop is:
while(Boolean_expression)
{
//Statements
}

The do...while Loop:

A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least one time.

Syntax:

The syntax of a do...while loop is:
do
{
//Statements
}while(Boolean_expression);

The for Loop:

A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times.
A for loop is useful when you know how many times a task is to be repeated.

Syntax:

The syntax of a for loop is:
for(initialization; Boolean_expression; update)
{
//Statements
}

Enhanced for loop in Java:

As of java 5 the enhanced for loop was introduced. This is mainly used for Arrays.

Syntax:

The syntax of enhanced for loop is:
for(declaration : expression)
{
//Statements
}

The break Keyword:

The break keyword is used to stop the entire loop. The break keyword must be used inside any loop or a switch statement.
The break keyword will stop the execution of the innermost loop and start executing the next line of code after the block.

The continue Keyword:

The continue keyword can be used in any of the loop control structures. It causes the loop to immediately jump to the next iteration of the loop.
  • In a for loop, the continue keyword causes flow of control to immediately jump to the update statement.
  • In a while loop or do/while loop, flow of control immediately jumps to the Boolean expression.

Syntax:

The syntax of a continue is a single statement inside any loop:
continue;

The if Statement:

An if statement consists of a Boolean expression followed by one or more statements.

Syntax:

The syntax of an if statement is:
if(Boolean_expression)
{
//Statements will execute if the Boolean expression is true
}

The if...else Statement:

An if statement can be followed by an optional else statement, which executes when the Boolean expression is false.

Syntax:

The syntax of a if...else is:
if(Boolean_expression){
//Executes when the Boolean expression is true
}else{
//Executes when the Boolean expression is false
}

The if...else if...else Statement:

An if statement can be followed by an optional else if...else statement, which is very usefull to test various conditions using single if...else if statement.

Syntax:

The syntax of a if...else is:
if(Boolean_expression 1){
//Executes when the Boolean expression 1 is true
}else if(Boolean_expression 2){
//Executes when the Boolean expression 2 is true
}else if(Boolean_expression 3){
//Executes when the Boolean expression 3 is true
}else {
//Executes when the one of the above condition is true.
}

Nested if...else Statement:

It is always legal to nest if-else statements. When using if , else if , else statements there are few points to keep in mind.
  • An if can have zero or one else's and it must come after any else if's.
  • An if can have zero to many else if's and they must come before the else.
  • Once an else if succeeds, none of he remaining else if's or else's will be tested.

Syntax:

The syntax for a nested if...else is as follows:
if(Boolean_expression 1){
//Executes when the Boolean expression 1 is true
if(Boolean_expression 2){
//Executes when the Boolean expression 2 is true
}
}

The switch Statement:

A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.

Syntax:

The syntax of enhanced for loop is:
switch(expression){
case value :
//Statements
break; //optional
case value :
//Statements
break; //optional
//You can have any number of case statements.
default : //Optional
//Statements
}

Java Methods:

A Java method is a collection of statements that are grouped together to perform an operation. When you call the System.out.println method, for example, the system actually executes several statements in order to display a message on the console.
In general, a method has the following syntax:
modifier returnValueType methodName(list of parameters) {
// Method body;
}
A method definition consists of a method header and a method body. Here are all the parts of a method:
  • Modifiers: The modifier, which is optional, tells the compiler how to call the method. This defines the access type of the method.
  • Return Type: A method may return a value. The returnValueType is the data type of the value the method returns. Some methods perform the desired operations without returning a value. In this case, the returnValueType is the keyword void.
  • Method Name: This is the actual name of the method. The method name and the parameter list together constitute the method signature.
  • Parameters: A parameter is like a placeholder. When a method is invoked, you pass a value to the parameter. This value is referred to as actual parameter or argument. The parameter list refers to the type, order, and number of the parameters of a method. Parameters are optional; that is, a method may contain no parameters.
  • Method Body: The method body contains a collection of statements that define what the method does.

Java Classes & Objects:

  • Object - Objects have states and behaviors. Example: A dog has states-color, name, breed as well as behaviors -wagging, barking, eating. An object is an instance of a class.
  • Class - A class can be defined as a template/ blue print that describe the behaviors/states that object of its type support.
A sample of a class is given below:
public class Dog{
String breed;
int age;
String color;

void barking(){
}

void hungry(){
}

void sleeping(){
}
}
A class can contain any of the following variable types.
  • Local variables . variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed when the method has completed.
  • Instance variables . Instance variables are variables within a class but outside any method. These variables are instantiated when the class is loaded. Instance variables can be accessed from inside any method, constructor or blocks of that particular class.
  • Class variables . Class variables are variables declared with in a class, outside any method, with the static keyword.

Exceptions Handling:

A method catches an exception using a combination of the try and catchkeywords. A try/catch block is placed around the code that might generate an exception. Code within a try/catch block is referred to as protected code, and the syntax for using try/catch looks like the following:
try
{
//Protected code
}catch(ExceptionName e1)
{
//Catch block
}

Multiple catch Blocks:

A try block can be followed by multiple catch blocks. The syntax for multiple catch blocks looks like the following:
try
{
//Protected code
}catch(ExceptionType1 e1)
{
//Catch block
}catch(ExceptionType2 e2)
{
//Catch block
}catch(ExceptionType3 e3)
{
//Catch block
}

The throws/throw Keywords:

If a method does not handle a checked exception, the method must declare it using the throws keyword. The throws keyword appears at the end of a method's signature.
You can throw an exception, either a newly instantiated one or an exception that you just caught, by using the throw keyword. Try to understand the different in throws and throw keywords.

The finally Keyword

The finally keyword is used to create a block of code that follows a try block. A finally block of code always executes, whether or not an exception has occurred.
Using a finally block allows you to run any cleanup-type statements that you want to execute, no matter what happens in the protected code.
A finally block appears at the end of the catch blocks and has the following syntax:
try
{
//Protected code
}catch(ExceptionType1 e1)
{
//Catch block
}catch(ExceptionType2 e2)
{
//Catch block
}catch(ExceptionType3 e3)
{
//Catch block
}finally
{
//The finally block always executes.
}