XII IP std-mat complete 2012-13 chap 1-4

Dear Students get latest New IP Question Bank 2012-13

chapter 1-4

 

 

 

GUWAHATI  REGION

 

STUDY MATERIAL

INFORMATICS PRACTICES (90)

Class – XII

Session: 2012-2013

 

Guidance

A.V.L. JAGANNADHA RAO

ASST. COMMISSIONER

RO, KVS, GUWAHATI

Kendriya Vidyalaya Sangathan, GUWAHATI  Region

Advisor

   K.L.NAGARAJU

 Assistant Commissioner

Kendriya Vidyalaya Sangathan, GUWAHATI  Region

Regional Convener

S.Laxmi Narayanan

PRINCIPAL, KV Digaru

 

 

By Amit Kumar,PGT Computer Science,Digaru

 

 

 

 

 

 

SPLIT – UP SYLLABUS

 

Class XII Informatics Practices (Theory)

 

 

Month

 

Chapter No.

 

 

 

Name of Chapter

No of

 

Theory Periods

No of

 

Practical Periods

April -May 1 Computer Networking 10
2 Open Source Concepts 10 4
June 3 Java Revision –I (Programming Fundamentals) 4 4
July 4 Java Revision -II

 

(GUI Swing Controls)

4 4
5 Java Revision -III (Class & Objects) 4 4
6 JAVA Classes and Libraries 4 5
August 7 Concept of Inheritance 5 4
8 GUI Dialogs & Tables 5 5
9 Database Connectivity 6 8
September 10 Web Application Developments 2
11 HTML-I (Basic Tags) 3 3
12 HTML-II (Advance Tags) 3 3
13 Introduction to XML 2
REVISION  
October 14 MySQL Revision 15 10
15 Database Transaction 5 6
16 Advance SQL

 

(Grouping & Table Joins)

15 10
November 17 Tables & Integrity Constraints 7 10
18 IT Applications 6  

20

Dec-Jan REVISION, Pre Board & Project Work  
 

TOTAL     110+  Revision

110 100

 

DETAILED SPLIT – UP SYLLABUS

Class XII

Informatics Practices (New Syllabus)

 

 

Unit Topic Period Marks
Theory Practical Theory Practical
1 Introduction to Computer Systems 20 04 10 02
2 Introduction to Programming 42 40 25 16
3 Relational Database Management System 42 36 30 08
4 IT Application 06 20 05 04
  Total 110 100 70 30

 

UNIT 1: Networking & Open Standard                               Marks: Theory [10] – Practical [02]

 

April-May(Before Summer Vacation)

 

Computer Networking:                                                 Periods: Theory [10] – Practical [00]

 

Networking  –  a  brief  overview,  Basic  concept  of  domain  name,  MAC,  and  IP  Address,  Identifying computers  and users over a network (Domain  Name, MAC ‘Media  Access  Control’ and IP address), domain name resolution, Network Topologies, Types of network – LAN, MAN, WAN, PAN; Wired Technologies  – Co-Axial, Ethernet Cable, Optical Fiber; Wireless Technologies  – Blue Tooth, Infrared, Microwave,  Radio Link, Satellite Link; Network Devices – Hub, Switch, Repeater, Gateway – and their functions Network security – denial of service, intrusion problems, snooping.

 

OpenSourceConcepts:                                               Periods: Theory [10] – Practical [04]

 

Open Source Software (OSS), common FOSS/FLOSS examples (e.g.Gnu/Linux, Firefox, OpenOffice), common open standards (open document format Ogg Vorbis)

 

Indian Language  Computing:  character encoding,  UNICODE,  different types of fonts (open type vs true type, static vs dynamic), Entering Indian Language Text – phonetic and key map based.

 

UNIT2:JAVA Programming

Marks: Theory [25] – Practical [16]

 

June

 

Java Revision of Class XI- I (Programming Fundamentals) Periods: Theory [04] – Practical [04]

Data Types & Variables:Concept  of data types; Built-in data types – byte, short, int, long, float, double, char, String (or any object), Boolean; Declaring Variables, Variable Naming Convention, Assigning value to Variables; Parsing methods, Data type conversion.

Operators: Types of Operators, Operators Precedence, using operators to form statements.

Control Structures: Decision Structure – if, if-else, switch; Looping Structure- while, do-while, for;

July

 

Java Revision of Class XI- II (GUI Swing Controls)

     Periods: Theory [04] – Practical [04]

 

Java Swing User Interface components– Frame, Dialog, OptionPane, Panel, ScrollPane, Label, TextField, PasswordField, TextArea, Buttob, CheckBox, RadioButton, ComboBox, List, Table, FileChooser, ColorChooser, ToolBar, Menu. Basic component handling methods/attributes. setText, getText, add, isSelected, setSelected, getX, getY, addActionListener.

 

Working with Swing controls (jButtons, jLabel, jTextField, jRadioButton, jCheckBox, jButtonGroup, jComboBox,  jList, (With commonly used properties and methods)

 

Java Revision of Class XI- III (Introduction to Class & Objects) Periods: Theory [04] – Practical [04]Introduction to Classes- Class, objects, types of members in classes, methods in classes, referencing object’s member.Concept of constructor methods,Use of constructors, types of constructors.

 

Concept of Methods- Need, prototypes, passing arguments, designing simple methods.

 

Programming Guidelines- Stylistic Guidelines; Debugging programs- Syntax Errors, Run-Time Errors, Logical Errors; Program Maintenance.

 

Java Classes and Libraries

 

Periods: Theory [04] – Practical [05]

 

Commonly used libraries: String class and methods: toString(), concat(), ength(), toLowerCase(), toUpperCase(), trim(), substring() Math object: pow(), round()

Basic concept of Access specifier (public, private, protected, private protected and default) for classes, Members and methods.

 

August

 

Concept of Inheritance:     Periods: Theory [05] – Practical [04]

 

Basic concept of Inheritance: Need, types, use of Access specifiers in inheritance, private Method Overloading and Overriding, Abstract Class and Interfaces, use of interfaces.

 

GUI Dialogs and Table:      Periods: Theory [05] – Practical [05]

 

Use of Dialogs (Input, Message and confirm dialogs); using jTable and JOptionPane in the application. Database Connectivity:           Periods: Theory [06] – Practical [08] Accessing MySQL database using ODBC/JDBC to connect with database.

September

 

Web Application Development: Periods: Theory [02]- Practical [00]

 

Web application development: URL, Web Server, Communicating with the web server, concept of Client and Server Side.

 

HTML Basics   Periods: Theory [03] – Practical [03]

 

HTML based web pages covering basic tags – HTML, TITLE, BODY, H1..H6, Paragraph (P), Line Break (BR), Section Separator (HR), FONT and commonly used Tags.

 

HTML Advanced     Periods: Theory [03] – Practical [03]

 

Html advanced Tag: LIST (UL, OL), TABLE, FORM: use of Form, commonly used Input Tag; Creating and accessing static pages using HTML.

 

Introduction to XML Periods: Theory [02] – Practical [00]

 

XML – Introduction; HTML vs XML; Features etc.

 

 

R evisio n & C u mu lative T est

 

October

 

UNIT 3: Relational Database Management Systems      Marks: Theory [30] – Practical [08] Review of RDBMS from Class XI   Periods: Theory [15] – Practical [10]

Introduction to database concepts: Advantages of DBMS; Data Model; Relation/Table, attribute/fields,

Tuple / Rows; Concept of Keys- Primary Key, Candidate key, Alternate key;

 

Introduction to MySQL: Features, data types (ANSI SQL 99 standard commands)

 

SQL commands: DML (SELECT, INSERT, UPDATE, DELETE); DDL( CREATE, DROP, ALTER); Working with SQL SELECT Statement:  Selecting  All or Specific Column,  Using Arithmetic  Operators, Defining and using Column Alias, Using Comparison  operators – =, <, >, <=, >=, < >, BETWEEN,  IN,LIKE(%),  Logical  Operators    -AND,  OR,  NOT;  Displaying  Table  Structure;  using  WHERE  clause,Working with Character Strings and Dates, Working with NULL values; ORDER BY Clause, Sorting in Ascending/Descending  Order, Sorting By Column Alias Name, Sorting On Multiple Columns;

 

MySQL  functions:   String  Function  –  CHAR(),  CONCAT(),INSTR(),   LCASE(),   LEFT(),  LOWER(), LENGTH(), LTRIM(), MID(), RIGHT(), RTRIM(), SUBSTR(), TRIM(), UCASE(), UPPER().Mathematical Functions – POWER(), ROUND(), TRUNCATE().Date and Time Functions – CURDATE() , DATE(), MONTH(), YEAR(), DAYNAME(),  DAYOFMONTH(), DAYOFWEEK(), DAYOFYEAR(), NOW(), SYSDATE().

 

Manipulation data: Inserting New Records, Inserting New Rows with Null Values, Inserting NUMBER, CHAR and DATE Values, Update Statement to Change Existing Data of a Table, Updating Rows in A Table, Delete statement – removing row/rows from a Table;Creating  Table  using  CREATE  TABLE,  ALTER  TABLE  for  adding  a  new  column,  using  naming conventions for column names;

 

Database Transactions

Periods: Theory [05] – Practical [06]

 

Concept of Database Transaction, Committing and revoking a Transaction using COMMIT and ROLLBACK, working with SAVEPOINTS.

 

Advanced SQL- Grouping & Table Joins Periods: Theory [15] – Practical [10]

 

Grouping Records: GROUP BY, Group functions – MAX(), MIN(), AVG(), SUM(), COUNT(); using COUNT(*), DISTINCT clause with COUNT, Group Functions and Null Values,
Displaying Data From Multiple Tables: Cartesian product, Union, concept of Foreign Key, Equi-

Join

A u t u m n   B r e a k

 

 

 

 

November

 

Table and Integrity Constraints

Periods: Theory [07] – Practical [10]

 

Creating a Table with PRIMARY KEY and NOT NULL constraints, adding a Constraint, enabling Constraints, Viewing Constraints, Viewing the Columns Associated with Constraints;ALTER TABLE for deleting a column, ALTER TABLE for modifying data types of a column DROP Table for deleting a table;

 

 

 

 

UNIT 4: IT Applications          Marks: Theory [05] – Practical [04] IT Applications Period: Theory [06]- Practical [20]

Review of IT Tools of Class XI: Definition, Benefits, salient features and societal impacts of e-

governance, e – Business, e-Learning.

 

 

 

 

Front-end Interface – Introduction; content and features; identifying and using appropriate component (Text Box, Radio Button, CheckBox, List) for data entry, validation and display;

 

Back-end Database – Introduction and its purpose; exploring the requirement of tables and its essential attributes;Front-End and Database Connectivity – Introduction, requirement and benefits Demonstration and development of appropriate Front-end interface and Back-end Database for e-Governance, e-Business and e-Learning applications

 

December – Feb

 

 

 

 

lRevision

l Pre-Board,

l Project Work

l Practical Examination.

 

March:

 

A ISSC E xa min atio n s

 

COMPUTER NETWORKING

 

 

Learning objectives

 

After learning this chapter the students will be able to:

 

  • Define what a Computer Network is

 

  • List the benefits of networking

 

  • List different wired and wireless media for communication

 

  • Identify different network devices

 

  • Identify the type of network on the basis of area covered

 

  • Describe various terms associated with computer networks.

 

  • List various security threats to computer networks

 

  • List the preventive and corrective measures against these threats

 

 

AN IDEA ABOUT NETWORK INTERNET AND

 DEVELOPMENT OF NEW ERA OF TECHNOLOGY

 

 

A   computer network, or simply a   network , is a collection of computers and other hardware components interconnected by communication channels that allow sharing of resources and information Where at least one process in one device is able to send receive data to from at least one process residing in a remote device, then the two devices are said to be in a network.

Simply, more than one computer interconnected through a communication medium for information interchange is called a computer network. Networks may be classified according to a wide variety of characteristics, such as the medium used to transport the data, communications protocol used, scale, topology , and organizational scope. Communications protocols define the rules and data formats for exchanging information in a computer network, and provide the basis for network programming .

Well-known communications protocols include Ethernet , a hardware and link layer standard that is ubiquitous in local area networks , and the Internet protocol suite , which defines a set of protocols for internetworking, i.e. for data communication between multiple networks, as well as host-to-host data transfer, and application-specific data transmission formats. Computer networking is sometimes considered a sub-discipline of electrical engineering , telecommunications , computer science , information technology or computer engineering , since it relies upon the theoretical and practical application of these disciplines.

 

Before the advent of computer networks that were based upon some type of telecommunications system, communication between calculation machines and early computers was performed by human users by carrying instructions between them. Many of the social behaviors seen in today’s Internet were demonstrably present in the 19th century and arguably in even earlier networks using visual signals.    In September 1940, George Stibitz used a Teletype machine to send instructions for a problem set from his Model at Dartmouth College to his Complex Number Calculator in New York and received results back by the same means. Linking output systems like teletypewriters to computers was an interest at the Advanced Research Projects Agency (ARPA) when, in 1962, J.C.R. Licklider was hired and developed a working group he called the “Intergalactic Computer Network “, a precursor to the ARPANET .

Early networks of communicating computers included the military radar system Semi-Automatic Ground Environment (SAGE), started in the late 1950s.    The commercial airline reservation system semi-automatic business research environment (SABRE) went online with two connected mainframes in 1960

In 1964, researchers at Dartmouth developed the Dartmouth Time Sharing System for distributed users of large computer systems. The same year, at Massachusetts Institute of Technology , a research group supported by General Electric and Bell Labs used a computer to route and manage telephone connections.    Throughout the 1960s Leonard Kleinrock , Paul Baran and Donald Davies independently conceptualized and developed network systems which used packets that could be used in a network between computer systems.

1965 Thomas Marill and Lawrence G. Roberts created the first wide area network (WAN). This was an immediate precursor to the ARPANET , of which Roberts became program manager.    The first widely used telephone switch that used true computer control was introduced by Western Electric in 1965.    In 1969 the University of California at Los Angeles , the Stanford Research Institute , University of California at Santa Barbara , and the University of Utah were connected as the beginning of the ARPANET network using 50 kbit s circuits.

Commercial services using X.25 were deployed in 1972, and later used as an underlying infrastructure for expanding TCP IP networks. Today, computer networks are the core of modern communication. All modern aspects of the public switched telephone network (PSTN) are computer-controlled, and telephony increasingly runs over the Internet Protocol, although not necessarily the public Internet. The scope of communication has increased significantly in the past decade, and this boom in communications would not have been possible without the progressively advancing computer network. Computer networks, and the technologies needed to connect and communicate through and between them, continue to drive computer hardware, software, and peripherals industries. This expansion is mirrored by growth in the numbers and types of users of networks, from the researcher to the home user. Interconnected collection of autonomous computers(unique identity) is known as computer network .

Properties  : Computer networks: Facilitate communications Using a network, people can communicate efficiently and easily via email, instant messaging, chat rooms, telephone, video telephone calls, and video conferencing. Permit sharing of files, data, and other types of information In a network environment, authorized users may access data and information stored on other computers on the network. The capability of providing access to data and information on shared storage devices is an important feature of many networks. Share network and computing resources In a networked environment, each computer on a network may access and use resources provided by devices on the network, such as printing a document on a shared network printer.

Distributed computing uses computing resources across a network to accomplish tasks. May be insecure A computer network may be used by computer hackers to deploy computer viruses or computer worms on devices connected to the network, or to prevent these devices from normally accessing the network (denial of service ). May interfere with other technologies Power line communication strongly disturbs certain forms of radio communication, e.g., amateur radio.

It may also interfere with last mile access technologies such as ADSL and VDSL .May be difficult to set up A complex computer network may be difficult to set up. It may also be very costly to set up an effective computer network in a large organization or company. Communication media Computer networks can be classified according to the hardware and associated software technology that is used to interconnect the individual devices in the network, such as electrical cable (HomePNA , power line communication , G.hn ), optical fiber , and radio waves (wireless LAN ). In the OSI model , these are located at levels 1 and 2. A well-known  family  of communication media is collectively known as Ethernet . It is defined by IEEE 802 and utilizes various standards and media that enable communication between devices. Wireless LAN technology is designed to connect devices without wiring. These devices use radio waves or infrared signals as a transmission medium.

Wired technologies The order of the following wired technologies is, roughly, from slowest to fastest transmission speed.

Twisted pair wire  is the most widely used medium for telecommunication. Twisted-pair cabling consist of copper wires that are twisted into pairs. Ordinary telephone wires consist of two insulated copper wires twisted into pairs. Computer networking cabling (wired Ethernet as defined by IEEE 802.3 ) consists of 4 pairs of copper cabling that can be utilized for both voice and data transmission. The use of two wires twisted together helps to reduce crosstalk and electromagnetic induction . The transmission speed ranges from 2 million bits per second to 10 billion bits per second. Twisted pair cabling comes in two forms: unshielded twisted pair (UTP) and shielded twisted-pair (STP). Each form comes in several category ratings, designed for use in various scenarios.     Coaxial cable   is widely used for cable television systems, office buildings, and other work-sites for local area networks. The cables consist of copper or aluminum wire surrounded by an insulating layer (typically a flexible material with a high dielectric constant), which itself is surrounded by a conductive layer. The insulation helps minimize interference and distortion. Transmission speed ranges from 200 million bits per second to more than 500 million bits per second..hn technology uses existing home wiring (coaxial cable , phone lines and power lines ) to create a high-speed (up to 1 Gigabit s) local area network.    An optical fiber is a glass fiber. It uses pulses of light to transmit data. Some advantages of optical fibers over metal wires are less transmission loss, immunity from electromagnetic radiation, and very fast transmission speed, up to trillions of bits per second. One can use different colors of lights to increase the number of messages being sent over a fiber optic cable.

Wireless technologies     Terrestrial microwave Terrestrial microwave communication uses Earth-based transmitters and receivers resembling satellite dishes. Terrestrial microwaves are in the low-gigahertz range, which limits all communications to line-of-sight. Relay stations are spaced approximately 48 km (30 mi) apart.     Communications satellites   – The satellites communicate via microwave radio waves, which are not deflected by the Earth’s atmosphere. The satellites are stationed in space, typically in geosynchronous orbit 35,400 km (22,000 mi) above the equator. These Earth-orbiting systems are capable of receiving and relaying voice, data, and TV signals.

Cellular and PCS systems  use several radio communications technologies. The systems divide the region covered into multiple geographic areas. Each area has a low-power transmitter or radio relay antenna device to relay calls from one area to the next area.     Radio and spread spectrum technologies Wireless local area network use a high-frequency radio technology similar to digital cellular and a low-frequency radio technology. Wireless LANs use spread spectrum technology to enable communication between multiple devices in a limited area. IEEE 802.11 defines a common flavor of open-standards wireless radio-wave technology.    Infrared communication can transmit signals for small distances, typically no more than 10 meters. In most cases, line-of-sight propagation is used, which limits the physical positioning of communicating devices.

A global area network (GAN) is a network used for supporting mobile across an arbitrary number of wireless LANs, satellite coverage areas, etc. The key challenge in mobile communications is handing off user communications from one local coverage area to the next. In IEEE Project 802, this involves a succession of terrestrial wireless LANs .Exotic technologies There have been various attempts at transporting data over more or less exotic media:    IP over Avian Carriers was a humorous April fool’s Request for Comments , issued as   RFC 1149   . It was implemented in real life in 2001.Extending the Internet to interplanetary dimensions via radio waves. Both cases have a large round-trip delay time , which prevents useful communication. Communications protocols and network programming Internet map. The Internet is a global system of interconnected computer networks that use the standard Internet Protocol Suite (TCP IP) to serve billions of users worldwide. Main article: Communications protocol A communications protocol is a set of rules for exchanging information over a network. It is typically a protocol stack (also see the OSI model ), which is a “stack” of protocols, in which each protocol uses the protocol below it. An important example of a protocol stack is HTTP running over TCP over IP over IEEE 802.11 (TCP and IP are members of the Internet Protocol Suite , and IEEE 802.11 is a member of the Ethernet protocol suite). This stack is used between the wireless router and the home user’s personal computer when the user is surfing the web. Communication protocols have various properties, such as whether they are connection-oriented or connectionless , whether they use circuit mode or packet switching , or whether they use hierarchical or flat addressing. There are many communication protocols, a few of which are described below.

Ethernet Main article: Ethernet Ethernet is a family of connectionless protocols used in LANs, described by a set of standards together called IEEE 802 published by the Institute of Electrical and Electronics Engineers . It has a flat addressing scheme and is mostly situated at levels 1 and 2 of the OSI model . For home users today, the most well-known member of this protocol family is IEEE 802.11 , otherwise known as Wireless LAN (WLAN). However, the complete protocol suite deals with a multitude of networking aspects not only for home use, but especially when the technology is deployed to support a diverse range of business needs. MAC bridging (IEEE 802.1D ) deals with the routing of Ethernet packets using a Spanning Tree Protocol , IEEE 802.1Q describes VLANs , and IEEE 802.1X defines a port-based Network Access Control protocol, which forms the basis for the authentication mechanisms used in VLANs, but it is also found in WLANs  it is what the home user sees when the user has to enter a “wireless access key”. Internet Protocol Suite The Internet Protocol Suite , often also called TCP IP, is the foundation of all modern internetworking. It offers connection-less as well as connection-oriented services over an inherently unreliable network traversed by datagram transmission at the Internet protocol (IP) level. At its core, the protocol suite defines the addressing, identification, and routing specification in form of the traditional Internet Protocol Version 4 (IPv4) and IPv6, the next generation of the protocol with a much enlarged addressing capability. SONET SDH Main article: Synchronous optical networking Synchronous Optical Networking (SONET) and Synchronous Digital Hierarchy (SDH) are standardized multiplexing protocols that transfer multiple digital bit streams over optical fiber using lasers. They were originally designed to transport circuit mode communications from a variety of different sources, primarily to support real-time, uncompressed, circuit-switched voice encoded in PCM (Pulse-Code Modulation) format. However, due to its protocol neutrality and transport-oriented features, SONET SDH also was the obvious choice for transporting Asynchronous Transfer Mode (ATM) frames.       Asynchronous Transfer Mode Main article: Asynchronous transfer mode Asynchronous Transfer Mode (ATM) is a switching technique for telecommunication networks. It uses asynchronous time-division multiplexing and encodes data into small, fixed-sized cells . This differs from other protocols such as the Internet Protocol Suite or Ethernet that use variable sized packets or frames . ATM has similarity with both circuit and packet switched networking. This makes it a good choice for a network that must handle both traditional high-throughput data traffic, and real-time, low-latency content such as voice and video. ATM uses a connection-oriented model in which a virtual circuit must be established between two endpoints before the actual data exchange begins. While the role of ATM is diminishing in favor of next-generation networks , it still plays a role in the last mile , which is the connection between an Internet service provider and the home user. For an interesting write-up of the technologies involved, including the deep stacking of communications protocols used, see. Network programming Main article: Computer network programming Main article: Network socket Computer network programming involves writing computer programs that communicate with each other across a computer network. Different programs must be written for the client process, which initiates the communication, and for the server process, which waits for the communication to be initiated. Both endpoints of the communication flow are implemented as network sockets ; hence network programming is basically socket programming.

Scale   Computer network   types by geographical scope    Near field (NFC)    Body (BAN)    Personal (PAN)    Near-me (NAN)    Local (LAN) o Home (HAN) o Storage (SAN)    Campus (CAN)    Backbone    Metropolitan (MAN)    Wide (WAN)

 

Interplanetary Internet    Networks are often classified by their physical or organizational extent or their purpose. Usage, trust level, and access rights differ between these types of networks.

Personal area network A personal area network (PAN) is a computer network used for communication among computer and different information technological devices close to one person. Some examples of devices that are used in a PAN are personal computers, printers, fax machines, telephones, PDAs, scanners, and even video game consoles. A PAN may include wired and wireless devices. The reach of a PAN typically extends to 10 meters. A wired PAN is usually constructed with USB and Firewire connections while technologies such as Bluetooth and infrared communication typically form a wireless PAN.  Local area network A local area network (LAN) is a network that connects computers and devices in a limited geographical area such as home, school, computer laboratory, office building, or closely positioned group of buildings. Each computer or device on the network is a node. Current wired LANs are most likely to be based on Ethernet technology, although new standards like ITU-T G.hn also provide a way to create a wired LAN using existing home wires (coaxial cables, phone lines and power lines). Typical library network, in a branching tree topology and controlled access to resources A sample LAN is depicted in the accompanying diagram. All interconnected devices must understand the network layer (layer 3), because they are handling multiple subnets (the different colors). Those inside the library, which have only 10 100 Mbit s Ethernet connections to the user device and a Gigabit Ethernet connection to the central router, could be called “layer 3 switches” because they only have Ethernet interfaces and must understand IP . It would be more correct to call them access routers, where the router at the top is a distribution router that connects to the Internet and academic networks’ customer access routers. The defining characteristics of LANs, in contrast to WANs (Wide Area Networks), include their higher data transfer rates, smaller geographic range, and no need for leased telecommunication lines. Current Ethernet or other IEEE 802.3 LAN technologies operate at data transfer rates up to 10 Gbit s. IEEE has projects investigating the standardization of 40 and 100 Gbit LANs can be connected to Wide area network by using routers.

Home area network A home area network (HAN) is a residential LAN which is used for communication between digital devices typically deployed in the home, usually a small number of personal computers and accessories, such as printers and mobile computing devices. An important function is the sharing of Internet access, often a broadband service through a cable TV or Digital Subscriber Line (DSL) provider.

Storage area network A storage area network (SAN) is a dedicated network that provides access to consolidated, block level data storage. SANs are primarily used to make storage devices, such as disk arrays, tape libraries, and optical jukeboxes, accessible to servers so that the devices appear like locally attached devices to the operating system. A SAN typically has its own network of storage devices that are generally not accessible through the local area network by other devices. The cost and complexity of SANs dropped in the early 2000s to levels allowing wider adoption across both enterprise and small to medium sized business environments.

Campus area network A campus area network (CAN) is a computer network made up of an interconnection of LANs within a limited geographical area. The networking equipment (switches, routers) and transmission media (optical fiber, copper plant, Cat5 cabling etc.) are almost entirely owned (by the campus tenant   owner: an enterprise, university, government etc.). In the case of a university campus-based campus network, the network is likely to link a variety of campus buildings including, for example, academic colleges or departments, the university library, and student residence halls.

Backbone network A backbone network is part of a computer network infrastructure that interconnects various pieces of network, providing a path for the exchange of information between different LANs or subnetworks. A backbone can tie together diverse networks in the same building, in different buildings in a campus environment, or over wide areas. Normally, the backbone’s capacity is greater than that of the networks connected to it. A large corporation which has many locations may have a backbone network that ties all of these locations together, for example, if a server cluster needs to be accessed by different departments of a company which are located at different geographical locations. The equipment which ties these departments together constitute the network backbone. Network performance management including network congestion are critical parameters taken into account when designing a network backbone. A specific case of a backbone network is the Internet backbone , which is the set of wide-area network connections and core routers that interconnect all networks connected to the Internet .

Metropolitan area network A Metropolitan area network (MAN) is a large computer network that usually spans a city or a large campus. Sample EPN made of Frame relay WAN connections and dialup remote access. Sample VPN used to interconnect 3 offices and remote users       Wide area network A wide area network (WAN) is a computer network that covers a large geographic area such as a city, country, or spans even intercontinental distances, using a communications channel that combines many types of media such as telephone lines, cables, and air waves. A WAN often uses transmission facilities provided by common carriers, such as telephone companies. WAN technologies generally function at the lower three layers of the OSI reference model : the physical layer , the data link layer , and the network layer .

Enterprise private network An enterprise private network is a network built by an enterprise to interconnect various company sites, e.g., production sites, head offices, remote offices, shops, in order to share computer resources.

Virtual private network A virtual private network (VPN) is a computer network in which some of the links between nodes are carried by open connections or virtual circuits in some larger network (e.g., the Internet) instead of by physical wires. The data link layer protocols of the virtual network are said to be tunneled through the larger network when this is the case. One common application is secure communications through the public Internet, but a VPN need not have explicit security features, such as authentication or content encryption. VPNs, for example, can be used to separate the traffic of different user communities over an underlying network with strong security features. VPN may have best-effort performance, or may have a defined service level agreement (SLA) between the VPN customer and the VPN service provider. Generally, a VPN has a topology more complex than point-to-point.

 

Virtual Network Not to be confused with a Virtual Private Network , a Virtual Network defines data traffic flows between virtual machines within a hypervisor in a virtual computing environment. Virtual Networks may employ virtual security switches , virtual routers , virtual firewalls and other virtual networking devices to direct and secure data traffic.

Internetwork An internetwork is the connection of multiple computer networks via a common routing technology using routers. The Internet is an aggregation of many connected internetworks spanning the Earth .

Organizational scope Networks are typically managed by organizations which own them. According to the owner’s point of view, networks are seen as intranets or extranets. A special case of network is the Internet , which has no single owner but a distinct status when seen by an organizational entity that of permitting virtually unlimited global connectivity for a great multitude of purposes.

Intranets and extranets Intranets and extranets are parts or extensions of a computer network, usually a LAN. An intranet is a set of networks, using the Internet Protocol and IP-based tools such as web browsers and file transfer applications, that is under the control of a single administrative entity. That administrative entity closes the intranet to all but specific, authorized users. Most commonly, an intranet is the internal network of an organization. A large intranet will typically have at least one web server to provide users with organizational information. An extranet is a network that is limited in scope to a single organization or entity and also has limited connections to the networks of one or more other usually, but not necessarily, trusted organizations or entities a company’s customers may be given access to some part of its intranet while at the same time the customers may not be considered  trusted  from a security standpoint. Technically, an extranet may also be categorized as a CAN, MAN, WAN, or other type of network, although an extranet cannot consist of a single LAN; it must have at least one connection with an external network.

Internet  : The Internet is a global system of interconnected governmental, academic, corporate, public, and private computer networks. It is based on the networking technologies of the Internet Protocol Suite . It is the successor of the Advanced Research Projects Agency Network (ARPANET) developed by DARPA of the United States Department of Defense. The Internet is also the communications backbone underlying the World Wide Web (WWW). Participants in the Internet use a diverse array of methods of several hundred documented, and often standardized, protocols compatible with the Internet Protocol Suite and an addressing system (IP addresses ) administered by the Internet Assigned Numbers Authority and address registries . Service providers and large enterprises exchange information about the reachability of their address spaces through the Border Gateway Protocol (BGP), forming a redundant worldwide mesh of transmission paths.

Network topology       Common layouts A network topology is the layout of the interconnections of the nodes of a computer network. Common layouts are:

A bus network : all nodes are connected to a common medium along this medium. This was the layout used in the original Ethernet , called 10BASE5 and 10BASE2 .    A star network : all nodes are connected to a special central node. This is the typical layout found in a Wireless LAN , where each wireless client connects to the central Wireless access point .    A ring network : each node is connected to its left and right neighbour node, such that all nodes are connected and that each node can reach each other node by traversing nodes left- or rightwards.

The Fiber Distributed Data Interface (FDDI) made use of such a topology.    A mesh network : each node is connected to an arbitrary number of neighbours in such a way that there is at least one traversal from any node to any other.

A fully connected network: each node is connected to every other node in the network. Note that the physical layout of the nodes in a network may not necessarily reflect the network topology. As an example, with FDDI , the network topology is a ring (actually two counter-rotating rings), but the physical topology is a star, because all neighboring connections are routed via a central physical location.

Overlay network An overlay network is a virtual computer network that is built on top of another network. Nodes in the overlay are connected by virtual or logical links, each of which corresponds to a path, perhaps through many physical links, in the underlying network. The topology of the overlay network may (and often does) differ from that of the underlying one. A sample overlay network: IP over SONET over Optical For example, many peer-to-peer networks are overlay networks because they are organized as nodes of a virtual system of links run on top of the Internet. The Internet was initially built as an overlay on the telephone network. The most striking example of an overlay network, however, is the Internet itself: At the IP layer, each node can reach any other by a direct connection to the desired IP address, thereby creating a fully connected network; the underlying network, however, is composed of a mesh-like interconnect of subnetworks of varying topologies (and, in fact, technologies). Address resolution and routing are the means which allows the mapping of the fully connected IP overlay network to the underlying ones. Overlay networks have been around since the invention of networking when computer systems were connected over telephone lines using modems , before any data network existed. Another example of an overlay network is a distributed hash table , which maps keys to nodes in the network. In this case, the underlying network is an IP network, and the overlay network is a table (actually a map ) indexed by keys. Overlay networks have also been proposed as a way to improve Internet routing, such as through quality of service guarantees to achieve higher-quality streaming media .

 

Previous proposals such as IntServ , DiffServ , and IP Multicast have not seen wide acceptance largely because they require modification of all routers in the network.  citation needed    On the other hand, an overlay network can be incrementally deployed on end-hosts running the overlay protocol software, without cooperation from Internet service providers . The overlay has no control over how packets are routed in the underlying network between two overlay nodes, but it can control, for example, the sequence of overlay nodes a message traverses before reaching its destination. For example, Akamai Technologies manages an overlay network that provides reliable, efficient content delivery (a kind of multicast ). Academic research includes end system multicast and overcast for multicast; RON (resilient overlay network ) for resilient routing; and OverQoS for quality of service guarantees, among others.       Basic hardware components Main article: Networking hardware Apart from the physical communications media themselves as described above, networks comprise additional basic hardware building blocks interconnecting their terminals, such as network interface cards (NICs) , hubs , bridges , switches , and routers .

Network interface cards A network card , network adapter, or NIC (network interface card) is a piece of computer hardware designed to allow computers to physically access a networking medium. It provides a low-level addressing system through the use of MAC addresses . Each Ethernet network interface has a unique MAC address which is usually stored in a small memory device on the card, allowing any device to connect to the network without creating an address conflict. Ethernet MAC addresses are composed of six octets . Uniqueness is maintained by the IEEE , which manages the Ethernet address space by assigning 3-octet prefixes to equipment manufacturers. The list of prefixes is publicly available. Each manufacturer is then obliged to both use only their assigned prefix(es) and to uniquely set the 3-octet suffix of every Ethernet interface they produce.

Repeaters and hubs :  A repeater is an electronic device that receives a signal , cleans it of unnecessary noise, regenerates it, and retransmits it at a higher power level, or to the other side of an obstruction, so that the signal can cover longer distances without degradation. In most twisted pair Ethernet configurations, repeaters are required for cable that runs longer than 100 meters.

A repeater with multiple ports is known as a hub . Repeaters work on the Physical Layer of the OSI model. Repeaters require a small amount of time to regenerate the signal. This can cause a propagation delay which can affect network communication when there are several repeaters in a row. Many network architectures limit the number of repeaters that can be used in a row (e.g. Ethernet’s 5-4-3 rule ). Today, repeaters and hubs have been made mostly obsolete by switches (see below).

 

Bridges :  A network bridge connects multiple network segments at the data link layer (layer 2) of the OSI model . Bridges broadcast to all ports except the port on which the broadcast was received. However, bridges do not promiscuously copy traffic to all ports, as hubs do, but learn which MAC addresses are reachable through specific ports. Once the bridge associates a port and an address, it will send traffic for that address to that port only. Bridges learn the association of ports and addresses by examining the source address of frames that it sees on various ports. Once a frame arrives through a port, its source address is stored and the bridge assumes that MAC address is associated with that port. The first time that a previously unknown destination address is seen, the bridge will forward the frame to all ports other than the one on which the frame arrived.

Bridges come in three basic types:    Local bridges: Directly connect LANs    Remote bridges: Can be used to create a wide area network (WAN) link between LANs. Remote bridges, where the connecting link is slower than the end networks, largely have been replaced with routers.    Wireless bridges: Can be used to join LANs or connect remote stations to LANs.

Switches :  A network switch is a device that forwards and filters OSI layer 2 datagrams (chunks of data communication) between ports (connected cables) based on the MAC addresses in the packets A switch is distinct from a hub in that it only forwards the frames to the ports involved in the communication rather than all ports connected. A switch breaks the collision domain but represents itself as a broadcast domain. Switches make forwarding decisions of frames on the basis of MAC addresses. A switch normally has numerous ports, facilitating a star topology for devices, and cascading additional switches. Some switches are capable of routing based on Layer 3 addressing or additional logical levels; these are called multi-layer switches. The term  switch  is used loosely in marketing to encompass devices including routers and bridges, as well as devices that may distribute traffic on load or by application content (e.g., a Web URL identifier).

Routers A router is an internetworking device that forwards packets between networks by processing information found in the datagram or packet (Internet protocol information from Layer 3 of the OSI Model ). In many situations, this information is processed in conjunction with the routing table (also known as forwarding table). Routers use routing tables to determine what interface to forward packets (this can include the “null” also known as the “black hole” interface because data can go into it, however, no further processing is done for said data).

Firewalls A firewall is an important aspect of a network with respect to security. It typically rejects access requests from unsafe sources while allowing actions from recognized ones. The vital role firewalls play in network security grows in parallel with the constant increase in ‘cyber’ attacks for the purpose of stealing corrupting data, planting viruses, etc.

Network performance Main article: network performance   Network performance   refers to the service quality of a telecommunications product as seen by the customer. It should not be seen merely as an attempt to get “more through” the network. The following list gives examples of Network Performance measures for a circuit-switched network and one type of packet-switched network , viz.

ATM:  Circuit-switched networks: In circuit switched networks, network performance is synonymous with the grade of service . The number of rejected calls is a measure of how well the network is performing under heavy traffic loads. Other types of performance measures can include noise, echo and so on.

ATM: In an Asynchronous Transfer Mode (ATM) network, performance can be measured by line rate, quality of service (QoS), data throughput, connect time, stability, technology, modulation technique and modem enhancements.

There are many different ways to measure the performance of a network, as each network is different in nature and design. Performance can also be modeled  instead of measured; one example of this is using state transition diagrams to model queuing performance in a circuit-switched network. These diagrams allow the network planner to analyze how the network will perform in each state, ensuring that the network will be optimally designed.

Network security Main article: network security In the field of networking, the area of   network security   consists of the provisions and policies adopted by the network administrator to prevent and monitor unauthorized access, misuse, modification, or denial of the computer network and network-accessible resources. Network security is the authorization of access to data in a network, which is controlled by the network administrator. Users are assigned an ID and password that allows them access to information and programs within their authority. Network Security covers a variety of computer networks, both public and private that are used in everyday jobs conducting transactions and communications among businesses, government agencies and individuals.

Network resilience Main article: resilience (network) In computer networking: Resilience   is the ability to provide and maintain an acceptable level of service in the face of faults and challenges to normal operation.

Views of networks Users and network administrators typically have different views of their networks. Users can share printers and some servers from a workgroup, which usually means they are in the same geographic location and are on the same LAN, whereas a Network Administrator is responsible to keep that network up and running. A community of interest has less of a connection of being in a local area, and should be thought of as a set of arbitrarily located users who share a set of servers, and possibly also communicate via peer-to-peer technologies. Network administrators can see networks from both physical and logical perspectives. The physical perspective involves geographic locations, physical cabling, and the network elements (e.g., routers , bridges and application layer gateways ) that interconnect the physical media. Logical networks, called, in the TCP IP architecture, subnets , map onto one or more physical media. For example, a common practice in a campus of buildings is to make a set of LAN cables in each building appear to be a common subnet, using virtual LAN (VLAN) technology. Both users and administrators will be aware, to varying extents, of the trust and scope characteristics of a network. Again using TCP IP architectural terminology, an intranet is a community of interest under private administration usually by an enterprise, and is only accessible by authorized users (e.g. employees).

Intranets do not have to be connected to the Internet, but generally have a limited connection. An extranet is an extension of an intranet that allows secure communications to users outside of the intranet (e.g. business partners, customers).

Unofficially, the Internet is the set of users, enterprises, and content providers that are interconnected by Internet Service Providers (ISP). From an engineering viewpoint, the Internet is the set of subnets, and aggregates of subnets, which share the registered IP address space and exchange information about the reachability of those IP addresses using the Border Gateway Protocol . Typically, the human-readable names of servers are translated to IP addresses, transparently to users, via the directory function of the Domain Name System (DNS). Over the Internet, there can be business-to-business (B2B) , business-to-consumer (B2C) and consumer-to-consumer (C2C) communications. Especially when money or sensitive information is exchanged, the communications are apt to be   secured   by some form of communications security mechanism. Intranets and extranets can be securely superimposed onto the Internet, without any access by general Internet users and administrators, using secure Virtual Private Network (VPN) technology.

More about Nework and Internet

 

 

Have you ever worked on Internet? Have you ever used an ATM? Have you ever given the print command on a computer to get the printout on a printer attached to some other computer? Have you ever transferred songs from your computer to a cell phone or vice-versa? If the answer to any of these questions is YES, then you have experienced and utilized the services of a computer network. In this chapter you will study about various types of computer networks, their benefits, and what

is required to create computer networks.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Networking – a brief overview

 

A computer network is a collection of interconnected computers and other devices which are able to communicate with each other. In this context, the term interconnected means that there exists a path through which data can be transmitted from one computer/device to another.

 

 

A computer network is a collection of interconnected computers and other devices which are able to communicate with each other and share hardware and software resources.

 

Why do we have computer networks? Are there any advantages of networked computers over stand alone computers? Yes, there are many. A few of these advantages are:

 

  • Resource Sharing

 

  • Cost saving

 

  • Collaborative user interaction

 

  • Time saving

 

  • Increased storage

 

Let us discuss these advantages in some details.

 

Resource Sharing:

 

In a networked computer lab when print command is given on one computer the document may be printed by the printer which is attached to some other computer. This printer is able to print documents from multiple users on the network. It means that the printer is being shared by more than one users. This is an example of resource sharing, and this is possible only when the computers are interconnected to form a network. Similarly other resources like Hard Disk, DVD Drive, and Scanner etc. can also be shared on a computer network. Software resources like Application Softwares, Anti-Virus tools etc. can also be shared on computer networks. You can very easily conclude that this

resource sharing also leads to cost-saving.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

COMPUTER NETWORKING

 

 

 

Collaborative User Interaction:

 

Let us take one more example of a school. Here we assume that all the computers in the school are connected to one main computer (called server). After the exams, teachers have to exchange marks with each other for result preparation. So all the teachers enter the marks class wise for their respective subjects at one centralized location and from there the class teachers can copy the marks of their classes and can prepare the result. This way data is shared on a computer network. Similar is the case with other computerized organizations also.

Let us take another example of collaborative user interaction. If we are working on a computer which is a part of a computer network, we can communicate with any other user of the network through e-mail or chatting. It takes negligible time to send and receive messages and watch live videos of one another irrespective of terrestrial distances. If the e-mail or chatting is done for some useful purpose, it leads to increased productivity, cost-saving as well as time-saving.

 

Increased Storage:

 

On a network, same data may be replicated on multiple computers to ensure the availability of data in the case of some computer getting faulty. For example, when you save your java applications on your computer, you can also store their copies on some other networked computers in your lab. This way your work will be available even if your computer develops some fault or somehow your programs are deleted from your computer. Similarly, on large networks also the data is replicated on multiple computers as if a huge storage area is available to store multiple copies of the data.

All these advantages are there for a small organization like a school as well as for big business organizations and for governments. Today, small as well as big organizations, and governments keep their data on secured large scale computers called servers. They share this data with authorized users. This ensures security. Customer care cells of companies share the resources and data and they also communicate among themselves as well as with customers with the help of computer networks only.

 

 

 

 

 

 

 

 

 

3

 

 

 

 

 

 

 

 

COMPUTER NETWORKING

 

 

 

Networking Hardware

 

To form a computer network a lot of hardware devices are required. Some of these

devices along with their functionalities are mentioned below :

 

Transmission Media

 

Computers on a network are able to share data and other resources. They are also able to communicate among themselves. To make all this possible there must be some medium over which the data can travel from one computer to another. A medium of data transmission over a computer network is called a channel or a transmission medium. Channels may be guided (wired) or unguided (wireless).

 

A transmission medium is a medium of data transfer over a network. It can be wired or wireless.

 

 

Wired Media

 

A number of various types of cables are used to transfer data over computer networks.

These are Twisted Pair Cable, Co-axial Cable, and Optical Fiber Cable. Let us know about these in some details.

 

 

Twisted Pair Cable –

This is probably the most widely used cable for creating small

 

computer networks. It contains four twisted pairs covered in an outer shield. These pairs are colour coded. An RJ-45 connecter is used to connect this cable to a computer. It is of two types:

UTP (Unshielded Twisted Pair): As the name suggests in UTP cables individual pairs are not shielded.

 

 

 

UTP Cable                                   UTP Cable

With RJ-45 Connector

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Characteristics of UTP cable:

 

  • It is a low-cost cable available for setting up small networks.

 

  • It is a thin (External diameter app. 0.43cm) and flexible cable and therefore it offers ease of installation.

 

  • It can carry data upto a length of 100m at a stretch.

 

STP (Shielded Twisted pair): It is the same cable as the UTP, but with each pair shielded individually. An outer shield then covers all the pairs like in UTP. STP data connectors are used to connect STP cable to the computer. RJ-45 connectors can also be used to connect this cable to a computer.

 

Characteristics of STP cable:

 

  • As compared to UTP, STP offers better immunity against internal and external electromagnetic interferences.

 

  • It is expensive than UTP cable.

 

  • As compared to UTP cable, STP cable is difficult to install.

 

 

Co-axial cable (or coax) –A coaxialCopper Wirecable consists of two conductors that share a common axis. The inner conductor is a straight wire and the outer conductor is a shield that might be braided or a foil.

 

Characteristics of Co-axial cable:

 

  • It can carry data for a larger distance (185m – 500m) at a stretch.

 

  • Less susceptible to electromagnetic fields

 

  • Bulkier and less flexible than twisted pair.

 

  • Due to its thickness (1cm diameter) and less flexibility, it is difficult to install as compared to twisted pair cable.

 

Earlier coaxial cable was also used for connecting computers in small networks but now

UTP/STP cables are more commonly used for this purpose.NETWORKING

 

 

Optical Fiber cable – Optical Fibers are long, thin strands of glass about the thickness of a human hair. They are arranged in bundles called optical fiber cables and used to transmit data through light signals over long distances.

 

An optical fiber has following parts:

 

 

Jacket Buffer Cladding      Core

 

  • Core – It is the thin glass rod at the center through which the light travels

 

  • Cladding – It is the outer optical material surrounding the core that reflects the light back into the core
  • Buffer coating – It is the plastic coating that protects the cable from damage and moisture

 

These optical fibers are arranged in bundles of hundreds and thousands and are protected by the cable’s outer covering, called jacket.

 

Characteristics of Optical Fiber Cable:

 

  • It can carry data for a very large distance at a stretch.

 

  • Not susceptible to electromagnetic fields

 

  • Specially skilled people are required to install optical fiber cables.

 

  • Till date it is the most expensive and at the same time the most efficient cable available for computer networks.

 

Comparison of wired media

 

Cable       Twisted Pair         Coaxial Cable          Optical Fiber Paramater                                             Cable                                                       Cable

 

Data Transfer Rate      10Mbps-10Gbps          100 Mbps          More than100 Gbps Data Transfer Range                               100 m               185m-500 m                     –

Interference                      More                 Less than                     NIL Susceptibility                                            Ethernet cable

 

Cost of Cable                Least Cost      More than Ethernet     Very Expensive

 

 

 

 

 

 

 

 

 

Wireless Media

 

Electromagnetic waves are used for wireless communication over computer networks. Frequencies of waves are measured in Hertz (Hz). As the frequencies of electromagnetic waves change, their properties also change. Based on their frequencies, electromagnetic waves are categorized into various categories. These categories are (in increasing order of frequencies): radio waves, microwaves, infrared radiation, visible light, ultraviolet

radiation, X-rays, and Gamma rays.

 

 

 

 

 

 

 

 

 

Electromagnetic Spectrum

 

 

Category     Long Radio   Radiowaves  Microwaves   Infrared

ROYGBIV  Ultraviolet    X-Rays Gamma

 

Rays           Visible Light Rays                         Rays

 

 

 

 

 

 

 

Frequency   Less than      3 x 103

to     3 x 108  to      3 x 1011  to  4.3×1014  to    More than 1014

 

(Hz)           3×103

3 x 109

3 x 1011

4 x 1014

7.5×1014

 

 

 

 

 

 

 

 

Out of these only radio waves, microwaves, and infrared rays are used for wireless

communication. Let us now study about these waves in some details.

 

Radio Waves – Radio waves have a frequency range of

3 KHz to 3GHz. Radio waves are used for communication over distances ranging from a few meters (in walkie-talkies) upto covering an entire city. These waves are easy to generate, can travel long distances and can penetrate buildings easily. That’s why they are widely used for communication, both indoors and outdoors. Cordless phones, AM and FM radio broadcast, Garage door openers etc. are examples of radio wave transmission. Omni Directional Radio Waves

 

 

 

Characteristics of Radio Wave Transmission:

 

  • These waves are omni-directional, so the transmitting and receiving antennas need not be aligned.

 

(Recall when you throw a stone in a pond, circular waves are generated and spread outwards. Similarly, radio waves are generated by the transmitter and spread in all the directions.)

 

  • Relatively inexpensive than wired media.

 

  • It offers ease of communication over difficult terrain

 

  • The transmission can be interfered by motors or other electrical equipment

 

  • Permission from concerned authorities is required for use of radio wave transmission

 

  • Less secure mode of transmission

 

Micro Waves – Micro waves have a frequency range of 300MHz (0.3 GHz) to 300 GHz. This range has some overlapping portion (0.3GHz – 3GHz) with radio waves as there is no clear- cut demarcation between radio waves and micro waves. Microwaves travel in straight lines and cannot penetrate any solid object. Therefore for long distance microwave communication, high towers are built and microwave antennas are put on their tops. Distance between two microwave towers depends on many factors including frequency of the waves being used and heights of the towers. These waves travel in straight lines and therefore the sending and receiving antennas have to be aligned with each other.

 

An example of usage of microwaves for communication is as follows:

 

In the big cities where land is very costly and a lot of formalities have to be completed to get permission to dig land for cabling, microwave antennas can be put on top of high rise buildings and communication can be started in a short time.

 

 

 

 

 

 

 

Micro Wave

Micro Wave

 

 

Office 1                                                                                 Office 2

 

 

Micro Wave Tower

 

 

 

 

Micro Wave Communication

 

Characteristics of Micro Wave Transmission:

 

  • Free from land acquisition rights

 

  • Relatively inexpensive than wired media

 

  • Offers ease of communication over difficult terrain

 

  • The transmission is in straight lines so the transmitting and receiving antennas need to be properly aligned ( line of sight transmission)

 

Infrared Waves – Infrared waves have a frequency range of 300 GHz to 400 THz. If you recall VIBGYOR spectrum of light, you will also recall that red light has the lowest frequency (400THz – 484THz) in this spectrum. Infrared waves are so called because they have a frequency range of just less than that of red light. These waves are used for short range communication (approx. 5m) in a variety of wireless communications, monitoring, and control applications. Home-entertainment remote-control devices, Cordless mouse, and Intrusion detectors are some of the devices that utilize infrared communication. These waves are easy to build but have a major drawback- they do not pass through solid objects (try standing between your remote control and your television and see if it still works). On the other hand, these waves do not pass through solid walls is a plus point also. Because of this, infrared system in one room of a building will not interfere with a similar system in adjacent rooms (you cannot control TV in another room with the remote in your

hand in a room).

Characteristics of Infrared Wave Transmission:

 

  • It is a line of sight transmission; therefore information passed to one device is not leaked to another device.

 

  • No government license is required for their use

 

  • It is a line of sight transmission, therefore at a time only two devices can communicate.

 

  • The waves do not cross any solid object in between

 

  • Performance drops with longer distances

 

 

Bluetooth – Bluetooth technology uses radio waves in the frequency range of 2.402 GHz to 2.480 GHz. This technology is used for short range communication (approx. 10m) in a variety of devices for wireless communication. Baby monitors, door openers, and cell phones are some of the devices that utilize Bluetooth communication.

 

 

 

 

Characteristics of Bluetooth Transmission:

 

  • Line of sight between communicating devices is not required. (Think Why?)

 

  • Bluetooth can connect upto eight devices simultaneously.

 

  • Slow data transfer rate (upto 1Mbps).

 

 

 

 

Satellite Link – Satellite links are used for very long distance wireless communication which may range from intercity to intercontinental. Transmission from the earth to a satellite is known as uplink. Transmission from a satellite to the earth is known as downlink. There are multiple micro wave frequency bands which are used for satellites links. Frequency used for uplink varies from 1.6 GHz to 30.0 GHz and that for downlink varies from 1.5GHz to 20.0GHz. Downlink frequency is always lower than the uplink frequency. For example, the uplink frequency is 6.0GHz, and the corresponding downlink frequency is 4.0 GHz. A communications satellite is a relay station in orbit above the earth that receives, regenerates, and redirects signals carried on a specific frequency. The satellite system is very expensive but its area coverage and fringe benefits compensate for the expenses. Communication satellites are normally owned by governments or by

government approved organizations of various countries.

 

 

 

 

 

 

 

 

COMPUTER NETWORKING

 

 

 

 

 

 

Orbit

Communication Satellite

 

 

 

 

 

 

Uplink

Uplink

 

Downlink

 

 

Downlink

 

 

 

 

 

 

 

 

 

 

Earth Station

Earth Station

 

 

 

Europe

 

 

Communication using Satellite Link

Asia

 

 

 

Characteristics of Transmission using satellite link:

 

  • Satellites cover large area of earth

 

  • Since communication over very long distances is possible, this becomes a commercially attractive option.

 

  • This system is expensive

 

  • Requires legal permissions.

 

 

Communication Medium

 

 

 

 

Guided (Wired)

Unguided (Wireless)

 

 

 

 

 

Twisted Pair Cable

Co-axial Cable

Optical Fiber Cable

Radio Waves

Micro Waves

Infrared Waves

 

 

 

 

 

 

 

 

 

 

Network Devices

 

Other than the transmission media many other devices are required to form computer networks. Some of these devices are:

 

NIC: Any computer which has to be a part of a computer network must have an NIC (Network Interface Card / Unit) installed in it. A computer communicates with other computers on a network with the help of an NIC only. Now a days, in most of the PCs and

the laptops, NIC is an integral part of the motherboard.

 

 

 

 

 

 

 

 

Socket for RJ-45

Connector

 

A Network Interface Card

 

An NIC (Network Interface Card) is a device that enables a computer to connect to a network and communicate.

 

 

Hub: Hub is a device that allows us to connect multiple computers/devices together in a network. A hub has ports into which the cables from individual computers’ NICs are inserted. This way each computer’s NIC is connected to hub and hence all the computers are connected together. Whenever a computer has to send some information to some other computer(s), the information is sent by the NIC to the hub. Then the hub re- transmits this information to the other computers attached to it. The computer(s) for which the information is intended receive(s) this information and accept(s) it. Other

computers on the network simply reject this information.

 

 

 

 

 

 

 

 

 

Hub/Switch

 

 

 

 

 

A Hub is an electronic device that connects several nodes to form a network and

redirects the received information to all the connected nodes in broadcast mode.

 

 

 

 

 

Switch: A switch is an intelligent hub. It looks exactly like a hub. It has the same function as that of a hub: to connect multiple computers/devices in a network. But the difference between the two is in the way they re-transmit the received information. Unlike a hub, instead of broadcasting (sending to each device attached to it) the received information, a switch sends the information selectively only to those computers for which it is intended. This makes a switch more efficient than a hub.

 

A Switch is an intelligent device that connects several nodes to form a network and redirects the received information only to the intended node(s).

 

 

Repeater: When the data is transmitted over a network for long distances, the data signal gets weak after certain distance. This distance depends on the data transfer range of transmission channel being used and can be from a few meters to a few kilometers. If the signal becomes weak, it cannot reach its destination. Therefore, some device is required which can re-strengthen the data signal before it gets too weak. Repeater is such a device. A repeater regenerates the received signal and re-transmits it to its destination

 

A Repeater is a device that is used to regenerate a signal which is on its way through a communication channel. A repeater regenerates the received signal and re-transmits it to its destination.

 

 

Gateway: There are a large number of computer networks in this world. As common examples you can consider your school’s computer network, ATM network of a bank, a big company’s computer network spread over a city, etc. There are thousands of computer networks that exist. These networks use different hardware and software. Many times these networks need to communicate with each other. For example, companies X, Y, and Z do business with each other and therefore they want to interconnect their computer networks. Another example is the internet which contains a large number of different

types of networks spread over the globe. Different networks are sometimes incompatible

 

 

with each other. It is like a group of persons using different languages for conversation. When two or more networks using different hardware and software have to be connected, some device is needed which can translate one network’s language into the other’s. A gateway is a device, which is used to connect different types of networks. A gateway is capable of understanding address architectures used in different networks and seamlessly translate between these address architectures.

 

 

 

 

 

 

A Gateway is a device, which is used to connect different types of networks and perform the necessary translation so that the connected networks can communicate properly.

 

 

Network Topologies

 

Before we start discussion on network topologies, let us understand the term ‘NODE’.

 

Any device (Computer, Scanner, Printer, etc.) which is directly connected to a computer network is called a node. Suppose you are working on a PC at your home and then you connect it to internet. As soon as it becomes a part of internet (which is a computer network), it becomes a node. Similarly, in your school, all the computers which are linked to school’s computer network are nodes.

 

 

A Node is a device, which is directly connected to a computer network. It can be a computer or any other device like printer, scanner etc.

 

 

Once we know about different communication media and devices to form a computer network, we can procure these media and devices and start constructing a computer network. Suppose we have 10 computers and we want to interconnect them to form a network. How can we interconnect them?

 

Recall the puzzle given in the beginning of this lesson. Is that not similar to the problem of connecting nodes in a network?

Similarly, when we have to connect computers/devices in a network, there may be certain conditions which have to be satisfied. Depending upon these conditions, there may be different ways of interconnecting the computers/devices. The way in which the

 

computers/ devices are physically interconnected to form a network is called a Topology.

 

 

A Topology is an arrangement of physical connections among nodes in a network.

 

There exist different network topologies. Let us discuss a few of them.

 

 

Bus Topology:

In bus topology all the nodes are connected to a main cable called

 

backbone. If any node has to send some information to any other node, it sends the signal to the backbone. The signal travels through the entire length of the backbone and is received by the node for which it is intended. A small device called terminator is attached at each end of the backbone. When the signal reaches the end of backbone, it is absorbed by the terminator and the backbone gets free to carry another signal. This prevents the reflection of signal back on the cable and hence eliminates the chances of signal interference.

 

 

 

 

 

Node

 

Node-Printer

 

Node

 

 

 

Backbone

 

 

Terminator

Terminator

 

 

 

 

 

 

 

 

 

Node

Node (Server)

 

Node                                   Node

Bus Topology


Characteristics of Bus topology:

 

  • It is easy to install.

 

  • It requires less cable length and hence it is cost effective.

 

  • Failure of a node does not affect the network.

 

  • In case of cable (backbone) or terminator fault, the entire network breaks down.

 

  • Fault diagnosis is difficult.

 

  • At a time only one node can transmit data.

 

 

Star Topology: In star topology each node is directly connected to a hub/switch. If any node has to send some information to any other node, it sends the signal to the hub/switch. This signal is then broadcast (in case of a hub) to all the nodes but is accepted by the intended node(s). In the case of a switch the signal is sent only to the

intended node(s).

 

 

 

 

 

 

Node

Node

 

 

Hub/ Switch

 

 

 

 

Node

Node

 

 

 

 

 

 

 

 

(Server)

Node-Printer

 

Bus Topology

Node

 

 

Star topology generally requires more cable than bus topology.

 

Characteristics of Star topology:

 

  • It is more efficient topology as compared to bus topology.

 

  • It is easy to install

 

  • It is easy to diagnose the fault in Star topology.

 

  • It is easy to expand depending on the specifications of central hub/switch

 

  • Failure of hub/switch leads to failure of entire network

 

  • It requires more cable length as compared to bus topology.

 

 

Tree Topology: Tree topology is a combination of bus and star topologies. It is used to combine multiple star topology networks. All the stars are connected together like a bus.

This bus-star hybrid approach supports future expandability of the network

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Tree Topology

 

Characteristics of Tree topology:

 

  • It offers easy way of network expansion

 

  • Even if one network (star) fails, the other networks remain connected and working.

 

 

 

 

 

 

 

 

 

Network Protocols

 

A computer network can be set up after procuring all the required hardware. But the network devices will be able to communicate with each other only after they know the rules of communication. Think of a group discussion session where all the participants can speak. Each participant can speak a lot. But the group discussion can be started and can be conducted well if each participant knows the rules of discussion. If all the participants start speaking suddenly and suddenly they stop, or a person stands up randomly and starts interrupting the discussion, or any such thing happens, the group discussion cannot be conducted at all. A more complex situation exists in the case of computer networks where the participating devices have no common sense and they follow each defined rule to the

T. So it is essential that the rules of communication are very well defined. A set of rules is

also known as a protocol.

 

A network protocol is a set of rules for communication among networked devices. Protocols generally includes rules of how and when a device can send or receive the data, how is the sent data packaged, and how it reaches its destination.

 

There are a number of protocols defined for computer networks. Here we discuss three of them – HTTP, TCP/IP, PPP.

 

HTTP (Hyper Text Transfer Protocol): HTTP is used to transfer all files and other data (collectively called resources) from one computer to another on the world wide web. When an HTTP client (a browser) sends a request to an HTTP server (web server) , the server sends responses back to the client. This transfer of requests and responses is done

following HTTP protocol.

 

TCP/IP (Transmission Control Protocol / Internet Protocol): It is the basic protocol of the Internet. Communication between two computers on internet is done using TCP/IP protocol. TCP/IP can also be used as a communications protocol in a private network. TCP/IP is a two-layer protocol. When data is to be sent from one computer to another over internet, it is first broken into smaller packets which are actually sent. When these packets are received by the receiver computer, they are assembled into the original message. This job of dividing the original message into packets and re-assembling the received packets into the original message is done following TCP protocol. Internet protocol is followed to ensure that each of these packets gets to the right destination. Different packets from the same message may be routed differently, but they reach the

same destination and are reassembled there.

 

PPP (Point to Point Protocol): It is a protocol for direct communication between two computers, typically a personal computer connected by phone line to a server. Most Internet service providers (ISPs) use PPP for customer dial-up access to the Internet. PPP is used over many types of physical networks including cellular telephone, serial cable,

phone line, trunk line, specialized radio links, and fiber optic links.

 

 

Know More!

 

There are a lot of other communication protocols like SMTP, POP, UDP etc. You can

explore the net to find more about these protocols.

 

Types of Networks

 

A computer network may span any amount of geographical area. It can be on a table, in a room, in a building, in a city, in a country, across continents or around the world. On the

basis of area covered computer networks are classified as:

 

  • PAN – Personal Area Network

 

  • LAN – Local Area Network

 

  • MAN – Metropolitan Area Network

 

  • WAN -Wide Area Network

 

PAN (Personal Area Network): A PAN is a network of Communicating devices (Computer, Phone, MP3/MP4 Player, Camera etc.) in the proximity of an individual. It can cover an

area of a few meters radius.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A PAN

 

 

When you have to transfer songs from one cell phone to another, you set up a PAN of two phones. When files are transferred from a PC to an MP3 player, a PAN is set up between the two. There can also be multiple devices in PAN. A PAN can be set up using guided

media (USB cable) or unguided media (Bluetooth, Infrared).

 

 

 

 

 

 

 

 

 

COMPUTER NETWORKING

 

 

 

 

LAN (Local Area Network): A LAN is a network of computing/Communicating devices in a room, building, or campus. It can cover an area of a few meters to a few kilometers radius. A networked office building, school, or home usually contains a single LAN, though sometimes one building can contain a few small LANs (Like some schools have independent LANs in each computer lab.). Occasionally a LAN can span a group of nearby buildings.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Wireless LAN

 

 

In addition to operating in a limited space, a LAN is owned, controlled, and managed by a single person or organization.

 

A LAN can be set up using wired media (UTP cables, Co-axial cables etc.) or wireless media (Infrared, radio waves). If a LAN is setup using unguided media, it is known as WLAN (wireless LAN).

 

MAN (Metropolitan Area Network): A MAN is a network of computing/communicating devices within a city. It can cover an area of a few kilometers to a few hundred kilometers radius. A network of schools, or banks, or Government offices etc., within a city, are examples of MANs. A MAN is usually formed by interconnecting a number of LANs and individual computers. All types of communication media (guided and unguided) are used to set up a MAN. A MAN is typically owned and operated by a single entity such as a government body or a large corporation. A good example of a MAN is the interconnected

offices of a state government.

 

 

 

 

 

 

 

Warehouse

 

 

Branch Office

 

 

 

 

 

 

Factory

Central Office

A Metropolitan Area Network

 

 

 

 

 

 

 

COMPUTER NETWORKING

 

 

 

WAN (Wide Area Network): A WAN is a network of computing/communicating devices crossing the limits of a city, country, or continent. It can cover an area of over hundreds of kilometer radius. A network of ATMs, BANKs, National Government Offices, International Organizations’ Offices etc., spread over a country, continent, or covering many continents are examples of WANs. WANs usually contain a number of interconnected individual computers, LANs, MANs, and maybe other WANs. All types of communication media (guided and unguided) are used to set up a WAN. The best known example of a WAN

is the internet.

 

 

 

 

 

 

 

 

 

 

LAN

 

 

PC

 

 

 

 

 

 

Devices and Protocols

for data transmission

 

 

PC                                                                                                                   PC

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

LAN

 

 

 

A Wide Area Network

MAN

 

 

 

 

The following table summarizes the characteristics of PANs, LANs, MANs, and WANs.

 

Network       PAN               LAN                MAN                 WAN

 

Parameter

 

Area Covered       Small Area      A few meters   A city and its     Entire country, (Upto 10m        to a few             vicinity           continent, or radius) kilometers    (Upto 100Km                     globe

(Upto 10Km     radius)              (No upper limit) radius)

 

Error Rates          Lowest           Lowest            Moderate          Highest

 

Transmission        High Speed     High Speed      Moderate          Low speed Speed                                     Speed

 

Networking Cost  Negligible       Inexpensive     moderately       Expensive expensive

equipment

 

 

Identification of computers and users over a network

 

Once a network has been set up, the nodes can communicate among themselves. But for proper communication, the nodes should be uniquely identifiable. If a node X sends some information for node Y on a network, then it is mandatory that nodes X and Y are uniquely

identifiable on the network. Let us see how this is achieved.

 

MAC (Media Access Control) address: Each NIC has a universally unique address assigned to it by its manufacturer. This address is known as the MAC (Media Access Control) address of the card. It means that a machine with an NIC can be identified uniquely through its NIC’s MAC address. MAC address of an NIC is permanent and does never change.

 

MAC addresses are 12-digit hexadecimal (or 48 bit) numbers. By convention, MAC addresses are usually written in one of the following two formats:

 

MM:MM:MM:SS:SS:SS

 

MM-MM-MM-SS-SS-SS

 

 

 

The first half (MM:MM:MM) of a MAC address contains the ID number of the adapter manufacturer. The second half (SS:SS:SS) of a MAC address represents the serial number assigned to the adapter (NIC) by its manufacturer.

 

 

 

 

 

 

 

 

For example, in the following MAC address,

 

00:A0:C9 : 14:C8:35

 

The prefix 00:A0:C9 indicates that the manufacturer is Intel Corporation. And the last three numbers 14:C8:35 are given by the manufacturer (Intel in this example) to this NIC.

 

A MAC (Media Access Control) address is a unique 12 digit (6 digits for manufacturer code and 6 digits for serial number) hexadecimal number assigned to each NIC. MAC address of an NIC never changes.

 

 

IP Address: Every machine in a network has another unique identifying number, called its IP Address. An IP address is a group of four bytes (or 32 bits) each of which can be a number from 0 to 255. A typical IP address looks like this:

 

59.177.134.72

 

To make it easier for us to remember, IP addresses are normally expressed in decimal format as a “dotted decimal number” like the one above.

 

On a network, IP address of a machine, and not the MAC address of its NIC, is used to identify it. Do you recall IP protocol? IP protocol identifies a machine with its IP address to route the packets.

 

MAC address is used only when a specific machine is to be targeted. For example, suppose we want to block a specific PC to access some network resource. If we use the PCs IP address, then the PC is not blocked permanently as its IP address may change when it connects to the network next time. Instead, if the PCs MAC address is used for the purpose, then the job is done!

 

An IP (Internet Protocol) address is a unique 4 digit hexadecimal number assigned to each node on a network. IP address settings of a node can be changed by the user

 

 

Know More!

 

There are two versions of IP addresses: version 4 (IPv4) and version 6 (IPv6). IPv6 uses 128 bits (IPv4 uses 32 bits) for an IP address. Using IPv4 only 232 (approximately 4 billion) distinct devices can be addressed. In the current scenario and in the near future, this is a small fraction of the number of objects which need to be allocated IP addresses. As the human population and also the number of devices which need to be online (mobile phones, home appliances, personal communication devices, etc.) is increasing at a very fast pace, IPv4 addresses are being exhausted. To address this problem IPv6 was developed and it is now being deployed. Using IPv6 2128 (approximately 4 Bn x 4 Bn x 4 Bn x 4 Bn) distinct devices can be addressed. IPv6 also includes an important feature: a set of possible migration and transition plans from IPv4.There are many other features of IPv6. You can explore the internet and

find more information about IPv6.

 

 

IP Address Vs MAC Address: You might wonder how an IP address differs from a MAC address. In fact, the IP address is assigned by the network administrator or the internet service provider while the MAC address is assigned by the manufacturer. Thus if a computer is transferred from one network to another, its IP address gets changed where as the MAC address remains the same.

From the IP address it is usually possible to track the tentative location of the computer but this is not the case with a MAC address.

 

Domain Name: So, whenever we have to communicate with a computer on internet, we can do so by using its IP address. But it is practically impossible for a person to remember the IP addresses of all the computers one may have to communicate with. Therefore, a system has been developed which assigns names to some computers (web servers) and maintains a database of these names and corresponding IP addresses. These names are called Domain Names. Examples of some domain names are cbse.nic.in, sikkimipr.org, indianrailway.gov.in etc. Domain names are used in URLs to identify particular Web servers. For example, in the URL http://www.cbse.nic.in/welcome.htm, the domain

name is www.cbse.nic.in.

 

 

A domain name usually has more than one parts: top level domain name or primary domain name and sub-domain name(s). For example, in the domain name cbse.nic.in, in is the primary domain name; nic is the sub-domain of in; cbse is the sub-domain of nic.

 

There are only a limited number of top level domains, and these are divided into two categories: Generic Domain Names and Country-Specific Domain Names. For example:

 

Generic Domain Names:

 

·com – commercial business

 

·edu – Educational institutions

 

·gov – Government agencies

 

·mil – Military

 

·net – Network organizations

 

·org – Organizations (nonprofit)

 

Country Specific Domain Names:

 

.in – India

 

·au – Australia

 

·ca – Canada

 

.ch – China

 

.nz – New Zealand

 

.pk – Pakistan

 

.jp – Japan

 

.us – United States of America

 

 

In context of internet, a Domain Name is a name assigned to a server through Domain Name System (DNS). A domain name usually has more than one parts: top level domain name or primary domain name and sub-domain name(s).

 

 

Domain Name Resolution: Domain Name Resolution is the process of getting the corresponding IP address from a domain name. It happens as follows:

 

Suppose you mention a URL in the web-browser to visit a website. The browser first checks your computer to find if the IP address of the server corresponding to the Domain Name (embedded in the URL) is present. If this address is present then with the help of this address, the corresponding server is contacted and then the website opens in your browser. Otherwise the browser sends this domain name to some specific servers (called domain name servers) to find the corresponding IP address. Once the IP address is known, the server is contacted and then the website opens in your browser.

 

Domain Name Resolution is the process of getting corresponding IP address from a domain name.

 

 

 

Know More!

 

The Internet Corporation for Assigned Names and Numbers (ICANN) is an internationally organized, non-profit corporation that has responsibility for Internet Protocol (IP) address space allocation, protocol identifier assignment, generic (gTLD) and country code (ccTLD) Top-Level Domain name system management, and root server system management functions. These services were originally performed under U.S. Government contract by the Internet Assigned Numbers Authority (IANA) and other entities. ICANN now performs the IANA

function.

 

 

Network Security

Computer networks are communication highways on which the data travels. Data travels on a network when an e-mail is sent or received, any transaction is made using a credit or a debit card, a web site is accessed, chatting is done, or any other work is done on a network. Data travelling over a network is vulnerable to attacks and thefts. There are some people who want to illegally access this data for any reason: using a credit/debit card data for shopping, using a company’s data to sell it to some rival company, to find the kind of web sites a person accesses, or may be hundreds of other reasons. These people

 

 

 

 

may sometimes also want to destroy the data on its way, or block the services of some resources or sites. As the data goes from one point to another point on the Internet, for example, it may pass through several points along the way, giving other users the opportunity to access, and even alter it. Even other users on your system may maliciously transform your data. Unauthorized access to your system may be obtained by intruders, who then use advanced knowledge to impersonate you, steal information or even deny your access to your own resources.

Therefore, there is always a threat of some kind of attacks on computer networks’ security. Some kinds of attacks on network security are as follows:

 

Denial of service attacks: A Denial of Service (DoS) attack is an attempt to make one or more network resources unavailable to their legitimate users. Examples of such attacks

are:

 

  • Denial of Access to Information: Corrupting, Encrypting, or changing the status of information so that it is not accessible to its legitimate user.

 

  • Denial of Access to Application: Forced shutting of an application as soon as the user opens it.

 

  • Denial of Access to Resources: Blocking a resource, may be a printer or scanner or USB port, of a computer from proper working.
  • Denial of Access to a Website: Continuously sending bulk requests to a website so that it is not available to any other user.

 

Intrusion Problems: An Intrusion problem is an attempt to mischievously steal some

information from someone’s computer. Examples of Intrusion are:

 

 

Snooping –

Have you ever tried to read someone else’s slam book secretly? This is

 

snooping. Have you ever tried to read what someone else is writing in his/her letter/email to someone else? This is snooping. Do you think your parents try to secretly check your mobile phone to find its contents? If yes, then what your parents are doing is snooping.

In context of network security, snooping refers to gaining unauthorised access to another person’s or organization’s data. This may be done in a number of ways:

 

 

  • By getting someone’s login information by casually watching what he/she is typing.

 

  • Reading the files on someone’s computer in an unauthorised manner

 

  • Using some softwares which keeps track of the activities and data being sent or received on someone’s computer.

 

 

Snooping  refers  to  gaining  unauthorised  access  to  another  person’s  or

organization’s data.

 

 

Eavesdropping – Do you ever find that when you are talking to someone else, another person is secretly trying to listen to your talks? What that person is doing is ‘eavesdropping’. Have you ever tried to secretly listen to the conversation between two teachers regarding your class? If yes, then what you have done is ‘eavesdropping’.

 

In context of network security Eavesdropping refers to unauthorised access to another person’s or organization’s data while the data is on its way on the network.

 

This may be done in a number of ways:

 

  • By setting up parallel telephone lines.

 

  • By installing some software (spyware) in the target computer.

 

  • By installing some receiver which captures the data while on its way.

 

 

Eavesdropping refers to gaining  unauthorised access to another person’s or organization’s data while the data is on its way on the network

 

It is the responsibility of a person/organization to protect its network from such attacks. The term Network Security refers to all activities undertaken to protect a computer network from attacks to its security. This covers protection of computers in the premises and data on the network from both internal and external attacks. To protect a network from security attacks, a number of steps are taken. These steps include:

 

Login-Password: By assigning login names and strong passwords to the users of a system, it can be ensured that only authorized people access a computer. This helps in increasing

the computer as well as network security. A strong password is the one which is easy to

 

 

 

 

 

 

remember for the user but difficult (almost impossible) for the others to guess successfully. On the other hand a weak password is generally the name of a person or organization, the registration number of a vehicle, year of birth of a person and so on. A weak password can be cracked in a few attempts. Examples of strong passwords may be raavanisdead (raavan is dead – with spaces removed), 2aur2paanch (name of an old Hindi movie) or anything like that.

 

Firewall: A firewall is a hardware device or a software that is installed to monitor the data entering the computer/Network  or leaving it. A firewall permits only that data to enter or leave a computer/Network for which permissions have been granted by the

computer/network administrator.

 

Anti Virus Software: These days anti-virus softwares work against not only the virus but also against almost all kinds of malware. Therefore by installing a full version legal (not

the pirated one or freeware) anti-virus software network security can be increased.

 

 

File Permissions:

A data file on a computer can be created, read, or modified. An

 

application file can be run or executed. Accordingly, different rights (privileges) can be given to different users of a computer to perform one or more of these tasks. For example, suppose there is a data file containing students’ marks in a school. The system administrator has created that file. If there is a need to create another such file, then again only the system administrator can create it. So, system administrator is given the ‘Create’ right. A teacher can read this file to go through the marks of the students. She can also enter or alter the marks in this file. Therefore a teacher has ‘Read’, ‘Write’, and ‘Modify’ rights to this file. The students can only view their marks; therefore, the students are given only the ‘Read’ right to this file. If report cards have to be printed for a class, the class teacher makes a request to the computer operator, who can run a program to print the report cards. This computer operator has been given the ‘Execute’ right to the application program which prints the report cards. This way by giving appropriate rights

to respective users, computer security as well as network security can be increased.

 

 

Setting up a computer network

 

Let us now take an example to see how can a computer network be setup.

 

Think of a hypothetical Educational Society (say XYZ Educational Society)  with its head

 

 

office in Chennai (Tamil Nadu) and schools in various parts of the globe. The society is setting up a new senior secondary school, ‘SF School’, in Bahadurgarh (Haryana).

 

The ‘SF School’ will have 3 computer labs with 30 computers in each, 1 Accounts office with 3 computers, 1 Administrative block with 5 computers, and 1 Principal’s office with 1 computer. Let us see how a computer network can be set up in the school.

First of all we can draw a rough sketch of the school with computers at various locations as follows:

 

 

 

 

 

Computer Lab 1

Computer Lab 2        Computer Lab 3

 

 

 

 

 

Administrative

Block

Principal’s

Office

Accounts

Office

 

 

 

 

Independent LANs can be set up in each of the following buildings:

 

Computer Lab1, Computer Lab2, Computer Lab3, Administrative Block, Accounts Office.

 

These LANs can be set up in STAR topology using UTP cable (economical, reliable, and easily available).  For this 1 switch (with suitable number of ports) will be required in each of these buildings. More than one switches can be used in computer labs if a switch with more than 30 ports is not available.

 

Two internet connections (broadband for high speed) can be procured in Administrative Office. Two connections should be procured from two different ISPs so that

 

(i)      Internet connection in Administrative office can be kept separate from the other Computer labs where students may do a lot of experimentation.

(ii)     If one internet connection is not working, the other can be used in case of urgent requirements.

 

These buildings can then be connected as follows:

 

 

 

 

Computer Lab 1

 

 

 

Administrative Block

Computer Lab 2

 

 

 

Principal’s Office

Computer Lab 3

 

 

 

Accounts Office

 

 

 

 

This interconnection will ensure that each building is directly connected to Admisnistrative block. This way internet connection will be available in each building irrespective of the status of the other building.

 

Server (if any) of the school may be placed in Administrative block so that it remains safe (physically) and a firewall can be set up so that the whole network remains safe from any kinds of virus or intrusion attacks.

 

There is no need to do any extra efforts or expenses to link the school to its head office.

This can be taken care of using the internet connections.

 

 

SUMMARY

 

  • A computer network is a collection of interconnected computers and other devices which are able to communicate with each other.

 

  • Communication Media are the links over which the data is sent from one node to another over a network.

 

  • Hardware devices used to form a network are: Cables, NIC, Hub, Switch, Repeater, and Gateway.

 

  • Repeaters are used to regenerate the signal which gets weakened during its transmission. Repeater are generally used to connect two networks which are more than 80 m apart.

 

  • Gateway is a device which connects two different types of networks.

 

  • On the basis of area covered by a network it is categorized as PAN, LAN, MAN, or WAN.

 

  • Physical arrangement of computers in a network is called network topology.

Basic network topologies are bus, star and tree.

 

  • Each machine on a network is identified by its IP address.

 

  • Conversion of domain name into IP address is done by DNS (Domain Name Server)

 

  • Denial of service, snooping and intrusion are some common threats for network security.

 

  • Network security can be increased by applying some preventive methods.

 

 

Future Trends

 

4G Technology

 

The scenario of how computers are networked is changing very fast. Before full implementation of a technology, a new technology is visible at the horizon. One such new technology is 4G. 4G stands for fourth generation of mobile technology. Change from one generation to another involves a major advancement in the technology used. 1G technology was used in the first mobile phones. 1G used analog radio signals. 1G was introduced in 1980s and continued until 1992 when 2G was introduced. 2G technology used a digital format and introduced text messaging. 2G also introduced data services for mobiles, starting with SMS. 3G technology has introduced more efficient ways of carrying data, making it possible to have faster web-services, live chat, fast downloading, video conferencing etc. over mobile phones. Today we are living in the world of 3G. Soon, 4G will rule the mobile market. Unlike previous generations of mobile technology, 4G mobile technology will be used for internet access on computers also, and it will be totally wireless! 4G will provide internet access, high quality streaming video and “anytime, anywhere” voice and data transmission at a much faster speed than 3G. The “anytime, anywhere” feature of 4G is also referred to as “MAGIC” (Mobile multimedia; Anytime/anywhere; Global mobility support; Integrated wireless solution; Customized personal services).

 

You can explore more about 4G technology on the internet.

 

Cloud Computing

 

This is an emerging area of demand based resource sharing, resulting into drastic saving of energy and cost. This is also referred to as ‘Green IT’.

 

 

Syllabus : XII Sc (C++)

 

Cloud Computing : Characteristics, layers- client, Application, platform and infrastructure, Deployment models-Private cloud, Public cloud, Community cloud and hybrid cloud, Issues- Privacy, Compliance, Security, Sustainability and abuse. 163

 

Introduction to cloud computing

 

   

 

 

 

 

 

 

 

The two words in the phrase cloud computing have the following interpretations:

  • Cloud: As a noun, this is a metaphor for the Internet, and as an adjective it means pertaining to the Internet This usage derives from the cloud symbols that represent the Internet on diagrams.
  • Computing: Any ITactivity carried out:
    • When using “a local server or a personal computer” which implies that the IT resources are under the exclusive control of the user.
    • To “store, manage, and process data” which implies that the data is private to the user, in the sense that it is determined by them, even if it is accessible by others.

This means that cloud computing is a type of Internet-based computing, and it consists of every situation where the use of IT resources by an entity, including a person or an organisation, has all of the following characteristics:

Access to the resources is:

    • Controlled by the entity, and restricted by them to their authorised users.
    • Delivered via the Internet to all of these users.
  • The resources are:
    • Hosted by a service provider on behalf of the entity.
    • Dedicated to their exclusive use.
  • Data processed by the resources is:
    • Private to the entity and its associates.
    • Entered or collected by them, or automatically produced for them.

 

Depending on the context, cloud computing can mean:

  • Access to and use of the resources.
  • The hosting and delivery service that provides this access.
  • A model for enabling such access and delivery.
  • The hosted resources or services themselves.
  • The computing execution carried out by the services.
  • Technology used for the provision of the services.

Typical versus essential characteristics  : As well as the above essential features, there are several other characteristics that are typical of some types of cloud computing.

Consumption features

The cloud-computing consumption model represents characteristics, such as payment, resource-sharing, scaling and access methods, that typically apply only to some examples of cloud computing, because they are optional alternatives rather than being necessary features. For example, no payment method can be an essential characteristic of cloud computing, because there are some free services, and because each different payment method is only typical of certain types of commercial service.

Internet versus network accessibility :There are several deployment models that make cloud computing available on the Internet in a variety of public or private computer systems. Besides these, there are also IT systems that have some of the same typical characteristics and advantages as cloud computing, but that, for security reasons, are accessible only via a private network, rather than the Internet. These have been described as “cloud computing-like” but, because of the shared features, they are sometimes included as part of cloud computing itself.

Terminology

Cloud services

As a hosting service, cloud computing is also known as cloud hosting, or as a cloud service.

Cloud systems

The hosted resources are known as cloud resources or cloud systems, and these include cloud software and cloud infrastructure.

Cloud software includes cloud applications, cloud databases and cloud platforms.

Cloud infrastructure includes cloud storage, cloud servers and cloud networks.

Cloud roles

The consumption and provision of cloud computing involves the following roles

  • Cloud consumer: Any person or organisation that arranges for the delivery of a cloud service, either for themselves, or for their individual users. In commercial cases, this is the customer that enters into a contract and pays for the service.
  • Cloud provider: A cloud-system host that delivers cloud services to cloud consumers.
  • Cloud auditor: An independent assessor that vets cloud services on behalf of potential consumers, for example to check security and privacy arrangements.
  • Cloud broker: A relationship manager and negotiator that connects a cloud consumer with a single cloud provider, or that aggregates services from more than one provider to satisfy the full range of a consumer’s needs.
  • Cloud carrier: An intermediary that connects consumers with the provider’s cloud systems, such as an ISP that provides Internet access and connectivity.

Cloud tenants

The cloud consumers serviced by the same cloud provider are known as tenants of the provider’s cloud systems, which are said to be multi-tenanted if they have many consumers, and single-tenanted if they have only one consumer

The tenants are the entities that contract for the services, rather than their individual users. Such an entity can be an organisation with many employees, so cloud systems can have a single tenant but many users.

In the cloud

Cloud computing happens in the cloud, and:

  • Cloud systems are said to be hosted or located in the cloud.
  • Cloud consumers are said to operate in the cloud.
  • When an organisation converts its IT management to cloud computing, it is said to move into the cloud.

Cloud of clouds

When used as a noun, the term cloud is a metaphor for the Internet, but it is also applied to the cloud systems hosted by a cloud provider, and these might be described, for example, as a public cloud.

The term cloud of clouds is used for the aggregate of the clouds hosted by several providers that co-operate in delivering cloud services

The Intercloud

The term Intercloud is used for all cloud systems, after an analogy with the word Internet, meaning inter-networks.

This is not the same as all websites on the Internet, because there are many that are excluded from cloud computing.

Cloud balancing and bursting

Cloud balancing is the day-to-day use by a consumer of more than one cloud provider for load balancing, and cloud bursting is the automatic overflow of demand to a different cloud provider only at peak times.

Cloud spanning

Cloud spanning is the use of more than one cloud service to run different components of an application.

Cloud clients

A client computer, or simply a client, is an end-user access point to a computer system, and the term came to prominence with client-server computing.

The term cloud client is an application of this concept to cloud computing, and so it is an end-user access point to a cloud system. These include PCs, notebooks, tablets and mobile phones, and the access may be through a web browser or a program interface running on the client.

They are used only to access cloud systems, and they aren’t part of cloud computing themselves.

Cloud datacentres

A datacentre is a facility that houses server computers. For example, a small or medium-sized organisation may place all its servers in one datacentre, and a large organisation may need to place them in several datacentres.

Cloud systems are hosted in a cloud datacentre

Cloud operating systems

Clients

A cloud operating system for a cloud client, such as Chrome O/S and Cloud, is a combination of a simple O/S and a web browser that enables a user device with minimal processor and memory resources to access cloud services.

Datacentres

Unlike a traditional server O/S, such as Windows NT and Unix, which manages the resources of a single server computer, a cloud operating system for a cloud datacentre manages all the servers in the entire datacentre, which are possibly in distributed locations.

Cloudware

Cloud software is also known as cloudware, and it includes cloud:

  • Applications
  • Databases
  • Platforms
  • Datacentre operating systems.

Cloud operations

Cloud operations are IT operations that provide, support or develop cloud systems, or that manage cloud datacentres.

Cloud operations use cloud engineering, which is the application of systems engineering and software engineering to the design of cloud systems, and cloud architecture, which is the structure of these systems, in terms of their components and the way they interact with each other and with external systems.

Cloud washing

Cloud washing is “the purposeful and sometimes deceptive attempt by a vendor to rebrand an old product or service by associating the buzzword cloud with it”.

Models

Cloud computing has been described as a “model for enabling” particular types of access to and delivery of IT services.

Service models

There are three main cloud-computing service models, and these represent the three types of computing generally required by consumers: software applications (SaaS) to process their data, platforms (PaaS) to develop applications, and infrastructure (IaaS) to run software and store data.

Software as a Service

Software in the cloud

Software as a Service (SaaS) provides software that is specific to its consumer’s end-user requirements, including traditional applications, such as accounting, and email. This is the largest group of cloud services, and it provides a very wide range of software.

The host manages the software, and the infrastructure that runs this software and that stores data. It may use its own infrastructure, which is then said to be in-house or on-premise, or it may use another cloud provider for this infrastructure.

The consumers do not control the software, beyond the usual configuration settings, or the infrastructure, beyond changing the resources they use, such as the amount of disk space required for their data.

For the usual security reasons that apply when managing a data centre, such as to mitigate against the risk of an infrastructure outage, the host will regularly backup all data, across all tenants, but consumers can also backup their own data in their own disk space.

SaaS may be accessible from a variety of cloud clients.

Desktop as a Service

Desktop as a Service (DaaS) is the hosting of a desktop PC software environment, including office-productivity applications, such as word processing, by a SaaS provider.  This is done so that only a thin client, with perhaps just a web browser, need be used to access all the required software, and this can be financially advantageous for the consumer. Also, it simplifies deployment and administration of the PC environment.

DaaS is also known as a cloud desktop or desktop in the cloud.

Database as a Service

Database as a Service (DbaaS) is the hosting of database software by a SaaS provider.

These are known as cloud databases.

Identity as a Service

Identity as a Service (IDaaS) is the hosting of identity-management software by a SaaS provider.

Platform as a Service

Development platforms in the cloud

Platform as a Service (PaaS) consists of software-development and deployment platforms, known as cloud platforms, located in the cloud.

With this type of service, the host provides a complete software-development and run-time environment, including programming languages and related infrastructure, so that the consumers can either create their own software on this platform, or deploy software that was developed elsewhere, but that needs this same environment to run.

The infrastructure can include a database and identity-management, or access-control, software.

SaaS development platforms

A form of PaaS that can be hosted by SaaS providers consists of their development environment being made available for cloud consumption by third-party developers, so that the applications for their main consumers can be enhanced.One advantage of this approach is that the third-party developers have access to the user data that is stored and processed by the main application.

Also, in some cases, consumers can use the development platform to customise the application for themselves.

SaaS versus PaaS

Software development is itself performed using software, so PaaS and SaaS are related, but PaaS involves software used specifically for development, and all related activities, such as testing and deployment.

Also, with SaaS, the application is controlled by the host, whether developed by the host or by a third party, but with PaaS, the consumer controls which applications are created or deployed on the provider’s infrastructure.

Infrastructure as a Service

Hardware in the cloud

Infrastructure as a Service (IaaS) consists of hardware infrastructure that is located in the cloud. It includes cloud storage, cloud servers and cloud networks, and is also known as Hardware as a Service (HaaS). The infrastructure can be used to run software or simply to store data.

The consumers can be end-users, developers or other cloud providers. For example, SaaS providers can use IaaS providers to run their applications or to store their consumers’ data.

Application agnostic

IaaS is application and platform agnostic, which means that any software can be deployed on the infrastructure by the consumers, including different operating systems, applications or development platforms. On the other hand, with SaaS, only the provided application can be used by the tenants, and with PaaS, only applications that run on the provided platform can be used.

The servers may run a hypervisor, in which case they can run several different operating systems at the same time, and any application that runs on these operating systems.

Storage as a Service

Cloud storage is also known as Storage as a Service (SaaS).

Network as a Service

Cloud networks are also known as Network as a Service (NaaS)

Deployment models

There are several cloud-computing deployment models, and these represent different types of exclusive and non-exclusive clouds provided to consumers or groups of consumers.

Public cloud

Public clouds are cloud systems that are made available to any member of a non-exclusive group, such as the general public, or all organisations in a specific industry. Because there are many consumers, these are multi-tenanted clouds. They are owned by cloud providers, and are off-premise for all consumers.

The cloud is public only in the sense that, potentially, any person or organisation that requires the provided services can become a consumer, and a public cloud may not necessarily be of universal interest. For example, a SaaS public cloud might provide an accounting system that is useful only to certain types of small business.

Private cloud

Private clouds are cloud systems that are accessible only by a single consumer, or by an exclusive group, such as all the business units in a single organisation. They are generally single-tenanted, but they can be multi-tenanted if the individual group members act as separate consumers. They may be owned by a cloud provider and be located off-premise, or they may be operated by the consumer and be located on-premise. In the latter case, they can also be known as internal clouds or corporate clouds.

These clouds are usually private because of the need for system and data security, and, for this reason, they will usually be behind a firewall that restricts access to a limited set of client devices.

There are IT systems that have some of the same characteristics and advantages as cloud computing, but that are accessible only through a private LAN or WAN, rather than the Internet. These have been described as “cloud computing-like” but, because of the shared features, they are sometimes included as part of cloud computing itself.

Virtual private cloud

When a service provider uses a public-cloud system to create a private cloud, the result is known as a virtual private cloud.

Community cloud

Community clouds are cloud systems that are available only to a specific group of related entities that share a common purpose, such as mission, security requirements, policy or compliance considerations, and that therefore need the same type of hosting. These are multi-tenanted clouds that may be managed by the community or by a third party, and they may be off-premise for all the consumers, or on-premise for one of the consumers.

Unlike a private cloud, the community of consumers isn’t narrowly exclusive. However, they are not truly public clouds, because entities outside the community that could benefit from the service, may not be able to become consumers.

Hybrid cloud

A hybrid cloud is a composition of two or more public, private and community clouds, that are used on a day-to-day basis or for cloud bursting.

Becoming part of such a cloud can be attractive to the providers, because it results in a larger pool of resources that can be made available to their consumers, so that variations in demand can be managed more flexibly. Also, for consumers, it may be that some of their data must be in a private cloud, for security and privacy reasons, but it may be more economical to keep some other, perhaps less sensitive, data in a public cloud, because the cost of these is generally lower.

A hybrid cloud is also a cloud of clouds, but the difference with the latter is that it can contain only one type of cloud deployment, rather than a mixture of public and private clouds, as with a hybrid.

Vertical cloud

A vertical cloud is a public cloud optimised for a specific, vertical industry.

Consumption model

There are several features of cloud computing that affect consumers in terms of their day-to-day use of the services, or the way they contract for the services, or their reasons for choosing one service over another, and these have been called the consumption model.

Some of them have been described as essential, but it has also been observed that “no single feature is proposed by all definitions”, and they have been discussed using terms such as alternatives, options, generally, recurrent ideas or typically, to indicate that they don’t necessarily apply to all cloud services.

Payment and pricing

Free services

There are cloud services that are entirely free, and some that are offered on a freemium basis.

Commercial services

Where payment is made, typically it is on the basis of consumption in a given time period, such as per concurrent user per month for SaaS, or per unit of storage per month for IaaS.

Charging by usage can be by any of the following methods:

  • Utility: Consumers pay only for what they use – so called because it is similar to the pricing of services from electricity utilities.
  • Subscription: Consumers pay for a fixed amount of resource whether they use it or not, which is similar to some contracts for cable TV or mobile telecommunications.
  • A combination of these, where consumers pay a subscription to consume up to a certain amount, and then as a utility for resources consumed above that amount.

Ownership

In some cases, cloud systems can be wholly owned by the consumer.

Measured service

Payment on the basis of consumption requires a measured service and a metering capability, but even free services may need to be metered if they apply only up to some level of resource.

Resource pooling

Multi-tenant hosting involves pooled resources that are shared among the several tenants. This can be a consumer advantage, because sharing the resources may lead to lower costs for each tenant.

However, resource pooling doesn’t apply to a private cloud with only one tenant, because this type of resource sharing applies only between different tenants, rather than among a tenant’s individual users. Sharing resources among users applies to any server or datacentre, whether it is part of cloud computing or not.

Scaling and provisioning

Scaling means reconfiguring resources to change their size. Scaling in means to release resources, and scaling out means to acquire more resources. Systems that can easily scale in or out are said to be elastic. Provisioning refers to the mechanisms used to provide and release resources, and hence to manage scaling. Agile provisioning allows the size of resources to be changed very easily, for example without the lengthy decision-making and budgetary process required when purchasing IT equipment for delivery on-premise. Elastic resources and agile provisioning are important for flexible and cost-effective management of variations in user demand.

The following terms are used to describe the various scaling and provisioning features that are available with some cloud services:

  • On-demand self service: Scaling that can be performed by the consumer, rather than by the host.
  • Dynamic scaling: Scaling that can be done via software, so that it can happen automatically, and possibly in a way that is invisible to the consumer.
  • Infinite scaling: There is no effective limit to the amount of resource that the consumer can have, although it is always actually finite at any one time.
  • Rapid provisioning: Provisioning that can be immediate, rather than waiting for the cloud provider to respond to a request for resources.

There is some disagreement as to whether agile provisioning is a defining characteristic of cloud computing. This is partly because the history of IT shows that flexible scaling and provisioning was available prior to the cloud era, and so it is more a feature of IT in general, rather than just cloud systems in particular. However, because large public clouds can have very many tenants, their datacentres can be much more massive than previously known, and so they can give the appearance of unlimited scalability.

Access

Broad

Access to cloud services is via the Internet, and this leads to the possibility of consumers having broad access, which means the ability to use the services from multiple types of cloud client, including desktop, portable and hand-held devices, or from many different locations.

To achieve access from many different clients, it is necessary for the websites to be made compatible with hand-held devices as well as PCs, for example because of the different screen sizes and the different mechanics of scrolling within large web pages.

Access can be from any location where an Internet connection is available, either from a fixed PC, for example in an office or Internet café, or from anywhere that mobile telephone access is available, for example using a USB modem attached to a notebook.

However, a private cloud may only allow access from certain sources, for example if it is behind a firewall.

Transparent

In IT, something is transparent to users if they do not need to understand or be aware of it. For example, with cloud computing, consumers can have transparent access, which means that the users of a service need not be aware of who provides the service or where the host is located.

However, for legal and regulatory requirements regarding the security of data, and the laws that might apply to breaches of service levels, a consumer may need to have their hosting provided by a known organisation in a specific location.

Examples

All cloud services have a dedicated-resource aspect, with consumer-controlled access to these resources by authorised users, via a secure-access method, such as a login ID. Also, the resources process data that is private to the consumer and their associates, which means that it is entered or created by them, although it may be accessible by others, including the general public.

There are many organisations that supply cloud services, and there is a very wide range of such services.

Application software

A range of cloud applications is available, including common small-business applications, such as accounting, and medium-to-large organisation line-of-business or mission-critical applications, such as CRM and ERP.

These applications are:

The authorised users of the hosted software include the consumer’s staff, and possibly the staff of their associates, such as customers and suppliers. The private data includes confidential information entered by the users, such as financial-transaction amounts, but there could also be a publicly-accessible aspect, such as a shopping-cart feature that can be used by visitors to a retail organisation’s website.

Third-party application providers

ASPs may host software that they have developed themselves, or software developed by others.

Some market-leading software systems, such as SAP and Sharepoint, are available from third-party ASPs.

Databases

Database as a Service (DbaaS) hosts cloud databases, and “virtually all major database platforms are available in the cloud”, including Amazon SimpleDB and Amazon Relational Database Service.

The private data for these services consists of the records stored in the database.

DbaaS is part of Software as a Service.

Email

Email computing involves two aspects:

  • Composing, reading and organising emails.
  • Sending and receiving them via the Internet.

The first of these can be done on a user-device, such as a PC, in which case it is not part of cloud computing, or it can be done at the website of an ISP, in which case it is part of cloud computing. The second aspect is part of cloud computing in both cases.

For PC-based email, composing and reading emails, and organising them in folders, is done with software running on a PC, and all of the permanent storage, such as for the inbox, sent and other folders, and address books, is allocated on the PC. This is not cloud computing, because the email software and storage are not accessed via the Internet, but directly on the PC, even though the send and receive software is hosted by an ISP. The latter software is part of cloud computing, and the private data for this computing consists of the received and sent emails stored, perhaps temporarily, by the ISP prior to being retrieved for reading on the PC, or sent via the Internet.

For web-based email, or webmail, such as Gmail, the data is stored for the consumer in disk space allocated by the service provider, and emails are composed, read and organised using software hosted by the provider at their site. The private data for this computing includes all emails, folders and address books. Webmail is part of Software as a Service.

In both cases, a PC, or other user device, is a cloud client used to access the services.

Office-productivity software

Office-productivity software, such as Google Docs, is available as a cloud service. The private data for this software consists of the user’s created artefacts, such as word-processor documents and spreadsheet models, which are stored and managed on the provider’s infrastructure.

This is part of Software as a Service.

Software production

Development environments

There are cloud services, such as the Azure Services Platform, that provide software-development environments. These are part of Platform as a Service, which is one of the cloud-computing service models.

The private data for these services consists of all development information, which would be accessible only by the consumers and their authorised users, including any third-party developers.

Customer support

There are cloud services, such as Get Satisfaction, that provide self-help and developer support for the customers of a software company. This support is obtained and entered at a website that hosts and sells the company’s products.

This is a service for the software company, and the private data includes the domain names of the websites for which support is required.

Storage services

Disk storage space can be rented from some cloud providers, and consumers of these services can upload software or data, for example by using the service for backup of client-device information. The private data would consist of the uploaded material.

The infrastructure is:

Co-operation and communication

There are cloud services that use the remote connectivity features of the Internet to support distributed co-operative activities, such as systems support, project work or voice and video communication.

Examples of such services include:

  • Screen-sharing systems, such as LogMeIn and Mikogo, that can be used for remote support or co-operation on projects among geographically distributed participants.
  • Teleconferencing systems, such as Skype.

For these systems, client software needs to be installed on a user device, and this isn’t part of cloud computing, but there is also central storage of a user’s identity, so that they can connect with others. This storage and the associated connectivity software are part of cloud computing.

The private data for this service includes the consumer’s identity.

Websites

Creation and hosting

There are cloud services that provide website creation and hosting.

The private data for the consumers of these services includes the website’s content, and the dedicated resources would include a CMS, so that they can manage the website, and possibly a CRM, so that they can manage customers and purchases.

Feedback

There are cloud services for website operators, that allow visitors to a website to provide feedback to these operators, and that allow the operators to analyse this feedback.

The private data includes the consumer’s domain names for which feedback is required.

Visitor statistics

There are cloud services, such as Google Analytics, that provide website visitor statistics to the operators, and that provide analysis of these statistics.

These are consumed by website operators, and the private data includes the consumer’s domain names for which statistics are required.

Payment

There are cloud services, such as PayPal, that allow website visitors to pay for anything purchased at the site.

These are consumed by website operators, and the private data includes information on the consumer’s connected bank accounts, so that transfers of accumulated payment amounts can be made.

Personal examples

Cloud storage

Anyone with Internet access can rent cloud storage and upload their personal data, for backup or sharing purposes. This is known as a personal cloud, and it is part of Infrastructure as a Service.

For example, with photos in the cloud, a family can share them with members and friends that are in distributed locations, in a way that couldn’t happen with data on their PCs. The private data consists of the uploaded information, and the authorised users consist of all those given access to this information.

Potentially, this type of service could have the largest group of tenants across all providers, because any member of the general public with a device that can access the Internet can become a consumer, if only to backup data.

Internet TV

Internet TV, also known as cloud TV, is a cloud service.

The private data for the consumers of these services includes their multicast address.

Online banking

Online banking is an example of SaaS for the bank’s customers, and the private data for each consumer includes their bank account transaction information.

Besides desktop and portable computers, the cloud clients used to access this service include ATMs, online or mobile wallets, and point-of-sale terminals.

Social media and networking

Media and networking sites, such as Facebook and LinkedIn, are part of cloud computing.

The private data for the consumers includes uploaded information, and this is accessible by the authorised network consisting of their friends or colleagues.

Synced data

Different client devices owned by the same consumer can have their data synchronised, or synced, via the cloud, so that each device can access the data produced by all the other devices. This is done by automatically backing up the data of each client using cloud infrastructure.

One example of this for personal use is the iCloud,which provides cloud storage for an individual’s music downloads from the iTunes Store in such a way that they can be accessed from any of their client devices. In this case, the private data consists of the tunes that are automatically gathered for the consumer onto their cloud storage, regardless of how they are purchased.

Online retailing

There are cloud services, such as eBay, that allow individuals to sell items on the Internet.

The private data for these services includes details of the consumer’s sale items.

Blogging

There are cloud services, such as WordPress, that enable individuals to create and maintain a weblog.

The consumers of these services control access by allowing only themselves to contribute blog topics and to respond to visitor comments, or by authorising others to do so.

The private data includes the:

  • Topics that are entered from time to time.
  • Comments entered by blog visitors, which can be published or suppressed by the consumer.
  • Responses of the consumer.
  • Details of who can read or contribute to the blog, which can be the general public, or an exclusive group.

Peer-to-peer file sharing

Cloud computing involves “using a network of remote servers hosted on the Internet”. These servers can be kept in a datacentre operated by a single cloud provider, but they can also be part of a distributed P2P network that shares resources via the Internet. In such a network, all participating systems are peers, which means that they are both clients and servers, and so their users are both service consumers and service providers.

For example, P2P file-sharing is part of cloud computing. At any one time, the group participating in this service consists of the users of all devices with the same file-sharing software, such as BitTorrent, that are on-line at any one time. For these participants, the service is the mutual sharing of files, and this sharing is:

  • Consumed by each participant by uploading from another participant, or downloading to another participant.
  • Provided by each participant by making available some of the files on their own device, for downloading or uploading.

For the participants, as:

  • Consumers, the:
    • Private data consists of the files on their own device that they allow to be shared.
    • Dedicated resources include their file-sharing software, which is used for the uploading and downloading of files, and to identify them as part of the network.
    • Controlled access consists of allowing the use of their client device for uploading to, or downloading from, the other participants.
  • Providers, they host on their own behalf.

Collaborative distributed computing

The Internet services that control collaborative, distributed computing, such as GIMPS and SETI@home, are part of cloud computing. This is also known as volunteer computing.

These services divide up the computation into small parts that are then distributed to the participating user devices over the Internet. After carrying out its part of the task, a device sends the results back to the cloud–based control as a contribution to the whole process.

The consumers of these services are the participants whose user devices carry out parts of the computation. The private data for each consumer consists of their registration information, including the Internet address of their device.

Deployment-model examples

There are several cloud-computing deployment models that provide public, private, community or hybrid clouds, and there are many examples of these.

Public clouds are the most ubiquitous, and they include:

Private clouds can provide similar types of software, platform and infrastructure services as public clouds, except that they are hosted for one consumer behind a firewall that restricts access to a limited set of client devices. They can be on or off-premise for the consumer.

Google Apps is available in a community cloud for Government agencies, and there is a vertical cloud for health-care.

Service-model examples

Cloud computing includes SaaS, PaaS and IaaS, and there are many examples of these.

SaaS constitutes the largest group of services, and the following are some specific examples:

PaaS comprises all software-development and run-time platforms that are available as cloud services.

IaaS examples include:

Exclusions

Cloud computing isn’t just the same as Internet computing, and the Intercloud doesn’t include all the websites on the Internet.

For example, the following are excluded from cloud computing:

  • Publicly accessible websites that process the same data for every visitor, such as web search engines. There is no private-data aspect for these sites.
  • All web pages that provide a calculation feature, but without managing private data, such as a financial institution’s loan-repayment calculator.
  • All sites that only provide information, rather than a computation facility.

Advantages

There are many possible advantages of cloud computing, but they may not apply to all consumers.

Reduced costs

Cloud services paid for on a usage basis can be financially advantageous for a consumer when compared to the outright purchase, or long-term rental, of what would be a big-budget item.

Also, there are reduced operating costs, because a cloud consumer does not need to house, staff and maintain their own equipment.

Up-to-date software

SaaS consumers can always have the most up-to-date software, because versioning is controlled centrally by the cloud provider, and when they make a new release it is automatically available to every user.

This is particularly advantageous for cloud desktops, because deployment of new software versions can be very costly and time consuming for a large organisation with many PCs, and because it can therefore be difficult to ensure that everyone has the same version of the organisation’s PC software applications at any one time.

Improved access

Cloud computing involves using the Internet, and this can provide access from multiple locations and many different types of user device.

Sharing and co-operation

Cloud services are advantageous, when compared to PCs and local servers, for activities that require co-operation among distributed groups.

Flexible and infinite scaling

Flexible and infinite scaling can be an advantageous feature of cloud-computing services, for example to allow for a sudden increase in demand by the users. This has traditionally been a difficulty for fully owned and self-managed IT resources, where there can be, for example, one server with a given, fixed size, and where some of its capacity may be wasted when demand is low, but where it may be overloaded, resulting in slow response times, when demand is high.

Simpler capacity planning

Cloud computing moves the IT capacity-planning role from the consumer to the cloud provider, and they can be in a better position to optimise the cloud resources used by their consumers than the consumers themselves would be for their own resources.

For example, the provider may be able to supply better demand smoothing, because they can perform capacity planning over a much larger pool of resources, and for a large group of consumers, whose peak loads will probably not occur all at the same time.

Risks

Besides the advantages of cloud computing, there are also risks, at least for some consumers.

Privacy and security

Because data is stored on a cloud provider’s systems, and possibly in a location that may not be known by the consumer, there can be data-privacy and security issues.

Concerns over lack of privacy arise because providers control the data, and so consumers could perceive a risk that they may:

  • Mine the data for their own use.
  • Share it with other organisations.
  • Lock the consumer out, for example if there is a commercial dispute.
  • Lock the consumer in, so that they can’t migrate to a different provider.
  • Lose data, particularly if their backup practices are not adequate to cope with emergencies.

Regulatory and customer requirements

There are some issues that may prevent the use of cloud services. For example:

  • Some organisations are required by regulations and laws to be responsible for the security and confidentiality of their customer’s data.
  • SLAs with customers and other associates may place restrictions on an organisation’s IT resource-management options.

Such issues may prevent organisations from using:

  • Third-party hosting
  • Hosting in any given location
  • A public cloud, however hosted.

Service-provider outages

Any accidental downtime, or outage, of cloud systems can affect some or all of the provider’s tenants, and so this can deprive many users of access to their IT systems. This is particularly true of large public clouds.

History

Origins

The concept

Telecom networks have been known as the cloud since at least the 1990s, and this was a symbolic metaphor used to represent the unseen network that delivered services invisibly. The term was also applied to large ATM networks in the early 1990s.

Cloud computing can be seen as a movement to apply the telecom cloud concept to IT.

Cloud symbols

Cloud symbols were used to represent the public telephone system on diagrams. Since this was the original basis of the Internet, through the use of dial-up modems, the cloud symbol was also adopted for the Internet, and it came into common use for this purpose in the 1990s.

New paradigm

Cloud computing has been a paradigm shift in IT acquisition and management, from outright purchase as a product, to consumption as a service. This has involved a change from dealing with technical capacity and performance specifications when choosing a supplier and a model number that can cope with projected user demand, to dealing only with economic considerations when choosing a service.

This is because visitors to an Internet website need only be concerned with the cost of using the available services, rather than with the IT infrastructure that supports the site. The technical details of this infrastructure can be left to the hosting organisation, and it is up to them to ensure that its performance and capacity specifications are adequate for the expected traffic. For these reasons, things are simpler for the users, as opposed to acquiring, sizing, housing, staffing and maintaining IT equipment for themselves.

The transition from ownership to cloud computing didn’t happen in one step, and in the history of this change there were other business models, such as outsourcing, and some related technologies, such as utility computing. However, the major shift has been from the exclusive use of a whole resource, such as a server or entire datacentre, over an extended period of time, such as several years, to consumption of a third-party operated service that may provide access to only part of a shared resource possibly contracted for on a short-term basis, such as monthly.

First uses of the term

The first uses of the term cloud computing were in the late 1990s, and in:

  • November 1996 it was coined by NetCentric, and applied as a marketing term.
  • May 1997 it was the subject of a trademark application (which was not approved).
  • October 1997 it was discussed in an academic conference, and described as a new “paradigm where the boundaries of computing will be determined by economic rationale rather than technical limits”.
  • November 1997, the first newspaper article on the subject was published.

Widespread adoption

Whilst there were earlier services, cloud computing started to gain widespread use from 2007.

Google Docs was launched in 2006, and it went mainstream in 2007. Also in 2007, Amazon, IBM and Microsoft started calling their Internet-based offerings cloud computing.

Google Trends shows cloud computing taking off as a search term in 2007, and as a news item in 2008.

Precursor technologies

There are many technologies that were in use before cloud computing, and that are either essential for its implementation, or that have some of the same characteristics.

Virtualisation

In IT, anything that is virtual does not exist as such, but is made to appear to exist through the use of software. Of course, this software runs on real computers that do actually exist, but the use of virtualisation techniques can make a relatively small computer appear to have a very large capacity, so that it can be shared by many concurrent activities. It has been available since the 1960s, when multi-user computers needed to provide a virtual memory to each process, so that they could share a relatively small real memory. Full virtualization of complete servers has been in use since the late 1960s.

Cloud computing uses virtualisation to implement independent virtual servers, with their own storage and software. For example, one of these, or even a network of them, can be made available to each of the many tenants of a public cloud, using a much smaller collection of real servers, or possibly only one server. This sharing of one server, or a small number, among very many virtual servers that each support their own tenants is one reason that cloud computing is advantageous, because there are economies of scale. It also enables flexible scaling and agile provisioning, since another virtual server can be made available instantly, because it can be done automatically, without necessarily purchasing any more equipment.

Timesharing

Timesharing, which originated in the 1960s, and which became a prominent computing model in the 1970s, involved sharing the resources of a mainframe computer among many concurrent users.

In the 1960s and 1970s, companies began to operate service bureaus that provided timesharing access for a fee.

Client-server computing

The client-server model of computing, which originated in the 1970s, is a type of distributed computing that separates out the:

  • Access points, called clients, which are used by only one person at a time, and which are therefore not shared.
  • Central servers, which supply applications and data, and which are shared among several clients that can access them at any one time.

All cloud-computing service-model examples are a development of client-server computing, and cloud datacentres contain one or more servers that are accessed via separate cloud clients. This is in contrast to P2P networks, in which all participating devices are both clients and servers, and there are some examples of these that are also part of cloud computing.

Utility computing

One typical characteristic of cloud computing is consumption as a utility, with payment only for what is used. This is similar to utility computing, which was available from the 1980s.

Originally, utility computing was not necessarily Internet accessible, and it may have involved very centralised, on-premise resources. However, later it was combined with the client-server model and then networks, and became more distributed. Later still, when combined with the Internet, it evolved into cloud computing.

The computer pioneer John McCarthy predicted in 1961 that computing would one day be delivered as a public utility.

Cluster computing

Cluster computing, which originated in the 1960s, is the use of a network of servers that are co-ordinated to achieve a common goal. It includes grid computing, which originated in the 1990s, and server farms. For example, a large organisation may provide its email service using a server farm consisting of several computers each of which deals with email addresses beginning with a few letters of the alphabet, such as one for all addresses beginning with “a”, “b” or “c”, and another for addresses beginning with “d”, “e” or “f”, and so on through the alphabet.

The use of multiple servers has advantages over an equivalently powerful single computer:

  • Fault tolerance: If there is an outage of one server, it may only lead to a partial degradation of service for some users, as opposed to an outage of one much larger computer, which could lead to a total degradation for all users.
  • Redundancy: Extra, standby servers can be included for failover in exceptional circumstances.
  • Load balancing: Further servers can be added at any time to cope with increased demand, without disturbing the other servers.
  • Cost: Purchasing many midrange computers can be more cost-effective than purchasing one large mainframe.

For these reasons, cloud datacentres can contain a cluster of servers, and each one of these may be able to support many virtual servers so as to allow for flexible scaling and easy provisioning.

Autonomic computing

Autonomic computing, which originated in 2001, is computing carried out by self-managed systems that can autonomously and automatically react to changing circumstances. For example, they can be self-repairing when there are outages, or they can be self-adjusting in reaction to changing demand from users.

Autonomic computing techniques are used to implement cloud computing because it is advantageous for resources to self-adjust in some circumstances. For example, cloud bursting is an application of this type of computing.

Long-term trends

Computer access

Since the adoption of computers during the 1950s, users have become more-and-more physically removed from their IT resources, and cloud computing is a further step in this trend.

Originally, users were required to visit a special room one at a time to use the computer, and one motivation for changing this situation was to enable more people to have concurrent use of computer resources.

This began with the advent of batch operating systems. With these systems, users would take their data on punched cards to the computer room, where they would be fed into the computer by a specialist computer operator, for a batch of different users all at the same time. The users would not be able to access the computer directly themselves. This was followed by multi-user operating systems, which were accessed via directly connected terminals not necessarily in the computer room, and then networks, where access to the computer would be via intermediate switching devices so that the users and the computers could be in separate places, including in different buildings.

The Internet, short for inter-networks, developed out of these networks to enable users to be in one place, and their IT resources to be in any other place in the world. Also, users could access their resources from any location with Internet access, not just a computer terminal in their office.

IT acquisition and management

There has been a long-term trend in IT acquisition and management away from outright purchase and self hosting of IT equipment, and cloud computing is part of this trend.

A major step before cloud computing was outsourcing, and the use of vendor hosting or third-party hosting, rather than self hosting. Originally, the equipment would be on the user’s premises, but with networks, the hosting could be in a different location, and then with the Internet there was even greater flexibility as to where resources could be hosted.

Resource sharing

Originally, any increase in the size of IT resources required the purchase, delivery and installation of extra hardware, which could involve a long delay. Because of this delay, resources were sometimes sized so as to cope with spikes, which meant purchasing a larger than normally required system, and so, since spikes may not occur frequently, if at all, the resources were very often under-utilised, and this was financially wasteful.

For this reason, there has been a trend in IT away from a static, fixed size of infrastructure to systems that can be shared and that can scale to cater for changing circumstances, such as extra users, more flexibly. Cloud computing is a further step in this trend.

One of the first developments was the use of virtualisation, and the advantage of this technology is the ability to provision new virtual servers easily, without purchasing new equipment. This allows new users to share the resources. Other developments included:

  • Pooling all of a large organisation’s IT resources in a data centre, rather than housing them in different departments. This made resource sharing easier.
  • Utility computing, where users have access only to part of a shared resource, and where the size of their share can be easily changed.

Cloud Computing Layers

Get StartedFree Consultation

Overview

As the cloud computing model gains in popularity it is important to understand the service layers that define it. Like the seven layer OSI model for networking, each layer of the cloud computing model exists conceptually on the foundation of the previous layers.

Within this model, there are three different service layers that are used to specify what is being provisioned, Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and Software as a Service (SaaS). Additionally, there are three further layers that are not provided as user services. The Hardware Layer and the Virtualization Layer are owned and operated of the cloud services provider while the Client Layer is supplied by the end users.

 

 

The Hardware Layer

The hardware layer is sometimes referred to as the server layer. It represents the physical hardware that provides actual resources that make up the cloud. Since, by definition, cloud computing users do not specify the hardware used to provide services, this is the least important layer of the cloud. Often, hardware resources are inexpensive and are not fault tolerant. Redundancy is achieved simply by utilizing multiple hardware platforms while fault tolerance is provided at other layers so that any hardware failure is not noticed by the users.

 

The Virtualization Layer

Often referred to as the infrastructure layer, the virtualization layer is the result of various operating systems being installed as virtual machines. Much of the scalability and flexibility of the cloud computing model is derived by the inherent ability of virtual machines to be created and deleted at will.

 

Infrastructure as a Service (IaaS)

The infrastructure layer builds on the virtualization layer by offering the virtual machines as a service to users. Instead of purchasing servers or even hosted services, IaaS customers can create and remove virtual machines and network them together at will. Clients are billed for infrastructure services based on what resources are consumed. This eliminates the need to procure and operate physical servers, data storage systems, or networking resources.

 

Platform as a Service (PaaS)

The platform layer rests on the infrastructure layer’s virtual machines. At this layer customers do not manage their virtual machines, they merely create applications within an existing API or programing language. There is no need to manage an operating system, let alone the underlying hardware and virtualization layers. Clients merely create their own programs which are hosted by the platform services they are paying for.

 

Software as a Service (SaaS)

Services at the software level consist of complete applications that do not require development. Such applications can be email, customer relationship management, and other office productivity applications. Enterprise services can be billed monthly or by usage, while software as service offered directly to consumers, such as email, is often provided for free.

 

The Client Layer

While this layer is not a cloud computing service, it is an essential part of the model. The client layer acts as the user interface to which cloud computing services are delivered. Client layer hardware can include personal computers, web browsers, mobile devices, and even telephones.

Conclusion

One of the beauties of the cloud computing model is the simplicity with which they are presented to the end users. At the same time, the cloud computing model actually consists of a complex series of interconnected layers. Understanding these layers is essential to any organization that wishes to utilize cloud computing services in the most efficient manner.

Cloud Computing Applications

The applications of cloud computing are practically limitless. With the right middleware, a cloud computing system could execute all the programs a normal computer could run. Potentially, everything from generic word processing software to customized computer programs designed for a specific company could work on a cloud computing system.

Why would anyone want to rely on another computer system to run programs and store data? Here are just a few reasons:

  • Clients would be able to access their applications and data from anywhere at any time. They could access the cloud computing system using any computer linked to the Internet. Data wouldn’t be confined to a hard drive on one user’s computer or even a corporation’s internal network.
  • It could bring hardware costs down. Cloud computing systems would reduce the need for advanced hardware on the client side. You wouldn’t need to buy the fastest computer with the most memory, because the cloud system would take care of those needs for you. Instead, you could buy an inexpensive computer terminal. The terminal could include a monitor, input devices like a keyboard and mouse and just enough processing power to run the middleware necessary to connect to the cloud system. You wouldn’t need a large hard drive because you’d store all your information on a remote computer.
  • Corporations that rely on computers have to make sure they have the right software in place to achieve goals. Cloud computing systems give these organizations company-wide access to computer applications. The companies don’t have to buy a set of software or software licenses for every employee. Instead, the company could pay a metered fee to a cloud computing company.
  • Servers and digital storage devices take up space. Some companies rent physical space to store servers and databases because they don’t have it available on site. Cloud computing gives these companies the option of storing data on someone else’s hardware, removing the need for physical space on the front end.
  • Corporations might save money on IT support. Streamlined hardware would, in theory, have fewer problems than a network of heterogeneous machines and operating systems.
  • If the cloud computing system’s back end is a grid computing system, then the client could take advantage of the entire network’s processing power. Often, scientists and researchers work with calculations so complex that it would take years for individual computers to complete them. On a grid computing system, the client could send the calculation to the cloud for processing. The cloud system would tap into the processing power of all available computers on the back end, significantly speeding up the calculation.

While the benefits of cloud computing seem convincing, are there any potential problems?

 

Platforms

Cloud computing has been called, among many different things, “platform as a service.” This specific name represents the fact that, to the user or developer, a cloud computing service looks like a “virtual system” on which applications are developed or run. Some platforms support only public cloud computing service use, others support only the creation of private clouds and a few support a mix of both.

Those who develop for, or deploy applications on, cloud computing resources both public and private may have to make a decision on which specific cloud computing platform to use. The wrong choice could negatively impact everyone involved, so it’s important to look at the choices carefully and consider short- and long-term issues in your decision.

Here are the key cloud architectures available today:

  • Amazon’s Elastic Compute Cloud, or EC2, is probably the most generalized and best-known of the cloud computing service offerings.
  • IBM Computing on Demand or Blue Cloud is a highly enterprise-focused cloud computing offering that, because it is related to and built with the same technology sold to enterprises, can cross over between public and private cloud applications.
  • Microsoft’s Azure cloud computing, based on Microsoft Vista and .NET technology, includes both cloud computing and cloud-hosted extension.

What is Cloud Computing Infrastructure?

  • While the term cloud computing has only come into popularity recently, it is used to describe a business practice that has been alive and well in the IT world for some time, especially when it comes to cloud computing infrastructure. While cloud computing sounds pretty nebulous, it is basically just a blanket term that covers any abstracted computer infrastructure managed by a third party that can host business applications which are billed based on consumption. This is radically different from the traditional method of IT resources in which a business needed to purchase all of its own hardware and software, as well as employ a team of IT professionals to keep it running and up to date. Let’s take a closer look at how cloud computing provides infrastructure solutions for businesses, especially when it comes to customer relationship management (CRM).
  • A classic example of cloud computing infrastructure comes in the example of cloud hosting. When a small business launches a successful website, it’s always thrilling to watch the visitor count climb and climb. However, the more customers visit and interact with the website and each other, the more pressure there is on the website’s server. It used to be that a website manager needed to buy or rent additional servers as quickly as possible before their visitors. If not, then the website might face diminishing returns as the site becomes bogged down by its own success and visitors quickly migrate elsewhere. This typically critical CRM problem for small to mid-sized businesses was solved by cloud hosting.
  • Cloud hosting is a type of cloud computing infrastructure in which a company or website manager purchases access to servers much like a resident pays for access to water and electricity. Just like those utilities, a user only needs to pay for the servers that they need while they need them. For instance, if a site that usually just goes through cloud hosting for one or two servers gets a sudden boost in traffic, the site manager can simply log in to his cloud hosting account and arrange for instant access to more servers. Once the traffic goes back to normal, he can adjust the requested servers so that he is just being billed for what he normally needs again. This all occurs behind the scenes of a growing website, where the increasing volume of customers and visitors notice no difference in speed or quality on the site, thanks to the flexibility that cloud computing provides.
  • This is but one example of the infrastructure as a service (IaaS) concept that is at the heart of cloud computing infrastructure. Gone are the days of every company big and small needing to purchase servers, office space, software and more just to have basic computer infrastructure. Instead, a business can get the majority of their computer infrastructure needs through utility computing that can address all of your computer hardware, networks and platforms off site. Cloud computing infrastructure is also dynamically scalable, allowing a business to make use of infrastructure resources for a wide range of capabilities. The cost of these resources is almost always both affordable and predictable, as all of the resources that are available typically have a fixed price associated with them driven by market demand.
  • Naturally, the savings garnered from cloud computing infrastructure as opposed to the traditional methods are substantial. Rather than purchasing expensive equipment, leasing space solely to store data centers and gobbling up your IT department’s man power, nearly all of your infrastructure needs can be met in one bill. With the scalability and customization available to cloud computing users, a business can pick and choose exactly what they need for their operation: no more, no less. With a solid computer infrastructure that you can tweak to meet the demands of your employees and customers, cloud computing allows you to make real time adaptations to you system that can address CRM concerns as soon as they arise.

Cloud Deployment Models – Private, Community, Public, Hybrid

How are Cloud Computing Solutions deployed? What are the general implications for different deployment options? A couple of months back I wrote about Cloud Service Models – Which one is for you? This post will cover another basic of Cloud Computing, popularly known as Cloud Deployment Models.

The content of this post is based on the recommendations of the National Institute of Standards and Technology (NIST) – Special Publication 800-146. The credit for the images used in this article goes to NISTSpecial Publication 800-146. Please check references for details. This document is not subject to copyright.

Following are the four types of Cloud Deployment Models identified by NIST.

  • Private cloud
  • Community cloud
  • Public cloud
  • Hybrid cloud

Private Cloud

The cloud infrastructure is operated solely for an organization.    —NIST

Contrary to popular belief, private cloud may exist off premises and can be managed by a third party. Thus, two private cloud scenarios exist, as follows:

  • On-site Private Cloud
    • Applies to private clouds implemented at a customer’s premises.
  • Outsourced Private Cloud
    • Applies to private clouds where the server side is outsourced to a hosting company.

Examples of Private Cloud:

  • Eucalyptus
  • Ubuntu Enterprise Cloud – UEC (powered by Eucalyptus)
  • Amazon VPC (Virtual Private Cloud)
  • VMware Cloud Infrastructure Suite
  • Microsoft ECI data center.

 

 

Community Cloud

The cloud infrastructure is shared by several organizations and supports a specific community that has shared concerns (e.g., mission, security requirements, policy, and compliance considerations).  Government departments, universities, central banks etc. often find this type of cloud useful. Community cloud also has two possible scenarios:

  • On-site Community Cloud Scenario
    • Applies to community clouds implemented on the premises of
      the customers composing a community cloud
  • Outsourced Community Cloud
    • Applies to community clouds where the server side is
      outsourced to a hosting company.

Examples of Community Cloud:

  • Google Apps for Government
  • Microsoft Government Community Cloud

 

 

Public Cloud

The most ubiquitous, and almost a synonym for, cloud computing. The cloud infrastructure is made available to the general public or a large industry group and is owned by an organization selling cloud services.

Examples of Public Cloud:

  • Google App Engine
  • Microsoft Windows Azure
  • IBM Smart Cloud
  • Amazon EC2

 

Hybrid Cloud

The cloud infrastructure is a composition of two or more clouds (private, community, or public) that remain unique entities but are bound together by standardized or proprietary technology that enables data and application portability (e.g., cloud bursting for load-balancing between clouds).

Examples of Hybrid Cloud:

  • Windows Azure (capable of Hybrid Cloud)
  • VMware vCloud (Hybrid Cloud Services)

 

Cloud Deployment Implications

Irrespective of the deployment model, in general any organization opting for cloud must consider the following implications:

Network Dependency –  Whether you choose, on-site or off-shore, a reliable and secure network is highly desirable for good performance.

Subscribers still need IT skills – You can’t just offer a pink-slip to all your IT resources. To manage various user devices that access cloud, resources with traditional IT skills are required, though in lesser number. Additionally, your existing resources may need to update themselves with new skills for working in cloud.

Risk from multi-tenancy –On-site private cloud mitigates this security risk by restricting the number of possible attackers as all the clients are typically the members of one subscriber organization. In a public cloud scenario, a single machine may be shared by the workloads of any combination of subscribers. This indeed raises the security risk as the number of potential attackers increases with number of subscribers. Therefore we can safely conclude that risk due to multi-tenancy increases in an order which can be stated as Private, Community, Hybrid, Public cloud.

Data import/export and performance limitations – Generally the on-demand bulk data import/export is limited by the cloud’s network capacity. In the on-site
private cloud scenario, however, these limits may be adjusted, although not eliminated, by provisioning high-performance and/or high-reliability networking within the subscriber’s infrastructure.

Workloads Locations – Workloads refers to managing hardware resources efficiently. Generally, cloud migrates workloads between machines without any inconvenience to the clients, i.e., it’s hidden from the client. Generally, the cloud vendors take care of this but you must explicitly check with your vendor if it manages the resources efficiently.

The implications described here are general in nature. Before making any decision in favor of a specific deployment model, study the detailed implications of that particular deployment model. For details, please check the reference section.

Issues

Privacy

The cloud model has been criticised by privacy advocates for the greater ease in which the companies hosting the cloud services control, thus, can monitor at will, lawfully or unlawfully, the communication and data stored between the user and the host company. Instances such as the secret NSA program, working with AT&T, and Verizon, which recorded over 10 million phone calls between American citizens, causes uncertainty among privacy advocates, and the greater powers it gives to telecommunication companies to monitor user activity. Using a cloud service provider (CSP) can complicate privacy of data because of the extent to which virtualization for cloud processing (virtual machines) and cloud storage are used to implement cloud service. The point is that because of CSP operations, customer or tenant data may not remain on the same system, or in the same data center or even within the same provider’s cloud. This can lead to legal concerns over jurisdiction. While there have been efforts (such as US-EU Safe Harbor) to “harmonise” the legal environment, providers such as Amazon still cater to major markets (typically the United States and the European Union) by deploying local infrastructure and allowing customers to select “availability zones.Cloud computing poses privacy concerns because the service provider at any point in time, may access the data that is on the cloud. They could accidentally or deliberately alter or even delete some info.

Compliance

In order to obtain compliance with regulations including FISMA, HIPAA, and SOX in the United States, the Data Protection Directive in the EU and the credit card industry’s PCI DSS, users may have to adopt community or hybrid deployment modes that are typically more expensive and may offer restricted benefits. This is how Google is able to “manage and meet additional government policy requirements beyond FISMA and Rackspace Cloud or QubeSpace are able to claim PCI compliance.

Many providers also obtain a SAS 70 Type II audit, but this has been criticised on the grounds that the hand-picked set of goals and standards determined by the auditor and the auditee are often not disclosed and can vary widely. Providers typically make this information available on request, under non-disclosure agreement.

Customers in the EU contracting with cloud providers established outside the EU/EEA have to adhere to the EU regulations on export of personal data.

U.S. Federal Agencies have been directed by the Office of Management and Budget to use a process called FedRAMP (Federal Risk and Authorization Management Program) to assess and authorize cloud products and services. Federal CIO Steven VanRoekel issued a memorandum to federal agency Chief Information Officers on December 8, 2011 defining how federal agencies should use FedRAMP. FedRAMP consists of a subset of NIST Special Publication 800-53 security controls specifically selected to provide protection in cloud environments. A subset has been defined for the FIPS 199 low categorization and the FIPS 199 moderate categorization. The FedRAMP program has also established a Joint Acceditation Board (JAB) consisting of Chief Information Officers from DoD, DHS and GSA. The JAB is responsible for establishing accreditation standards for 3rd party organizations who will perform the assessments of cloud solutions. The JAB will also review authorization packages and may grant provisional authorization (to operate). The federal agency consuming the service will still have the final responsibility for final authority to operate.

Legal

As can be expected with any revolutionary change in the landscape of global computing, certain legal issues arise; everything from trademark infringement, security concerns to the sharing of propriety data resources.

Open source

See also: Category:Free software for cloud computing

Open-source software has provided the foundation for many cloud computing implementations, one prominent example being the Hadoop framework. In November 2007, the Free Software Foundation released the Affero General Public License, a version of GPLv3 intended to close a perceived legal loophole associated with free software designed to be run over a network.

Open standards

See also: Category: Cloud standards

Most cloud providers expose APIs that are typically well-documented (often under a Creative Commons license) but also unique to their implementation and thus not interoperable. Some vendors have adopted others’ APIs and there are a number of open standards under development, with a view to delivering interoperability and portability.

Security

Main article: Cloud computing security

As cloud computing is achieving increased popularity, concerns are being voiced about the security issues introduced through adoption of this new model. The effectiveness and efficiency of traditional protection mechanisms are being reconsidered as the characteristics of this innovative deployment model can differ widely from those of traditional architectures. An alternative perspective on the topic of cloud security is that this is but another, although quite broad, case of “applied security” and that similar security principles that apply in shared multi-user mainframe security models apply with cloud security.

The relative security of cloud computing services is a contentious issue that may be delaying its adoption. Physical control of the Private Cloud equipment is more secure than having the equipment off site and under someone else’s control. Physical control and the ability to visually inspect the data links and access ports is required in order to ensure data links are not compromised. Issues barring the adoption of cloud computing are due in large part to the private and public sectors’ unease surrounding the external management of security-based services. It is the very nature of cloud computing-based services, private or public, that promote external management of provided services. This delivers great incentive to cloud computing service providers to prioritize building and maintaining strong management of secure services. Security issues have been categorised into sensitive data access, data segregation, privacy, bug exploitation, recovery, accountability, malicious insiders, management console security, account control, and multi-tenancy issues. Solutions to various cloud security issues vary, from cryptography, particularly public key infrastructure (PKI), to use of multiple cloud providers, standardisation of APIs, and improving virtual machine support and legal support.

Cloud computing offers many benefits, but it also is vulnerable to threats. As the use of cloud computing increase, it is highly likely that more criminals will try to find new ways exploit vulnerabilities in the system. There many underlying challenges and risks in cloud computing that increase the threat of data being compromised. To help mitigate the threat, cloud computing stakeholders should invest heavily in risk assessment to ensure that system encrypts to protect data; establish trusted foundation to secure the platform and infrastructure; and build higher assurance into auditing to strengthen compliance. Security concerns must be addressed in order to establish trust in Cloud computing technology.

Sustainability

Although cloud computing is often assumed to be a form of “green computing“, there is no published study to substantiate this assumption. Citing the servers affects the environmental effects of cloud computing. In areas where climate favors natural cooling and renewable electricity is readily available, the environmental effects will be more moderate. (The same holds true for “traditional” data centers.) Thus countries with favorable conditions, such as Finland, Sweden and Switzerland, are trying to attract cloud computing data centers. Energy efficiency in cloud computing can result from energy-aware scheduling and server consolidation. However, in the case of distributed clouds over data centers with different source of energies including renewable source of energies, a small compromise on energy consumption reduction could result in high carbon footprint reduction.

Abuse

As with privately purchased hardware, customers can purchase the services of cloud computing for nefarious purposes. This includes password cracking and launching attacks using the purchased services. In 2009, a banking trojan illegally used the popular Amazon service as a command and control channel that issued software updates and malicious instructions to PCs that were infected by the malware.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Glossary: Cloud Computing

Cloud Computing Glossary

Advertising-based pricing model : A pricing model wherein cloud services are offered to users at low or no cost, with the service provider being compensated by advertisers whose ads are delivered to the user along with the service.  Google

CDN:Content delivery network- a system consisting of multiple computers that contain copies of data which are located in different places on the network so clients can access the copy nearest to them

Cloud: A Metaphor used for global network. Historically it was first used in reference to the telephone network and currently commonly used to represent the Internet.:

Cloud broker:A service/entity that creates and maintains relationship with multiple cloud service providers.  It acts as a liaison between cloud service users and cloud service providers, selecting the best provider for each user monitoring the service.

Cloud operating system

A computer operating system that is designed specially to run in a service provider’s datacenter and be delivered to the user over the Internet

Example:

  1. Microsoft Azure is a cloud operating system that runs on windows server 2008.
  2. Google Chrome which refers to cloud-based client operating client based operating system

Cloud oriented architecture

An architecture where applications act as services in the cloud and serve other applications in the cloud environment

Cloud portability

The ability to move application and data from one cloud service provider to another

Cloud provider

A company that provides cloud-based platform, infrastructure, applications, or storage service to other organizations and individuals. The provision is usually for fee.

Cloud storage

A service that allows users to save data by transferring it over to the Internet or another network to an offsite system maintained by a third party

Cloud sourcing

Replacing traditional IT services with cloud services

Cloud storming

Connecting multiple cloud computing environments

Cloudware

Software that enables creating, deploying, running, or managing applications in the cloud

Cluster

  1. A group of linked computers that work together as a unified resource, for high availability and / or load balancing
  2. Cluster computing: Cluster computing is a form of distributed computing in which resource allocation is performed by a centralized resource manager and all nodes co-operatively work together as a single unified resource.

Consumption-based pricing model

A pricing model whereby the service provider charges its consumers based on the amount of the service the user consumes, rather than time-based fee. For example, a cloud storage provider might charge per GB of information stored.

Tata example

Customer self-service

A feature that allows customers to provision, manage, and terminate service themselves , without involving the service provider, via a web interface or programmatic calls to service ie APIs

Elastic computing

The ability to dynamically provision and de-provision processing, memory, and storage resources to meet demands of peak usage without worrying about capacity planning and engineering for peak usage

External cloud

Public cloud services that are provided for outside users

Grid Computing

The Grid is a type of parallel and distributed computing system (peer-to-peer computing) that enables the sharing, selection, and aggregation of geographically distributed autonomous resources (nodes)  dynamically at runtime depending on their availability, capability, performance, cost and user’s quality-of-service requirements. In Grid computing, each node has its own resource manager, providing a single system view. Autonomous resources in grid computing may span across single or multiple organizations. Grid aims at exploiting synergies that result-from cooperation – ability to share and aggregate distributed computational capabilities.

HaaS

Hardware as a service

Hosted application

An Internet- based or web-based application software program that runs on a remote server and can be accessed via an Internet-connected PC or thin client

Hybrid cloud

A networking environment that includes multiple integrated internal and or public clouds

IaaS

Infrastructure as a service also known as IaaS. It is one of three service models in cloud computing. In IaaS- cloud infrastructure services, where by a virtualized environment is delivered as a service over the Internet by the provider. The Infrastructure can include servers, network equipment, and software

Internal Cloud

A type of private cloud whose services are provided by an IT department to those in its own organization

Mash up

A web-based application that combines data and / or functionality from multiple sources

Example

Middleware

Software that sits between applications and operating system, consisting of set of services that enable interoperability in support of distributed architecture by passing data between applications.  So, for example , the data in database can be accessed through another database

On-demand service

A model by which a customer can purchase cloud services as needed; for instance if customers need to utilize additional servers for the duration of a project, they can do so and then drop back to the previous level after the project is completed.

PaaS

Platform as a service- Cloud platform services, whereby the computing platform ( operating system and associated services) is delivered as a service over the Internet by the provider

Pay as you go

A cost model for cloud services that encompasses both subscription-based and consumption-based models, in contrast to traditional IT cost model that requires up-front capital expenditures for hardware and software.

Private cloud

Service offered over the Internet or even over a private internal network to only select users, not available to the general public

Public Cloud

Public cloud services offered over the public Internet and available to anyone who wants to purchase the service

SaaS

Software as a service- cloud applications service, whereby applications are delivered over the Internet by the provider, so that the applications don’t have to be purchased, installed, and run on the customer’s computers. SaaS providers were earlier known as ASP (application service providers)

Service migration

The act of moving from one cloud service or vendor to another

Service provider

The company or organization that provides a public or private cloud service

SLA

Service level agreement – A contractual agreement by which a service provider defines the level of service, responsibilities , priorities , and guarantees regarding availability , performance, and other aspects of the service

Subscription-based pricing model

A service pricing model that lets customers pay a fee to use the service for a particular time period, often used for SaaS services

Utility computing

Online computing or storage sold as a metered commercial service in a way similar to public utility

Vendor lock-in

Dependency on the particular cloud vendor and difficulty moving from one cloud vendor to another due to lack of standardized protocols, APIs, data structures (schema), and service models

Vertical cloud

 

 

 

 

 

 

A Cloud computing environment that is optimized for use in a particular industry, such as health care or education or financial service

Virtual private data centre

Resource grouped according to specific business objective

 

 

 

 

 

NOTES

 

Opposite views on cloud computing

Some experts and vendors define cloud computing narrowly as an updated version of utility computing: essentially virtual servers available over the Internet.

Other defines cloud computing broadly saying that any thing we consume outside the firewall is in the cloud, including conventional outsourcing.

Variety of cloud computing

There are many patterns, or categories, in the world of cloud computing that individuals and institutions can use to meet the needs of enterprise architecture. Some solve specific problems such as security-as-a-service or testing as a service, and some provide complete platform, such as Plat-form-as a service or infrastructure as a service. Cloud computing encompasses any subscription-based or pay-per-use service that, in real time over the Internet , which extends IT’s existing capabilities

Currently cloud computing is an early stage , with diverse crew of providers, large and small , delivering a slew of services , from full blown applications to storage services to spam filtering.

 

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

 

More informations about Network

Computer networks: summary

 

The following gives an overview of computer networks and data communication:

»The basic principles

»Local area networks

»National computers networks

»International computer networks

»The Internet

»Future impact of digital communication networks

 

 

Computer networks: prerequisites

Before using computer networks, you should ideally have some knowledge and skills related to

• computer hardware

• computer software

Data communication: a definition

 Interpersonal communication

»Telecommunication

—Broadcast

—Telephone

—Data communication

–Remote login

–File transfer

–Hypertext transfer

–Electronic mail

Data communication: various views

User

(Applications)

Database producer

(Information)

Sociologist

(Sociological aspects)

Engineer

(Techniques)

Data communication: which types of ‘data’?

Linear text Hypertext

Sound

Static images Video

Multimedia / Hypermedia

Programs for computers

Digital information

Telecommunication: digital versus analogue

• Morse   digital

• Telephone          analogue (or digital)

• Data communication          digital

Data communication: which types of ‘data’?

 

• The same types of data (information) that can be stored and managed on a computer can be transferred over computer networks to one or several other computers. So the networks form an important extension of the stand-alone computers. “The network is the computer”

 

Data communication: applications

 

• Hard-copy transfer (Fax)

• Online use of the processing power of a remote computer

• Online access to information sources !

»library catalogues,

»bookshop catalogues,

»publisher’s catalogues,

»campus-wide and community information systems,

»(text or multimedia) databases,

»network-based journals,

• Software-downloading

• Electronic mail from a person to one or several persons

• Computer-network based interest groups

• Online talking / chatting (IRC,…)

• Video conferencing (Cu-seeme, …)

• Selling, shopping, buying,..

 

Computer network applications: information and communication

 

1-way = information transfer = almost no interaction

• publications by e-mail / Internet radio

• file transfer

• (gopher) / core WWW based on http and static html pages

• network services based on databases (input or searches)

• e-mail communication / Usenet News

• chat / telephony / video conferencing

N-way = communication       = highly interactive

 

Computer networks: an analogy

Traditional Networks

• Letter Envelope

• Mail-box Post office, Roads

Hypermedia Protocol Client Server Networks

 

Example

Computer network applications related to journalism

• Journalists search for information online.

• Publishers make the products of the journalists available online.

• Journalists communicate with their readers by electronic mail.

 

 

 

Data communication: problems, difficulties, limitations

• Low transfer speed

• Technical complexity

 

Data communication: modems

• description: MODulator-DEModulator: device to convert digital data signals into a suitable form for transmission along a telecommunications channel, and to convert them back upon receipt into machine readable form.

• types

»(Acoustic coupler)

»Free standing box

»Board/card to plug-in microcomputer

Data communication: transmission modes

• Simplex

Transmission in one way only

• Half duplex

Transmission in both directions, but not at the same time

• Full duplex Transmission in both directions at the same time

Data communication: trade offs

Cost

LAN(short distance)

Dial-up/PAD (low speed)

Speed High volume (high cost) Distance

 

Computer network protocols: definition

• When 2 computer systems communicate via network, they do that by exchanging messages. The structure of network messages varies from network to network. Thus the message structure in a particular network is agreed upon a priori and is described in a set of rules, each defined in a protocol.

Computer network protocols: Open Systems Interconnection

The evolving international standard under development at ISO (International Standards Organization)for the interconnection of cooperative computer systems. An open system is one that conforms to OSI standards in its communications with other systems.

 

Computer networks, data communication and Internet Local Area Networks. A local area computer network: scheme

Data communication with a server in a Local Area Network(Terminal) ,Microcomputer with serial line,communications software / terminal emulation software,Microcomputer with network card and network software,Network server,Applications of server computers in a LAN,Extra personal disk space for the users, Common files with programs and/or data for many users,(e.g. an intranet) Making files available from the institute to external users over the Internet (e.g. using ftp, gopher, or http/WWW!)

 Executing programs on a server in the LAN

(e.g. using Unix or Windows NT or Windows 2000, in multi-tasking / multi-user mode)

• Electronic mail servers; Usenet servers;…

 

Examples

 

LAN software packages for homogeneous networks: examples

• Intel compatible processors:

»LANtastic,

»Novell,

»Windows for Workgroups,

Windows 95, Windows 98, Windows ME, Windows 2000, Windows XP…

• Apple, …

****Examples

LAN software packages for heterogeneous networks: examples

Based on TCP/IP (protocol suite used in Internet)

• For DOS:

NCSA (= National Center for Supercomputing Applications) CUTCP, PC/NFS,…

• For Windows 3.x:

PC/NFS, PC/TCP, Trumpet TCP Manager,…

• For Windows 95, 98,…: included!

• For Windows NT, 2000,…: included!

 

Packet switching

     Packet switching in data communication networks: definition Communication is not through a continuous stream of bits, but in small packets.Routing, the followed route, may change during communication session.Packet switching in data communication networks: scheme = Computer  =  “Packet Switching Exchange”

Packet switching in communications: advantages

• Economic usage/exploitation of existing communication lines in the network, resulting in less network congestion higher data communication speed lower cost Less risk of interruptions due to breaks in a link of 2 nodes = higher reliability = less vulnerable Possibility of error correction of individual packets

Packet switching protocols: examples

• TCP/IP in the Internet

• X-25 in OSI networks

The X.25 data communication protocol

• protocol for packet switching in data network

• an alternative to dial-up over voice telephone lines with modems

• available in several “flavours”:direct X.25 trunk connects over leased lines through “PAD” interfaces by ordinary dial-up modem access to X.25 “ports” Increasing quality.

 

X.25 versus phone + modem for data communication

Whether you use X.25 or phone plus modem depends on a number of factors; usually the determining factor is cost.In North America, using a high speed modem over a telephone line tends to be less expensive.In Europe, the phone system structure usually makes X.25 more cost- effective.

Computer networks,

National Wide Area Networks

• Public access national packet switching networks

• Research computer networks

• Public access made available by Internet Service Providers

Examples

National public access computer networks: examples

• Belgium:            DCS (Data Communication Service)

• Nederland:         Datanet

• United Kingdom:  PSS (Packet Switching Service)

• France:  Transpac

Examples

National research computer networks: examples

• Belgium:            BELNET

• Finland: FUNET

• Germany:           DFN

• The Netherlands:  Surfnet

• United Kingdom:  JANET (Joint Academic Network)

International computer networks

International computer networks: examples

• National public data communication networks linked together

• FidoNet

• Bitnet / EARN

• Usenet

• Internet!

International connectivity map

• “Internet” is not well-defined.

 A network of smaller networks:

The global collection of interconnected local area, regional and wide-area (national backbone) networks which use the TCP/IP suite of data communication protocols. Links computers of various types. Is constantly growing the analogy of a superhighway has been used to describe the emerging system of networked computers. The Internet has no owner, and is not managed by one organization.

 

access from your Local Area Network Your microcomputer Local Area Network (LAN) One of the national networks The global Internet Host computers in the Internet: definition

• A host (computer) is a domain name that has a unique IP address record associated with it. Could be any computer connected to the Internet by any means.For instance: www.vub.ac.be Data communication layer architecture

User Application layer

 Transport layer

Network layer

Link layer

Internet data communication layers and protocols

USER

Application programs, using application protocols such as

smtp, pop, imap, nntp, telnet, ftp, gopher, http…

TCP = host to host transfer control protocol IP = Internet protocol

different physical nets

Internet data communication layers and protocols (Part 2)

USER

Client     Server

Computer

Client application programs Application protocols TCP IP

Computer Server application programs

Application protocols

TCP IP

different physical nets

Transmission Control Protocol / Internet Protocol (TCP/IP)

• the main suite of transport protocols used on the Internet for connectivity and transmission of data across heterogeneous systems

• “glue that holds the Internet together”

• an open standard

• available on most Unix systems, VMS and other minicomputer systems, many mainframe and supercomputing systems and some microcomputer and PC systems

TCP/IP hardware

The most common hardware system / solution used for actual physical connections using TCP/IP in a Local Area Network is Ethernet, but TCP/IP will also run on Token- Ring, serial lines (modems, serial connections) and other

systems as well.

 

TCP/IP:

Serial Line Internet Protocol (SLIP)

• SLIP is a standard on the Internet for RS232 serial line and modem connectivity between two systems. This allows any one SLIP client to connect to a SLIP server to provide connectivity between different IP hosts.

• Both systems must have TCP/IP stacks running.

• SLIP packages are available for PC systems.

TCP/IP:

Point to Point Protocol (PPP)

• successor to SLIP

• built in operating system software Windows 95,…

Internet application protocols / services based on the Internet (1)

• telnet    protocol for remote terminal login

• ftp       file transfer protocol

• gopher  communication using gopher menus

• WAIS, Z39.50 for database searching

• http      hypertext transfer protocol (WWW)

Internet application protocols / services based on the Internet (2)

• smtp     simple mail transfer protocol (e-mail) to send messages

• pop      post office protocol (e-mail) to read e-mail messages

imap      another protocol for reading e-mail messages

• nntp     network news transfer protocol in Usenet

•Internet: addresses of computers with the Domain Name System

• Internet style = Domain name system

• The Internet naming scheme consists of a hierarchical sequence of names from the most specific to the most general (left to right), separated by dots.

computer.subdomain.domain.(country if not USA)            OR n1.n2.n3.n4

where n is a natural number (8-bit)

Examples

The Internet Domain Name System DNS: examples

• Belgium:

»ftp.vub.ac.be

»www.vub.ac.be

• U.S.A.:

»dialog.com

»ftp.cs.widener.edu

Internet domain names in the United States

Most Internet sites in the US, Canada and US overseas installations follow a breakdown into six generic domains:

»EDU:  educational sites, such as universities

»COM: commercial sites, generally large corporations

»GOV: non-military government sites

»MIL: military installations

»ORG: non-commercial, non-network sites and gateways

»NET: other networks to which e-mail must traverse a gateway

 

Internet: the basic methods to connect

• Method 1: Connect your computer to

Increasing  power

»the LAN of your institute, that includes a server computer connected to an Internet Service Provider, or

»an Internet Service Provider, using a a cable modem + a public cable network

• Method 2: Dial from your computer into an external Internet Service Provider,

using a modem + the public voice telephone network

• (Method 3: Connect your computer to an external Internet host that provides Internet services.)

Internet: the basic methods to connect (Part 2)

Method 1:

full-time Internet host

Method 2:

part-time Internet host

(Method 3:

using another Internet host)

Increasing  power

Internet: TCP/IP in

the basic methods to connect

Method 1: TCP/IP

Increasing  power

between your computer and the rest of the Internet, at high speed.

Method 2: TCP/IP between your computer and the rest of the Internet, but speed limited by the modem and the telephone network

(Method 3: TCP/IP between the Internet host you connect to and the rest of the Internet, but not between your computer and that Internet host.)

Internet: trade offs in the basic methods to connect

Cost

(SLIP or) PPP       Shell-account on a server

User interface

Direct access

Speed

Internet Service Provider = ISP

Internet Service Providers provide their clients access to Internet + in many cases

»an email address / server

»space for a web site

»software tools to start

»training

»technical support

»an accessible location for a WWW site of the client

»assistance with WWW site design and promotion

Internet

end-user equipment

Several types of equipment allow connection to Internet:

• PC + Internet connection!

• WebTV

• Webphone = Screenphone

(based on for instance JavaOS by Sun)

 

The Core Internet and the Consumer Internet

• Core Internet = all computers that can provide interactive Internet services (such as telnet, ftp, gopher, http,…)

using server programs

• Consumer Internet = all computers that can use interactive Internet services, using client programs (such as WWW browsers)

 

Internet:

WAP = Wireless Application Protocol

• A public/open, global specification that empowers mobile users with wireless devices to easily access and interact with information and services instantly over the Internet.

• It allows to deliver and to access information evn when the full screen environment is either not available or not necessary.

Internet WAP: problems

• Wireless devices represent the ultimate constrained computing device with limited CPU, memory, and battery life, and with only a simple user interface. Wireless networks are constrained by low bandwidth, and unpredictable availability and stability.

Internet WAP: the architecture

A network-based course about computer networks

Internet in schools: aims and applications Applications by the teachers. Applications by the students. stimulates interest in information technology in general. Internet-assisted teaching and learning: advantages  For many people the learning materials are accessible fast and at low cost.

(However, a version printed in multiple copies can be cheaper than a version printed by individual users.) The updates, corrections and improvements of the course material are accessible faster than when print is used for distribution. Internet-assisted Links to other Internet-based information sources can be offered in the course material, better than in a printed course. Permanent self assessment by students can work better than with printed course material. Internet-assisted Communication students – professor – teaching assistant(s) – administration/secretariat can be offered, based on an e-mail group, a Usenet Newsgroup or a web-based group, for each course. Furthermore, an archive of messages can be stored and can be made searchable. In this way one can save time and costs related to travel to a classroom and communication is not limited to fixed contact hours.

 

 Multimedia

(coloured graphics, sound, animations, video,…) can be integrated well in the course material.

• To create a better social environment for study, professors as well as students can make information about themselves available through the web for the students. Adaptive hypertext is possible, but more complicated to develop.

teaching and learning: limitations

• Students should have access to a suitable computer and to Internet at an acceptable price. The contents of the computer-based course should be easily conveyable without personal contacts and practical work. Interactive work that requires real-time access to the server computer can be too expensive due to the telecommunication cost.

 

Windows software versions: their suitability for Internet usage

Licensing fee / price / costs RAM required

Includes TCP/IP stack

Set-up of Internet applications Allows (faster) 32-bit programs Problems with limitations of Windows “resources”

 

Integrated Services Digital Network : What is it?

• Integrated Services Digital Network = ISDN

• intended as a worldwide upgrade to digital status for the Public Switched Telephone Network

• 64 kbits/s up to 2 Mbits/s available (which is higher than with a modem)

• designed to be delivered over existing copper wires

• allows simultaneous transfer of sound, text and numbers, graphics (fax),…

 

Integrated Services Digital Network : applications

• backup of leased lines

• interconnection of LANs

• home-office use

• home use: telephone, fax, network access,…

• supporting existing analogue equipment if necessary

.Money transfer via the networks: increasing importance

• Money transfer over the Internet and public access networks is not secure without precautions.

• Several systems will allow secure money transfer, even for small amounts of money, with only small transfer costs:

“Digital cash”, “Cyberbucks”,…

Money transfer via the networks: impact on services offered

• Many services and sources of information, offered free of charge previously, may start charging money. Many services and sources of information, which were previously not offered, because there was no good charging and paying mechanism available, may be offered at a price.

 

Microcomputer — external computer: some ways of data communication

Micro- computer Modem Tele- phone ISDN

Voice telecommunication  network TelePAD LAN Local PAD

Public data comm. network Gateway computer system External computer Private/academic data comm. network (e.g. Internet) Leased, fixed communication line Intern Extern Computer networks,

 

The future impact of digital communication networks

Future impact of digital communication networks

Extreme scenarios:

• Boom scenario: evolution to ‘computopia’

• Doom scenario: evolution to a digital ‘brave new world’

Computer-based communication: boom scenario

Evolution to ‘computopia’

• International, interpersonal communication increases, using the international computer communication networks.

• Information gap (between information rich and information poor) disappears: access from everywhere (even from developing countries) to internationally available information.

• Capitalism and repression disappear.

Computer-based communication: doom scenario

Evolution to a digital ‘brave new world’

• Face-to-face, interpersonal communication disappears.

• Information gap

(between information rich and information poor) becomes larger.

• Capitalism uses the evolving techniques for increased control and repression.

The world of information from your desktop

Data transfer rate between components of computer systems

Data transfer rates: introduction

• The speed of delivery of information = data transfer rate.

• This is always limited by the weakest component.

• High quality graphics, audio, animation, video,… typically require a high transfer speed.

• When a transfer system (medium, channel,…) is used (shared) by more than one user, the effective, practical transfer rate decreases of course.

Data transfer rate of various computer systems/media Type

14.4 kbits/s modem

28.8 kbits/s modem ISDN

T1 Internet line 1x CD-ROM Ethernet

24x CD-ROM

USB Transfer rate

1.8 KB/s

3.6 KB/s

7-16 KB/s

30 –200 KB/s

150 KB/s

1 000 KB/s

3 600 KB/s

12 000 KB/s

EXERCISES

 

MULTIPLE CHOICE QUESTIONS

 

  1. Which of the following topologies is a combination of more than one topologies?

 

a. Bus

b.

Tree
c. Star

d.

None of these

 

  1. Which of the following is used for wireless communication?

 

  1. Optical Fiber                         b.       UTP cable

 

c.    Radio Waves                         d.       Coaxial Cable

 

  1. Which of the following is not a transmission medium?

 

  1. Telephone Network                b.       Coaxial Cable

 

c.    Modem                                 d.       Microwaves

 

  1. IP addresses of two computers on a network:

 

  1. Can be the same                    b.       Cannot be the same

 

c.    Are not defined                     d.       Must match with a third computer

 

  1. Bluetooth can be used for

 

  1. Long distance communication b.     Short distance communication

 

c.    In mobile phones only            d.       None of the above

 

  1. Micro waves are

 

  1. Uni directional                      b.       Omni directional

 

c.    Guided media                       d.       Not used for communication.

 

 

  1. Snooping is

 

  1. A threat to data security             b.      Not a threat to data security

 

c.    Good for laptops                        d.      A topology

 

  1. A repeater

 

  1. Regenerates the received signal   b.      Destroys the received signal

 

c.    Can be used as a hub                   d.      None of the above

 

  1. Satellite links are generally used for

 

  1. PANs                                         b.      LANs

 

c.    MANs                                        d.      All of the above

 

  1. A domain name maps to

 

a. A URL

b.

An IP address
c. A website

d.

All of the above

 

ANSWER THE FOLLOWING QUESTIONS

 

  1. What is a computer network? What are its advantages?

 

  1. What is meant be communication channels? Give two examples of guided media and two examples of unguided media.

 

  1. Which communication channel(s) is/are suitable in each of the following situations:

 

  1. Setting up a LAN

 

  1. Transfer of data from a laptop to a mobile phone.

 

  1. Transfer of data from one mobile phone to another.

 

  1. Creating a remote control that can control multiple devices in a home.

 

  1. Very fast communication between two offices in two different countries.

 

  1. Communication in a hilly area

 

  1. Communication within a city and its vicinity where cost of cabling is too high.

 

  1. Why is a switch called an intelligent hub?

 

 

 

 

 

 

 

COMPUTER NETWORKING

 

 

 

  1. When is a repeater used in a computer network?

 

  1. Diagramatically show how would you connect 6 PCs, 1 server, 1 printer, and 2 scanners in

 

  1. Star topology                        b.       Bus topology

 

  1. Two engineers in the same room have connected their Palm-tops using bluetooth for working on a Group presentation. Out of the following, what kind of Network have they formed?

 

LAN, MAN, PAN, WAN

 

  1. What is a MAC address? What is the difference between a MAC address and an IP address?

 

  1. Give some examples of domain names and URLs. How is a domain name different from a URL?

 

  1. What is domain name resolution?

 

  1. Define Network security? What kind of attacks can be made on data and computer networks?

 

  1. List some methods which are used for network security.

 

  1. Differentiate (with examples wherever possible) between :

 

  1. LAN and MAN                         b.       MAN and WAN

 

c.    Hub and Switch                     d.       Guided and Unguided media

 

  1. Write one advantage of star topology over bus topology and one advantage of bus topology over star topology.
  2. Ishika Industries has set up its new production unit and sales office at Ranchi. The company compound has 4 buildings as shown in the diagram below:

 

Administrative Office     Factory A      Factory B

Sales Office

 

 

Distances between these buildings are as follows:

 

 

Administrative Office to Factory A

 

150 m

 

Factory A to Factory B

 

50 m

 

Factory B to Sales Office

 

100m

 

Sales Office to Administrative office

 

200m

Administrative Office to Factory B 125 m

 

Number of Computers in each of the buildings is follows:

 

 

Administrative Office

 

15

 

Factory A

 

25

 

Factory B

 

18

 

Sales Office

 

15

 

  1. Suggest a cable layout of connections between the buildings so that each building is directly connected to Administrative Office.

 

  1. Suggest the most suitable place (i.e. building) to house the server of this production unit with a suitable reason.

 

  1. Suggest the placement of the following devices with justification:

 

(i)      Repeater

 

(ii)     Hub/Switch

 

  1. The Administrative office of this unit is to be linked with the head office situated in Patiala (Punjab). What will be the most economical way to do this? Justify your answer.

 

 

 

LAB EXERCISES

 

  1. Find the IP addresses of at least five computers in your school.

 

  1. Find the MAC addresses of at least 2 computers in your lab. Then verify their manufacturer’s name on the net.

 

  1. Find the layout of LAN in your school’s labs. If you think some modifications can be done in the layout, note these down in your notebook.

 

  1. Find the name of Internet Service Provider of your school.

 

  1. Find the IP address of your school’s web site.

 

TEAM BASED TIME BOUND EXERCISES

(Team size recommended: 3 students each team)

  1. A school building is divided into 4 blocks (A, B, C, and D). Each block is at a distance of 25m from its adjacent blocks. Each block has 1 computer lab with 15 computers each. Each block also has some other rooms (maximum 10) with 1 computer each. The school has only one internet connection. The computer network in the school has to be restructured with the following goals in mind:

 

  • Each lab has to have an independent LAN.

 

  • All the computers in the school should have internet access. (The school does not want to have any other new internet connection.)

 

  • For internet access a computer should be dependent only on one point and not on multiple points. It means that if the internet connection is active, any computer should be able to access it directly irrespective of whether some other computer in the school is ON or OFF.
  • Any two computers in the school should be able to communicate with each other irrespective of whether any other computer in the school is ON or OFF.

 

The job of each team is to design a layout for this new network structure. Each team

has to specify

 

  • The layout of the network structure diagrammatically.

 

 

  • Topology/topologies is/are used in the layout.

 

  • How the design will be able to fulfill all the mentioned requirements.

 

  1. Find the average price and specifications of each of the following network devices in

the market: Switch , Cable (UTP), LAN Card. Each team has to specify:

 

  • Different types of switches available in the market, their prices, and number of ports.

 

  • Names of brands of UTP Cable available in the market, along with their prices.

 

  • Different types of LAN cards available in the market along with their prices.

 

OPEN SOURCE CONCEPTS

 

 

Learning objectives

 

After learning this chapter the student will be able to:

 

  • Understand about OSS/FOSS/FLOSS

 

  • Cite different examples of OSS

 

  • Describe open document format

 

  • Understand character encoding in Indian languages

 

  • Know about open type/true type/static/dynamic fonts

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Introduction

Computers and internet have transformed our lives. Software is required to work on a computer but the software that we buy or download only comes in the compiled ready-

to-run version. It is next to impossible to modify the compiled version of the software. At times we feel the need to change certain features of the software but are unable to do so.

 

In this chapter we will study about software which are developed collaboratively and they can be modified as well. Such software are available in many forms like Free Software, Open Source Software (OSS), Free Open Source Software (FOSS) and Free/Liberal Open Source Software (FLOSS).Well, have you noticed something common in all these terms. That’s right! It is the word free. People often correlate this word with the cost. They think that these software are available for free. Practically, these software can be acquired at very little or no cost. But, here, “free” means freedom to use.

 

These software can be studied, copied, redistributed freely and even modified according to one’s need without seeking any kind of permission. In order to modify such software the developers also provide the source code to the users.

 

There do exist software which are actually “free” in the sense of price. These are known as Freeware. Lots of freeware can be downloaded from the internet for various different purposes such as currency converters, drawing graphs and charts etc. But freeware may not come with the source code. Therefore freeware differ from free software. The focus

 

in this chapter is on free software rather than freeware.

The first formal definition of “free software” was given in 1983 by Richard Stallman, a long time member of the hacker community at the MIT Artificial Intelligence Laboratory. He insisted that a free software should give the following four freedoms to users:

 

  • Freedom 0: The freedom to run the program for any purpose.

 

  • Freedom 1: The freedom to study how the program works, and change it to make it do what you wish.

 

  • Freedom 2: The freedom to redistribute copies so as to help your neighbour.

 

  • Freedom 3: The freedom to improve the program, and release your improvements (and modified versions in general) to the public, so that the whole community benefits.

 

Examples of free software include the Linux Kernel, MySQL Relational Database, Apache

web server, OpenOffice.org office suite and TeX and LaTeX typesetting systems.

 

 

 

 

 

 

 

 

 

 

 

 

Later on, the term “free software” was recoined as “open source software (OSS)” and soon after as “free open source software (FOSS)”. In order to avoid the ambiguity in the word “free”, in 2001, FOSS was termed as FLOSS, short form of “free/liberal open source software”.

 

 

 

NRCFOSS :

 

National Resource Centre for Free and Open Source Software (NRCFOSS) is an initiative of the Department of Information Technology, Ministry of Communications & Information Technology, Government of India. NRCFOSS contributes to the growth of FOSS in India through Research & Development, Human Resource Development, Networking & Entrepreneurship development, as well as serves as the reference point for all FOSS

related activities in the country.

 

Examples of FLOSS/FOSS :

 

Operating systems and Desktop environments

 

  • Linux – Operating system kernel

 

  • Ubuntu – Linux distribution  with full complement of software for everyday use.

 

  • Google Chrome OS – Lightweight operating system based around the web browser

 

  • Android smart – phone operating system – by Google / Open Handset Alliance

 

  • Symbian smart – phone operating system – by Nokia

 

Graphics and multimedia

 

  • GIMP – Bitmap graphics editor, similar to Adobe Photoshop

 

  • Blender – Advanced 3D modelling and rendering application.

 

  • Songbird – similar to iTunes with built-in browser.

 

 

  • Audacity – digital audio editor

 

  • Ardour – digital audio workstation

 

  • F-Spot – Photo manager

 

 

 

 

 

 

 

 

Office software

 

  • OpenOffice.org  –  office  productivity  software.  Comparable  to  Microsoft Office. It uses an open file format and can read and write Microsoft Office files

 

  • NeoOffice – Mac OS X version of OpenOffice

 

  • PDFCreator – creates PDFs from any Windows program.

 

Internet related software

 

  • Apache webserver – web server

 

•         Mozilla Foundation

 

  • Mozilla Firefox – web browser

 

  • Mozilla Thunderbird – mail client

 

  • Google Chrome – Google’s web browser

 

Other

 

  • Celestia – 3D space simulation software.

 

  • Flight Gear – flight simulator

 

  • Second life – virtual world viewer

 

  • Wine – a compatibility layer for computers running Linux that enables them to run many applications that were originally written for MS Windows

 

Programming related

 

  • Eclipse – software framework and Java IDE

 

  • PHP – server-side programming language

 

  • PERL – Dynamic programming language

 

  • Python – versatile, clean and powerful programming language used for cross- platform desktop applications, server-side scripting for websites, and scripting within java and .net environments

 

  • MySQL – Database management system

 

  • Java – Programming language

 

 

More comprehensive list of open-source software can be found at :

 

http://en.wikipedia.org/wiki/List_of_open_source_software_packages

 

 

GNU/Linux – The GNU Project was launched in 1983 by Richard Stallman of Free Software Foundation (FSF) to develop a complete Unix-like operating system which is free software: the GNU operating system. Unix-like operating systems are built from a collection of libraries, applications and developer tools, plus a kernel to allocate resources and to talk to the hardware. GNU is often used with the Linux kernel. The combination of GNU and Linux is the GNU/Linux operating

system, now used by millions.

 

Firefox – Firefox is a free and open source web browser produced by Mozilla Foundation. Firefox runs on various versions of GNU/Linux, Mac OS X, Microsoft Windows and many other Unix-like operating systems.

 

 

Open Office – Open Office is the leading open source office suite for word processing, spreadsheets, presentations, databases etc. It is available in many languages. It stores files in open document format (ODF) for data interchange that is its

default file format.

NetBeans – NetBeans began in 1996 as verify, a Java Integrated Development Environment (IDE) student project, under the guidance of the Faculty of Mathematics and Physics at Charles University in

Prague. In 1999 it was bought by Sun Microsystem which open-sourced the NetBeans IDE in June of the following year. The NetBeans community has since continued to grow, thanks to individuals and companies using and contributing to the project. NetBeans refers to both a platform framework for Java desktop applications, and an IDE for

developing applications with Java, JavaScript, PHP, Python, Ruby, C, C++, and others.

 

BOSS( Bharat Operating Systems Solutions) – BOSS is a free Indian Operating System based on GNU/LINUX developed by C-DAC(Center for Development of Advance Computing). BOSS makes it easier for a Microsoft  Windows  user  to  shift  to  GNU/LINUX

platform which is there with variant features. Currently BOSS GNU/Linux Desktop is available in many Indian Languages which also enables the non-English literate users in the country to be exposed to Information and communication technology and to use the

computer more effectively.

 

 

Open Source Software Security

 

A commonly voiced concern about open source software:

 

“If anyone can contribute to open source software, doesn’t it become a free-for-all full of loopholes?”

 

The Answer is while anyone can propose a contribution to an open source project, any actual change must go through a small core group of maintainers first. Getting a change incorporated into an open source project is thus rather like getting an article published in

 

a scientific journal.

Open source software is more heavily tested than their commercial counterparts as it can be downloaded by anybody around the world and any one of them can discover a bug or security flaw and submit those reports back to the project.

Also since it’s an Open Source, if any bug or flaw is found, project’s core maintainers, while potentially embarrassed, have no further reason to cover up the flaw like their proprietary counterpart. Also the loop-hole or bug is available to every one and the customer can take the preventive measure accordingly and fix comes faster.

 

 

Common open standards

 

Open Document Format

 

The Open Document format (ODF) is a format for office documents, such as spreadsheets, databases, presentations and word-processing documents. Open Document is a free and open format. For governments, businesses, archivists and others, it’s critical to store documents in a way that can be read for years to come. Proprietary digital file formats are typically changing with every new version of the software, so there should be some format which supports files created in any application. The data should be the center of importance not the application. Office suite applications, as always, need a file format that is designed to organize the data when it moves away from the application. People with different machines in different places should be able to open and edit the data in a file. ODF offers an open alternative to the formats used by all of the existing Office application versions for text, spreadsheet, presentation, and other kinds of documents. Open Document’s main file extensions are .odt (for text documents), .ods (for spreadsheets), and .odp (for presentations). These will be more commonly recognized

when more people and organizations adopt Open Document-ready software.

 

Ogg Vobris

 

Ogg Vorbis is a new audio compression format developed by Xiph.org. It is an open, patent-free, professional audio encoding and streaming technology with all the benefits of Open source. It is comparable to other formats such as MP3, VQF, AAC etc. used to store

and play digital music.

 

Character Encoding

 

A character encoding system consists of a code that associates each character from a given system with something else, such as a sequence of natural numbers, binary numbers or electrical pulses, in order to facilitate the transmission of data (generally

numbers and/or text) through telecommunication networks or for storage of text in

computers. ASCII, EBCDIC, and UNICODE are the most widely used character encoding systems for computers.

 

 

 

Indian Language Computing

 

Let us recall from Annexure I of Class XI that in order to communicate with the computers some kind of a binary code is required. In this regard, a detailed study was made on BCD code which is a 4 bit code. However, BCD code is not sufficient enough to accommodate even all the characters of English alphabet and digits. To accommodate all these, a higher bit code is required. Among such codes, the most popular is the ASCII code (American Standard Code for Information Interchange). It is a 7 bit code that can store 27  = 128 characters. In the earlier days most computers were using an 8 bit system. This extra bit gave computer developers lot of empty spaces which was used for different purposes. In order to work with Indian languages, these unspecified spaces were used for Indic characters. The efforts were very creative and gave good results despite the fact that there was no or very little support from the operating systems. Since no general rules and methodologies were adopted in developing Indic characters, different developers developed these characters in their own ways. This created compatibility issues across different programs and across different operating systems. For example browsers like Internet Explorer did not support all Indic characters and displayed distorted texts.

 

On one hand, more and more work had been undertaken to facilitate the use of Indian languages on computers but on the other hand it was becoming difficult to maintain consistency across different programs developed for the same set of Indic characters. In such a scenario, it was important to have a common standard for coding Indian scripts. In 1991, the Bureau of Indian Standards (BIS) adopted the Indian Script Code for Information Interchange (ISCII), the ISCII standard that was evolved by a standardization committee, under Department of Electronics during 1986-88.

ISCII is an 8 bit encoding system as compared with the 7 bit ASCII. The lower 128 code points are plain ASCII while the upper 128 code points are ISCII specific containing the basic alphabets required for the 10 Indian scripts (Assamese, Bengali, Devanagari, Gujarat, Gurmukhi, Kannada, Malayalam, Oriya, Tamil and Telugu) which have originated from the Brahmi script.

 

Know More!

 

The Indic scripts are a family of abugida (alphabetic-syllabary) writing systems. They are used throughout South Asia, Southeast Asia, and parts of Central and East Asia, and are descended from the Brahmi script of the ancient Indian subcontinent. They are used by languages of several linguistic families: Indo- European, Dravidian, Tibeto-Burman, Mongolic, Austro-Asiatic, Austronesian, Tai, and possibly Korean (hangul). They were also the source of the dictionary order of

Japanese kana.

 

 

 

 

 

 

 

 

UNICODE

 

For a long time ASCII has been the standard code used worldwide. ISCII was the Indian contribution to work with Indian languages. Similarly, to work with other languages of the world, people were making efforts to use ASCII along with the extra 8th bit. Efforts were continued to conceive a single standard code which could cater to all world’s languages and it was UNICODE.

 

Unicode was developed with the aim to conceive a single standard code which could manage to represent all languages of the world.

Unicode characters are represented in one of the three encoding forms: a 32-bit form (UTF-32), a 16-bit form (UTF-16), and an 8 bit form (UTF-8). The 8-bit, byte oriented form, UTF-8, has been designed for ease of use with existing ASCII-based systems.

 

Advantages of Unicode

 

  • With the usage of Unicode, single versions of software were developed instead of language-specific versions that reduced the complexity.

 

  • UNICODE is supported by most OS and application vendors. This ensures platform, vendor and application independence.

 

  • Incorporating Unicode into applications and websites offers significant cost savings than proprietary solutions.
  • It allows data to be transported through several different systems without distortion.
    • Since every number and character combination is unique, the representation

results in a true standard.

 

 

Different Types of Fonts

 

Post Script

 

This font format was developed by Adobe in 1980’s. This font consists of two parts which are both necessary for the font to be properly printed and displayed on screen. With most operating systems, these fonts can be installed simply by being placed in the system’s folder. However, for Micro Soft operating systems predating windows 2000, they need to

be installed using ATM (Adobe Type Manager) utility.

 

True Type

This format was jointly developed by Apple and Microsoft in the late 80s. These fonts contain both the screen and printer font data in a single component, making the fonts easier to install. And that is why these are a good choice for those who find the installation of fonts difficult.

 

 

 

Open Type

 

This is the latest font format which is a joint effort by Apple and Microsoft. Like True Type fonts, this contains both the screen and printer font data in a single component. However, open type fonts support multiple platforms and expanded character sets. Additionally, open type format allows the storage of upto 65,000 characters. This additional space provides freedom to include add-ons such as small caps, old style figures, alternate characters and other extras that previously needed to be distributed as separate fonts.

However, not all open type fonts contain additional characters. Many fonts have been converted from either PostScript or TrueType formats without expanded character sets to take advantage of the cross-platform functionality benefits of Open Type. OpenType fonts that do contain expanded character sets are referred to informally as OpenType Pro fonts. Support for OpenType Pro fonts is increasing, but the format is yet to be fully supported by all applications.

 

Static and Dynamic fonts

 

Static fonts – In these types of fonts the characters are designed and digitized and then stored in font files. Every time printing takes place, same character will appear with same shape e.g. Times New Roman, Arial etc.

 

 

Dynamic fonts –

Dynamic font is a web browser technology used when visiting any

 

website that uses fonts which are not installed on client’s machine. The web browser would not be able to display the page properly, but will select one of fonts available on client machine. In this the characters are redefined at each occurrence (everytime they are displayed or printed). All hand written fonts such as handwritten alphabets, calligraphic letters, graffiti etc are dynamic fonts because of individual variations.

 

This technology is helpful in displaying multilingual websites.

 

 

Entering Indian language text

Many tools have been developed to facilitate the typing of Indian language text. These tools broadly support two types of text entries:

 

  • Phonetic Text Entry

 

  • Keymap based Text Entry

 

Phonetic Text Entry (Transliteration)

 

In this type of text entry, traditional keyboards with English keys are used. But while typing, the Indian alphabets are written phonetically (i.e., the way they sound as per the pronunciation) in English Script and then converted to corresponding language word. For

e.g. we will type “mera desh mahaan” from English keyboard and the relevent phonetic

key entry software will transliterate it in the language selected eg. Hindi.(“esjk ns’k egku”)

 

 

 

Keymap based Text Entry

In this method the keyboard keys are mapped to specific characters using a keymap. The whole arrangement of mapping the keyboard keys to specific language characters is known as keymap. A keymap is internally stored as a table. Multiple keymaps are used to store complete keymapping e.g. a table to represent the keymappings without any additional key press(such as shift) ; a table representing keymappings along with Shift key press; along with Ctrl key press and so on.

 

Indian language keymaps are known as INSCRIPT keymaps or Indian Script Keymaps.

 

 

ENGLISH KEYBOARD WITH INSCRIPT OVERLAY

 

The ASCII characters of a standard QWERTY keyboard are on the left half of a key. The INSCRIPT (Indian Script) overlay characters are shown on the right half of a key. CAPS LOCK is used to select

the INSCRIPT overlay.

NUKTA CHARACTERS IN INSCRIPT OVERLAY

 

When Nukta “-” is typed after character, the character shown to its left on the

key, is obtained.

 

 

Future Trends

 

At present very few open source endeavors which involve few people are there and are largely unstructured and undisciplined. But as this concept matures in future more OSS projects will come up and will adopt more structured methodologies to code, control and coordinate. In future this concept will be adopted at a big level by private and government sector. This will force companies to embrace open source and will force the open source community to innovate in line with more

complex need of government and business.

 

Summary

 

  • Free and open source software, also OSS, FOSS, or FLOSS (free/libre open source software) is software that is liberally licensed to grant the user right to use, study, change, and improve its design through the availability of its source code.

 

  • NRCFOSS – National Resource Centre for Free and Open Source Software.

 

  • ODF (Open Document Format) offers an open alternative to the formats used by all of the existing software.

 

  • Ogg Vorbis is open audio compression format.

 

  • A character encoding system consists of a code that associates each character from a given system with something else, such as a sequence of natural numbers, binary numbers or electrical pulses, in order to facilitate the transmission of data (generally numbers and/or text) through telecommunication networks or for storage of text in computers

 

  • ISCII – Indian Script Code for Information Interchange is common standard for coding Indian Scripts.

 

  • UNICODE – Universal Code is a single standard code which can cater to all the world’s languages.

 

  • Post Script font consists of two parts which are both necessary for the font to be properly printed and displayed on screen.

 

  • True type fonts contain both the screen and printer font data in a single component.

 

  • Open type fonts support multiple platforms and expanded character sets.

 

  • On the basis of their configuration, fonts are categorized as static fonts and dynamic fonts.

For entering text in Indian script keymap based or phonetic text based entry

can be done.

 

EXERCISES

 

MULTIPLE CHOICE QUESTIONS

 

1)       Open Document’s main file extensions are

 

(a)     .odt                                     (b)     .ods

 

(c)   .odp                                     (d)     All of these

 

2)       Technology no longer protected by copyright, available to everyone, is considered to be

 

(a)     Proprietary                           (b)     Open

 

(c)   Experimental                        (d)     in the public domain

 

3)       Which of the following codes uses 7 bits to represent a character

 

(a)     ISCII                                     (b)     ASCII

 

(c)   UNICODE                              (d)     All of the above

 

4)       How many bits are used by UTF-8 to represent a character

 

(a)     7                                          (b)     8

 

(c)   16                                        (d)     32

 

5)       ASCII stands for

 

(a)     American System Code for Information Interchange

 

(b)     American Standard Code for Information Interchange

 

(c)     American Standard Code for Interchange Information

 

(d)     American System Code for Interchange Information

 

6)       ISCII stands for

 

(a)     Indian System Code for Information Interchange

 

(b)     Indian Standard Code for Information Interchange

 

(c)     Indian Script Code for Interchange Information

 

(d)     International Standard Code for Interchange Information

 

PEN SOURCE CONCEPTS

 

 

 

7)       ISCII is

 

(a)     An 8 bit character code          (b)     A 16 bit character code

 

(c)   A 7 bit character code            (d)     Same as ASCII

 

8)       Which of the following is open source operating system

 

(a)     DOS                                      (b)     Windows 2010

 

(c)   BOSS                                    (d)     Mac

 

9)        Following operations are possible with OSS

 

(a)     Free download

 

(b)     Source code is available

 

(c)     You can redistribute the modified version

 

(d)     All of the above

 

10)     Platform independence is provided by

 

(a)     ASCII                                    (b)     ISCII

 

(c)   UNICODE                               (d)     All of the above

 

 

ANSWER THE FOLLOWING QUESTIONS

 

1)       Define Open source software. Give at least two examples of OSS. Justify that free software is not open source software.

 

2)       Give examples of two OSS in each of the following categories :

 

(a)   OS                                       (b)     Graphics and animation

 

(c)   Office software                     (d)     Internet related software

 

(e)   Programming related software.

 

3)       What is a character encoding system?

 

4)       Differentiate between true type font and open type font.

 

5)       What do you understand by ODF?

6)       What is Ogg Vorbis?

 

7)       Expand the following terms:

 

OSS, FLOSS, ISCII, ASCII, BOSS, NRCFOSS

 

8)       What is UNICODE?

 

9)       Write short notes on GNU, BOSS, ISCII

 

10)    What is the difference between static and dynamic fonts?

 

 

LAB EXERCISES

 

1)       Find out which software in your school lab are open source.

 

2)       Note down the category of software (system software or application software) to which they belong to.

 

3)       If any of them is application software then specify its area of application.

 

4)       Search on internet about the features of mySQL and Netbeans.

 

 

TIME BOUND TEAM BASED EXERCISE

(Team size recommended: 3 students each team)

 

1)       Download open office on your computer. Write down its components, their areas of applications, their file extensions.

2)       Procure BOSS and install it (with the permission of your teacher) on your computer and write down the features which are similar to windows and also which are not similar to windows.

 

Language Fundamentals

 

 

  1. Java is case sensitive.

 

  1. Source file may contain ONLY ONE public class or interface, and any numbers of default classes or interfaces.

 

  1. If there is a public class or interface, the name of the source file must be the same as the name of the class or interface.

 

  1. The file name may begin with numbers if there is no public class on it.

 

  1. If no package is explicit declared, java places your classes into a default package (Object).

 

  1. Identifiers are composed of characters, where each character can be any letter (including                                                                                     Ò ù Á ÆÅ), a connecting punctuation (underscore _) or any currency symbol (such as $ ¢ £ ¥) and CANNOT start with a digit.

 

  1. Keywords are reserved identifiers that are predefined in the language, and CANNOT be used to denote other entities. NOTE: None of the keywords have a capital letter.

 

 The following table denotes the currently defined keywords:                                  

abstract                        default  if              package                                synchronized                      boolean do                                        implements           private                                   this                                         break double                                        import                    protected                              throw                                     byte

else                                 instanceof            public                                    throws                                   case ex tends                             int                           return                                    transient                              catch final                                        interface               short                                      try                                           char finally                                        long                       static                                     void                                        class

float                               native                    super                                     volatile                                 continue for                                        new                        switch                                    while

strictfp   I found this in reference , but I didn’t find it in any certification  book.

 

The following table shows three reserved predefined literals:

  n u ll                                 true                             f alse                                                                         

 

 The following table shows reserved keywords NOT currently in use:                          

 

const goto  
byvalue cast future generic inner operator outer rest var I found this in reference , but

I didn’t find it in any certification book.

 

  1. Integer literal by default is int, you can specify it as long by appending “L” or “l” as suffix, NOTE: THERE IS NO WAY to specify a short or byte literal.

 

  1. Floating point literal by default is double, you can specify to be a float by appending “F” or “f” as suffix.

 

  1. Octal numbers are specified with “0” as prefix, Hexadecimal numbers are specified with “0x” or “0X” as prefix.

 

 

 

11.  Most important Unicode values:                                                                            

 

Escape Sequence Unicode Value Character
‘ ’

\u0020

Space
‘0’

\u0030

0
‘9’

\u0039

9
‘A’

\u0041

A
‘Z’

\u005a

Z
‘a’

\u0061

a
‘z’

\u007a

z

 

 

12.   Escape sequences are used to define special character values and can be represented also in Unicode value,

 the following table shows them:                                                       

Escape S equence       Unicode Value                Character

\b

\t

\u0008

\u0009

Backspace

Horizontal tabulation

\n

\u000a

Linefeed
\f

\r

\u000c

\u000d

Form feed

Carriage return

\’

\u0027

Apostrophe-quote
\”

\\

\u0022

\u005c

Quotation mark

Backslash

\xxx   A character in octal representation; xxx must
 

\uxxxx

  range between 000 and 337

A unicode character, where xxxx is a

    hexadecimal format number.

 

  1. The single apostrophe ‘ need not to escaped in Strings, but it would be if specified as a character literal ‘\’’. Example:

 

String tx = “Delta values are labeled \”\u0394\” on the chart.”;

 

  1. Regardless of the type of comment, it can’t be nested.

 

  1.  Default values for member variables table:                                                              

Data type                                    Default value                                                        boolean                                       false

char                                              ‘\u0000’

Integer(byte, short, int, long)        0

Floating-point(float, double)         +0.0F or +0.0D Object reference                           null

 

  1. Static variables in a class are initialized to default values when class is loaded if they are not explicitly initialized.

 

  1. Instance variables are initialized to default values when the class is instantiated if they are not explicitly initialized.

 

  1. Local variables (Automatic) are NOT initialized when they are instantiated at method invocation. The compiler javac reports use of un-initialized local variables.

 

  1. There can be ONLY one package declaration in a Java file, and if it appears, it must be the first non-comment statement.

 

  1. The JVM expects to find a method named main with the signature as follows:

 

public static void main(String[] args)

 

 

The array is typically named args, but it could be named anything.

 

NOTE:  You can have methods named main that have other signatures. The compiler will compile these without comment, but the JVM will not run an application that does not have the required signature.

Oper ator and assignments

 

 

1)      Operator precedence and associativity:                                                                    Postfix operators                 [] . (parameters) expression++ expression–

Prefix unary operators         ++ expression –expression +expression –expression ~ !

Object creation and cast      new (type) Multiplication                      * / % Addition                              + –

Shift                                    << >> >>>

Relational operators            < <= > >= instanceof

Equality operators               == != Bitwise/Logical AND             & Bitwise/Logical XOR                ^ Bitwise/Logical OR               | Logical AND                                    && Logical OR                           || Conditional operator           ?:

Assignment                         = += -= *= /= % = <<= >>= >>>= &= ^ = |=

 

2)       Casting between primitive values and references CANNOT be applied.

 

3)       ~ (Bit wise inversion) convert all 1’s to 0’s and vise versa.

 

4)       The modulo operator % give the value of the remainder of the division of the left operand (dividend) by the right operand (divisor).

 

5)       A useful rule to calculate the modulo: Drop any negative sign from the operands, calculate the modulo, then the result sign is relative to the left operand (dividend).

Example:

int x = -5 % 2; // x = -1 int y = -5 % -2; // y = -1 int z = 5 % -2; // z = 1

 

 

 

6)       || and && work with boolean not with integers like & and |, and the result from | & is int.

 

NOTE : & and | are used with both boolean and integers.

 

7)       Unlike in C, integers in Java can NEVER be interpreted as boolean values, so expressions used for flow control

MUST evaluate to boolean.

 

8)       The conditional assignment operator, the ONLY Java operator that takes three operands:?

<condition>? <expression1>:<expression2>

Example:

String x = (salary < 1500)? “Poor”: ”Not poor”;

String y = (salary > 1500)? “Poor”: (salary1 < 10)? “poor1″:”poor2”;

 

9)       Multiple assignment:

 

k = j = 10;  //   (k = (j = 10))

 

10)   Boolean values CANNOT be casted to other data values, and vice versa, the same applies to the reference literal null, which is NOT of any type and therefore CANNOT be casted to any type.

 

11)   Conversion is done when:

(a)    Assigning a value to a primitive variable.

(b)    Evaluating arithmetic expressions.

(c)    Matching the signature of methods.

 

Example:The Math class has max and min methods in several versions, one for each of int, long, float, double. Therefore, in the following  code that calls Math.max with one int and one long in line 3, the compiler converts the int primitive to a long value. The alternative in line 4 forces the compiler to cast the value n to an int and calls the version of max that uses two int primitives.

int m = 93; //(1)  
long n = 91;

long x = Math.max(m, n);

 

//(3)

//(2)
int y = Math.max(m, (int) n); //(4)  

12)   Widening primitive conversion is as follows (it doesn’t lose information about the magnitude of a value), and any other conversion is called narrowing primitive conversion and may cause lose of information. At runtime, casts that lose information do not cause a runtime excpetion, and it is up to the programmer to think through all the implications of the cast.

Byte      short

 

 

Char

int      long    float    double

 

 

13)   Integers of int (32-bit) or smaller can be converted to floating-point representation, but because a float also uses only 32 bits and must include exponent information, there can be a loss of precision.

 

14)   All six numbers types in Java are signed meaning they can be negative or positive.

 

15)   The ONLY integer primitive that is not treated as a signed number is char, which represents a Unicode character.

 

16)   All conversion of primitive’s data types take place at compile time.

 

17)   Arithmetic operations:

a)      For unary operators if byte – short – char Æ converted to int.

b)      For Binary operands:

i)        If one of operands is double the other operand is converted to a double.

ii)       If one of the operand is float, the other operand is converted to float.

iii)     If one of the operand is long, the other operand is converted to long.

c)      Else both the operands are converted to int.

 

18)   Ranges of primitive data types:                                                                              

 

byte 8

1

-2 7 2 7   – 1
short 16

2

-2 15 2 15   – 1
char 16

2

\u0000 \uFFFF
int 32

4

-2 31 2 31   – 1
long 64

8

-2 63 2 63   – 1

 

Type       Bits             Bytes           Minimum range              Maximum range 

 

 

     
 

float

 

32

 

4

 

1.40129846432481707e-45

 

3.40282346638528860e+38

double 64

8

4.94065645841246544e-324 1.79769313486231570e+308

 

19)   Depending on the storing type of the arithmetic operation the precision is done.

Example:

int  x = 7/3;                                   // x = 2 byte b = 64; b *= 4;  // b = 0

 

20)   The compiler pays attention to the known range of primitives.

Example:

int n2 = 4096L;     // (1) would require a specific (int) cast short s1 = 32000;  // (2) OK

short s2 = 33000;  // (3) out of range for short primitive

In spite the fact that 4096 would fit in an int primitive, the compiler will object on the first line because the literal is in long format. You could force the compiler to accept line 3 with a specific (short) cast, but the result would be a negative number due to the high bit being set.

21)   Important examples for arithmetic expression evaluation:                                      

Arithmetic Expression         Evaluation            Result when printed

4/0 Arithmetic Exception  
4.0/0.0

(4.0/0.0)

POSITIVE_INFINITY
-4.0/0.0

0.0/0.0

((-4.0)/0.0)

(0.0/0.0)

NEGATIVE_INFINITY

NaN

 

22)   NaN can result from mathematical functions that are undefined, such as taking the square root of a negative number. In float to double conversion, if the float hasone of the special values, NaN, POSITIVE_INFINITY, or NEGATIVE_INFINITY, the double ends up with the corresponding double special values.

 

23)   Float.NaN, Double.NaN are considered non-ordinal for comparisons, this means all that are false:

x < Float.NaN

x == Float.NaN

But you can test by Float.isNaN(float f), Double.isNan(double d).

 

24)   While casting special floating-point values, such as NaN, POSITIVE_INFINITY to integer values, they will be casted without any complaint from the compiler or an exception.

 

25)   <variable> <op>=<expression> is equivalent to

<variable> = (<variable type>) (<variable><operator>(<expression>)).

 

26) short h = 40; // OK, within range
  h         = h + 2; // Error can’t assign int to short

Solution for the above situation, choose one of the following:

h = (short) (h+2); h += 2;

NOTE :

h = h + (short)2;       // Requires additional casting

Will not work because binary numeric promotion leads to an int values as result of evaluating the expression on the right-hand side.

 

27)   System.out.println(“We put two and two together and get ” + 2 + 2);

Pr ints: We put two and two together and get 22

NOT: We put two and two together and get 4

Declaration: (((“We put two and two together and get ”) + 2) + 2).

 

28)   If your code conducts operations that overflow the bounds of 32-bit or 64-bit integer arithmetic, that’s your problem, i.e. Adding 1 to the maximum int value 2147483647 results in the minimum value –2147483648, i.e. the values “wrap-around” for integers, and no over or underflow is indicated.

 

29)   The dot operator has left associativity, in the following example the first call of the make() returns an object reference that indicates the object to execute the next call, and so on …

SomeObjRef.make().make().make();

 

30)   To get the 2’s complement:

a)      Get the 1’s complement by converting 1’s to 0’s and 0’s to 1’s.

b)      Add 1.

 

31)   In the << left shift operator all bytes are moved to the left the number of places you specify, and zero is padded from the right. [6]

 

32)   >> Signed right shift and >>> unsigned right shift work identically for positive numbers, in >>> operator zeros

fill the left most bits, but in >> will propagate the left most one through the rest of bits.

 

33)   When you shift a bit by a numeric value greater than the size in bits, Java does a modulus shift.

 

34)   To shift a negative number get the 2’s complement and then shift it.

 

35)   Object reference equality ( ==, != ):

The equality operator == and the inequality operator != can be applied to object references to test if they denote the same object. The operands must be type compatible, i.e. it must be possible to cast one into the other’s type, otherwise it is a compile time error.

Example:

Pizza pizza_A = new Pizza(“Sweat & Sour”); Pizza pizza_B = new Pizza(“Hot & Spicy”); Pizza pizza_C = pizza_A;

 

String banner = “Come and get it”;

 

boolean test  = banner == pizza_A;      // Compile time error boolean test1 = pizza_A == pizza_B;   // false

boolean test2 = pizza_A == pizza_C;   // true

 

36)   The equals method:

In the Java standard library classes, the method that compares  content is always named equals and takes an Object reference as input. It does not look at the value of the other object until it has been determined that the other object reference is not null and that it refers to the same type, else it will return false.

NOTE :

The equals method in the Object class returns true ONL Y IF

this == obj

so in the absence of an overriding equals method, the == operator and equals method are equivalent.

 

37)   Using instanceof: if the right-hand operand that MUST name a reference type may equally will be an interface; In such case the test determines if the object at the left-hand argument that MUST be a name of a reference variable implements the specified interface.

 

38)   If we compare an object using instanceof and the class we compare with is not in the hierarchy this will cause compiler error, (Must be on the hierarchy above or bottom the class). We can overwrite the problem of compiler error caused by instanceof by declare the class from the Object class.

Example:

Object x = new Button();

 

39)   Object reference conversion takes place at compile time because the compiler has all the information it needs to determine whether the conversion is legal or not.

 

40)   Short circuit evaluation:

In evaluation of boolean expression involving conditional AND && or OR ||, the left operand is evaluated before the right one, and the evaluation is short circuited, i.e.: if the result of the boolean expression can be determined from the left-operand, the right-hand operand is not evaluated.

NOTE :

when bitwise AND & or bitwise OR | are used in a boolean expression, both operands are evaluated, and NO

short circuit evaluation is applied.

 

41)   Parameter passing: All parameters are passed by value.                                           

Data type of the formal parameter                           Value passed                            Primitive data types                                                  Primitive data value

Class type                                                                 Reference value Array type                                                                Reference value

 

42)   A formal parameter can be declared with the keyword final preceding the parameter declaration. A final

 

 

 

parameter is also known as blank final variable, i.e. it is blank (uninitialized) until a value is assigned to it at method invocation.

Example:

public static void bake(final Pizza pizzaToBeBaked) { pizzaToBeBaked.meat = “chicken”;   // Allowed pizzaToBeBaked = null;                                               // Not Allowed

}

Declar ations and Access Contr ol

 

 

1)       Arrays are a special kind of reference type that does not fit in the class hierarchy but can always be cast to an Object reference. Arrays also implement the Cloneable interface and inherit the clone method from the Object class, so an array reference can be cast to a Cloneable interface.

 

2)       Array declaration and constructor:

<elementType1> <arrayName>[] = new <elementType2> [numberofelements];

Note:

<elementType2> must be assignable to <elementType1>, i.e.: class or subclass of <elementType1>, and when the array is constructed, all its elements are initialized to the default value for <elementType2>,

WHATEVER the array is automatic variable or member variable.

 

3)       When constructing multi-dimensional arrays with the new operator, the length of the deeply nested arrays may be omitted, these arrays are left unconstructed.

Example:

double matrix[][] = new double[3][];

 

4)       Length of array object is a variable NOT a method.

 

5)       It is legal to specify the size of an array with a variable rather than a literal.

 

6)       The size of the array is fixed when it is created with the new operator or with special combined declaration and initialization.

 

7)       Anonymous arrays:

new <elementType>[] {<initialization code>}

NOTE: No array size is mentioned in the above syntax. Example of usage:

class AnonArray {

public static void main(String[] args) {

System.out.println(“Minimum  value = ” + findMin(new int[] {3,5,2}));

}

public static int findMin(int[] dataSeq) { int min = dataSeq[0];

for (int index=1; index<dataSeq.length; index++) { if (min >= dataSeq[index])

min = dataSeq[index];

}

}

}

 

8)       There is NO way to `bulk’ initialize an array, if you want to initialize array to certain value during declaration => you MUST iterate with the value you want. NOTE: Initialization by means of a bracketed list can be used only in the statement that declares the variable.

 

9)       It is possible to create arrays of zero length of any type, a common natural occurrence of an array of zero length is the array given as an argument to the main() method when a Java program is run without any program arguments.

 

10)   Primitive arrays have no hierarchy, and you can cast a primitive array reference ONLY to and from an Object reference. Converting and casting array elements follow the same rules as primitive data types. Look to the strange LE GAL syntax for casting an array type as shown in line 3 in the following example.

int sizes[] = {4, 6, 8, 10};               //(1) Object obj = sizes;                          //(2) int x = ((int[])obj)[2];                    //(3)

 

11)   Casting of arrays of reference types follows the same rules as casting single references.

NOTE that an array reference can be converted independantly of whether or not the array has been populated with references to real objects.

 

Example: Suppose you have a class named Extend that extends a class named Base. You could then use the following code to manipulate a reference to an array of Extend references:

Extend[] exArray = new Extend[20];

Object[] obj = exArray; Base[]bArray = exArray;

Extend[] temp = (Extend[])bArray;

 

12)   An import declaration does not recursively import sub-packages.

 

13)   The order of modifiers in class declaration:

a)      public.                   (optional)

b)   final or abstract. (CANNOT appear together)
c) class. (mandatory)
d) classname. (mandatory)
e) extends. (optional)
f)     superclassname. (mandatory if extends specified)
g) implements. (optional)
h)

i)

interfacelist.

{}.

(mandatory if implements specified)

(mandatory)

14)   If the access modifier is omitted => (package or default accessibility), in which case they are only accessible in the package but not in any sub-packages.

 

15)   The ONLY access modifier allowed to the top level class is public or friendly.

 

16)   abstract modifier implies that the class will be extended, but abstract class CANNOT be instantiated.

 

17)   The compiler insists that a class that has an abstract method must be declared abstract, and this forces its subclasses to provide implementation for this method, and if a subclass does not provide an implementation of its inherited methods must be declared abstract.

 

18)   It is NOT a MUST for an abstract class to have an abstract method.

 

19)   Interfaces as classes CANNOT be declared protected, private, native, static, synchronized.

 

20)   An interface is different from a class in also it can extend MORE than one interface, this follows from the fact that a class can implement more than one interface.

Example:

public interface RunObs extends Runnable, Observer

Any class implementing this interface will have to provide methods required by both Runnable and Observer.

 

21)   The order of modifiers in method declaration:

a) public or private or protected. (optional for package declaration)
b) abstract or final or native or static or synchronized. (optional)
c)

d)

returntype.

methodname.

(mandatory)

(mandatory)

e) throws clause. (optional)
f) {}. (mandatory)

22)   abstract methods or methods defined in an interface must end with ‘;’. (i.e. abstract method is non-functional methods that haven’t body), and abstract methods declared ONLY on interface or abstract classes.

 

23)   The class must be declared abstract if:

a)      The class has one or more abstract methods.

b)      The class inherits one or more abstract methods (from an abstract parent) for which it doesn’t provide implementation for one or more of the abstract methods of the parent class.

c)      The class declares that it implements an interface but doesn’t provide implementation for EVE RY method of that interface.

24)   When an abstract class implements  interface there is no need to this class to implement all members of that interface.

 

25)   Interfaces just specify the method prototypes and not the implementation; they are by their nature, implicitly abstract, i.e. they CANNOT be instantiated. Thus specifying an interface with the keyword abstract is not appropriate, and should be omitted, but it won’t give compile error if specified.

 

26)   final classes CANNOT be extended. Only a class whose definition is complete (i.e. has implementation of all the methods) can be specified to be final.

 

27)

a) public or private or protected. (optional)
b) final or static or transient or volatile. (optional)
c) variable type. (mandatory)
d) variable name. (mandatory

 

The order of modifiers in variable declaration: 

 

 

)

 

28)   Within a cla ss definition, reference variables of this class’s type can be used to access all NOT INHERITE D

members regardless of their accessibility modifiers.

Example:

Class Light {

// Instance variables private int noOfWatts; private boolean indicator; private String location;

 

public void switchOn() {indicator = true;} public void switchOff() {indicator = false;} public boolean is On() {return indicator;}

 

public static Light duplicate (Light oldLight) { Light newLight = new Light(); newLight.noOfWatts = oldLight.noOfWatts; newLight.indicator = oldLight.indicator;

newLight.location = new String(oldLight.location);

}

}

 

29)   ONLY variables, methods and inner classes may be declared protected.

 

30)   static members can be called from the member objects.

Example: this.xyz NOTE :

The use of this MUST be from a non-static method, or “this cannot be referenced from a static context” compiler error will be thrown.

 

31)   Trying to use object class member before the constructor of the object class member called will compile fine but will give NullPointerException.

Example:

public class Trial { static Date d ;

public static void main (String args[]) { System.out.println( d.getYear() );

}

}

 

32)   In local object if u try to check null of a local object before the initialize of it is called => will cause compilation

error that variable might not have been initialized, you can overwrite this problem by initializing an object with

null value.

 

33)   Summary of accessibility modifiers for members:                                                

Modifiers                            Memb ers                                                                   public                                 Accessible everywhere.

Protected                            Accessible by any class in the same package as its class, and accessible only by subclasses of its class in other packages.

default(no modifier)            Only accessible by classes, including subclasses, in the same package as its class(package accessibility).

private                                Only accessible in its own class and not anywhere else.

 

Access Modifier Its own class Class in Same Package Subclass in Same  Package Subclass in Different Package Class in

Different  Package

public Yes Yes Yes Yes Yes
protected Yes Yes Yes Yes No
default Yes Yes Yes No No
private Yes No No No No

 

34)   final method CANNOT be abstract and vice versa.

 

35)   final method CANNOT be overridden.

 

36)   final variables must be initialized before being used even it is member variable (i.e. take the default value), no default value applied for local final variables.

 

37)   You may not change a final object reference variable.

Example:

final Date d  = new Date(); Date d1 = new Date();

d = d1;                                     // Illegal

 

38)   You may change data owned by an object that is referred to by a final object reference variable.

Example:

final walrus w1 = new walrus(1000); w1.height = 1800;

 

39)   Static method may not be overridden to be non-static and vice versa, i.e. overriding static methods MUST remain static & non-static MUST also remain non-static.

 

40)   You can specify a block of code to be static.

Example:

static { static int x = 1 }

 

41)   Summary of other modifiers for members:

Modifiers         Variables                                 Methods

static Defines a class variable. Defines a class method.
Final Defines a constant. The method cannot be overridden.
abstract Not relevant. No method body is defined; its class is then
    implicitly abstract.
synchronized Not relevant. Methods can only be executed by one thread at a

time.

native Not relevant. Declares that the method is implemented in
another

transient

 

This variable’s value will not be

language.

Not applicable.

 

 

persistent (do not need to be saved) if its object is serialized.volatile          The variable’s value can change Not applicable.asynchronously; the compiler should not attempt to optimize it, i.e. signal the compiler that the designated variablemay be changed by multiple threads and that it cannot take any shortcuts when retrieving the value in this variable.

 

42)   When you declare a return primitive type from a method you can return less number of bits:

Return type                        Can return                                                                     short                                          byte – short

int                                      byte – short – int

float                                    byte – short – int – long – float

double                                byte – short – int – long – float – double

 

43)   Instance variables may not be accessed from static methods.

 

44)   The scope (visibility) of local variables is restricted to the code block in which they are declared.

Flow Control and Exception handling

 

 

  1. The rule of matching an else clause is that an else clause always refers to the nearest if which is not already associated with another else clause.

 

  1. The compiler always checks for unreachable code, and give “Statement not reachable” error.

Example:

for (int i = 0; i < 10; i++) { continue;

System.out.println(“Hello” + i); // Statement not reachable

}

 

  1. The compiler always checks for that all paths that will initialize local variables before they are used.

 

  1. State Diagram for switch statement:  [I changed the diagram a little]

 

 

  1. In the switch statement:
    1. The case labels are CONSTANT expressions whose values must be UNIQUE. [When one friend tried identical case labels it compiled !!!! but several books says that they must be unique, if you find any declaration please send]
    2. Constants in case statements can be integer literals, or they can be variables defined as static and final.
    3. The type of the integral expression must be char, byte, short or int (All primitives that implicit cast to int).
    4. The type of the case label CANNOT be boolean, long or floating point.
    5. The compiler CHECKS that the constant is in the range of the integer type in the switch statement, i.e. if you are using a byte variable in the switch statement, the compiler will object if it finds case statement constants outside –128 to 127 range that a byte primitive can have.
    6. The associated statement of the case label can be a list of statements which need not be a statement block.
    7. The labels (including the default label) can be specified in any order in the switch body.
    8. If it doesn’t have a break statement during execution when we reach the condition all cases after it is executed.
    9. If the condition matches a case value it will perform all code in the switch following the matching case

statement until a break statement or the end of the switch statement is encountered.

  1. If there is no default statement and no exact match, execution resumes after the switch block of code.
  2. The code block can have another switch statement, i.e. switch statement can be nested.
  3. The code block associated with a case MUST be complete within the case, i.e. you can’t have an ifelse or loop structure that spreads across multiple case statements.

 

  1. Label rules:

Identifiers used for labels on statements do not share the same namespace as the variables, classes, and methods

of the rest of a Java program. The naming rules, as far as legal characters, are the same as for variables except that labels are always terminated with a colon (there can be a space between the name and the colon). You can reuse the same label name multiple points in a method as long as one usage is not nested inside another. Labels cannot be freestanding, i.e. they must be associated with a statement.

 

  1. break statement immediately terminates the loop code block, and can be used with an optional identifier which is the label of an enclosing statement => control is then transferred to the statement following this enclosing

labeled statement.

Example:

class LabeledBreakOut {

public static void main(String args[]) {

int[][] squareMatrix = {{4, 3, 5},{2, 1, 6},{9, 7, 8}}; int sum = 0;

 

outer: // label

for (int i = 0; i < squareMatrix.length; i++ ) {  // (1)

for ( int j = 0; j < squareMatrix[i].length; j++) { // (2) if ( j == i )

break; // (3) Terminate this loop control to (5)

System.out.println( “Element[” + i + “, ” + j + “]:” +  squareMatrix[i][j]); sum += squareMatrix[i][j];

if (sum > 10)

break outer; // (4) Terminate both loops control to (6)

} // (5) Continue with the outer loop

} // end outer loop

// (6) Continue here

 

System.out.println(“sum: ” + sum);

}

}

 

  1. break statement can be used in:
    1. Labeled blocks.
    2. Loops (for, while, do-while).
    3. switch statement.

 

  1. continue statement skips any remaining code in the block and continues with the next loop iteration, and can be used with an optional identifier which is the label of an arbitrary enclosing loop => Control is then transferred to the end of that enclosing labeled loop.

Example:

class LabeledSkip {

public static void main(String args[]) {

int[][] squareMatrix = {{4, 3, 5},{2, 1, 6},{9, 7, 8}}; int sum = 0;

 

outer: // label

for (int i = 0; i < squareMatrix.length; i++ ) {  // (1)

for ( int j = 0; j < squareMatrix[i].length; j++) { // (2) if ( j == i )

continue; // (3) Control to (5)

System.out.println( “Element[” + i + “, ” + j + “]:” +       squareMatrix[i][j]); sum += squareMatrix[i][j];

if (sum > 10)

continue outer; // (4) Control to (6)

} // (5) Continue with the outer loop

} // end outer loop

// (6) Continue here System.out.println(“sum: ” + sum);

}

}

 

  1. continue statement can be used ONLY in loops:

for, while, do-while

 

  1. while statement:

 

 

  1. Any variable used in the expression of while loop must be declared before the expression evaluated.

 

  1. dowhile statement:

 

 

 

 

 

 

 

  1. for statement:

 

 

  1. None of the for-loop sections are required for the code to compile, i.e. everything in a for loop is optional.

 

  1. All the sections of the for loop are independent of each other. The three expressions in the for statement doesn’t need to operate on the same variables. In fact, the iterator expression does not even need to iterate a variable; it could be a separate Java command.

Example:

for (int x1 = 0; x1 < 6; System.out.println(“iterate” + x1)) x1 += 2;

 

Output: iterate2 iterate4 iterate 6

NOTE: Most of who study for the certification solved the above example wrong, and say it just iterate till iterate 4 only, in fact this is wrong, look to (14) for tracing help.In the initialization part in the for loop, it is legal to mix expression with expressions, or variable declaration with variable declaration, BUT it is illegal to mix variable declaration with expressions.

Example:

for (int x1 = 0, x2 = 0; x1 < 15; x1++) {}   // valid

 

int k = 0;

for ( System.out.println(“Initial”),  k = 1; k < 10; k++) {} // valid

 

for ( int j = 0, System.out.println(“Begin”); j < 10; j++) {} // NOT VALID

 

  1. It doesn’t matter whether you pre-increment or post-increment the variable in the iterated expression in the for loop. It is always incremented after the loop executes and before the expression is evaluated.

 

19. return statement:                                                                                                                                                                                 

Form of return statement    In void method      In non-void method

return; Optional Not allowed
return <expression>; Not allowed Mandatory

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  1. Partial Exception inheritance hierarchy:

 

 

  1. trycatch-finally:
    1. Block notation is MANDATORY.
    2. When an exception or error is thrown, the JVM works back through the chain of method calls that led to the error, looking for an appropriate handler to catch the object, if no handler is found, the Thread that created the error or exception dies.
    3. For each try block there can be zero or more catch blocks but only one finally block.
    4. The catch blocks & finally block must appear in conjunction with a try block, and in the above order.
    5. A try block must be followed by either at least one catch block or one finally block.
    6. Each catch block defines an exception handler, and the header takes exactly one argument, which is the exception, its block willing to handle.
    7. The exception must be of the Throwable class or one of its subclasses.
    8. When an exception is thrown, java will try to find a catch clause for the exception type. If it doesn’t found one, it will search for a handler for a super type for the exception.
    9. The compiler complains if a catch block for a superclass exception shadows the catch block for a subclass exception, as the catch block of the subclass exception will never be executed, so the order of the catch clauses must reflect the exception hierarchy, with the most specific exception first.
    10. The finally block encloses code that is always executed at some time after the try block, regardless of whether an exception was thrown, it executed after the try block in case of no catch block or after the catch

block if found, EXCEPT in the case of exiting the program with System.exit(0); .

  1. k.       Even if there is a return statement on the try block, the finally block will be executed after the return

statement.

  1. If a method doesn’t handle an exception the finally block is executed before the exception is propagated.

 

  1. Subclasses of Error are used to signal errors that are usually fatal and are not caught by catch statements in the program.

 

  1. throws clause:

The exception type specified in the throws clause in the method header can be a superclass type of the actual exceptions thrown.

 

  1. A subclass can override a method defined in its superclass by providing a new implementation, but the method definition in the subclass can only specify all or subset of the exception classes (including their subclass) specified in the throws clause of the overridden method in the superclass else it will give compilation error.

 

  1. Runtime exceptions are referred to as unchecked exceptions because the compiler does not require explicit provision in the code for catching them. All other exceptions, meaning all those that DO NOT derive from java.lang.RuntimeException, are checked exceptions because the compiler will insist on provisions in the code for cathing them. A checked exception must be caught somewhere in your code. If you use a method that throws a checked exception but do not catch this checked exception somewhere, your code will not compile.

 

  1. Each method must however either handle all checked exceptions by supplying a catch clause or list each unhandled exceptions as a thrown exceptions in the throws clause.

 

  1. To throw your exception you just use the throw keyword with an instance of an exception object to throw, and you must caught this thrown exception if this exception is checked but if it is runtime exception or unchecked exception you needn’t to catch.

 

  1. If you want to handle an exception in more than one handler you can re-throw the exception, and the throw

statement must be the LAST line of your block because any line under it is unreachable.

 

  1. Runtime exceptions are a special case in Java. Because they have a special purpose of signaling events that happen at runtime, usually as the result of a programming error, or bug, they do not have to be caught. If not handled they terminate the application.

 

  1. If class extends Exception => class represent checked exception, but if the class extends RuntimeException it mean it is unchecked.

 

  1. getMessage() method in the Throwable class prints the error message string of this Throwable object if it was created with an error message string; or null if it was created with no error message.

 

  1. toString() method returns a short description of this Throwable object. If this Throwable object was created with an error message string, then the result is the concatenation of three strings:
    1. The name of the actual class of this object.
    2. “: ” (a colon and a space).
    3. The result of the getMessage() method for this object.

If this Throwable object was created with no error message string, then the name of the actual class of this object is returned.

 

  1. printStackTrace() method in the Throwable class prints this Throwable and its backtrace to the standard error stream. This method prints a stack trace for this Throwable object on the error output stream that is the value of the field System.err. The first line of output contains the result of the toString() method for this object. Remaining lines represent data previously recorded by the method fillInStackTrace(). The format of this information depends on the implementation, but the following example may be regarded as typical:

Example:

java.lang.NullPointerException

at MyClass.mash(MyClass.java:9)

at MyClass.crunch(MyClass.java:6)

at MyClass.main(MyClass.java:3)

 

  1. fillInStackTrace() method fills in the execution stack trace. This method records within this Throwable object information about the current state of the stack frames for the current thread. This method is useful when an application is re-throwing an error or exception.

Example:

try {

a = b / c;

} catch(ArithmeticThrowable e) { a = Number.MAX_VALUE; throw e.fillInStackTrace();

}

 

 

GUI PROGRAMMING – A REVIEW

 

 

Learning Objectives

 

After studying this lesson the students will be able to:

 

  • Identify, name and state the usage of the different components of the NetBeans IDE.

 

  • Identify and name the various methods and properties associated with the various form controls

 

  • Create simple applications in Java using NetBeans IDE.

 

  • Create  GUI  applications  using  the  concepts  of  variables  and  control structures.

 

 

NetBeans IDE allows us to develop applications by dragging and positioning GUI components from a palette onto a container. The GUI builder automatically takes care of the correct spacing and alignment of the different components relative to each other. The JFrame acts as a container for the elements like the JLabel, JButton, JTextArea and allows direct editing of their associated properties at the design time and run time. The related methods are used in the code to develop applications for a specific task. The concept of variables and control structures

are used to simplify the code of the applications.

 

 

 

 

 

 

 

 

 

 

 

 

 

Introduction

 

Let us take a journey back in time and think as to what the world was like 15 years ago. Amazon was a large river in South America. Yahoo was a term from Gulliver’s Travels. A googol was a very large number (one followed by a hundred zeroes) and to get our tickets booked we had to go to shops called ‘travel agents’. In case we fell sick and went to a hospital, our records were maintained on paper. If the doctor wanted to refer to a particular patient’s record, he had to instruct a assistant to hunt for information from the pile of files.

Nowadays hospitals use computers to keep the records of patients – medical history, details on what medication to give to a patient, the prescribed dosage and also personal details that can be accessed at the click of a button. The entire information is entered into a computer using a front end that accepts the different patient details. We learnt how to design valid front end forms in class XI in Java using the NetBeans IDE. This chapter will help us recapitulate all the concepts learnt in class XI.

 

 

 

NetBeans IDE

It can be used to create java applications very easily using the efficient GUI builder. Let us quickly recap the different components of the NetBeans IDE:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Inspector Window

Design Area

Properties Window

Palette

 

 

 

Figure 3.1 NetBeans IDE

 

  1. Title Bar

 

  1. Menu Bar with pull down menus

 

  1. Toolbars

 

  1. GUI builder: It is an area to place components on the form visually. There are two views of the GUI builder- the Design View and the Source View. We can switch over from one view to another by simply clicking on the source and design tabs directly above the Design Area.

 

  1. Palette: Palette contains controls or components used to create GUI applications

 

 

inspector Window: This window is used to display a hierarchy of all the components or controls placed on the current form.

 

 

  1. Properties Window: Using this window we can make changes in the properties of currently selected control on the form.

 

  1. Code Editor Window: – It is the area where we write code for our java application.

 

Components

Components (also known as “widgets”) are the basic interface elements the user interacts with: jlabels, jbuttons, jtextfields etc. Components are placed on a container (like the jFrame). There are two types of controls :

 

  • Parent or container controls: They act as a background for other controls. For example-Frame. When we delete a parent control, all its child controls get deleted. When we move a parent control all its child controls also move along with it.

Child controls: controls placed inside a container control are called child.controls. For example-Text Field, Label, Button etc.

 

 

 

 

 

 

 

 

To display a message in a Text Box on click of OK button

 

 

 

/*

*   BS_1.java

*   Created on Aug 20, 2009, 8:06:03 AM

*/

package basic_samples;

/**

*   @author MK

*/

public class BS_1 extends javax.swing.JFrame

{

public BS_1() { initComponents();

}

private void jButton1ActionPerformed (java.awt.event.ActionEvent evt)

{

jTextField1.setText(“Hello world”);

}

public static void main(String args[])

{

java.awt.EventQueue.invokeLater(new Runnable()

{

public void run()

{

 

 

}

});

}

new BS_1().setVisible(true);

 

// Variables declaration – do not modify private javax.swing.JButton jButton1; private javax.swing.JTextField jTextField1;

// End of variables declaration

}

 

 

Basic  Sample

 

To display a message as Lebels on click of OK button

 

 

 

private void jButton1ActionPerformed (java.awt.event.ActionEvent evt)

{

jLabel1.setText(“Hello                     world”);

}

 

 

private void jButton2ActionPerformed (java.awt.event.ActionEvent evt)

{

if     (jLabel2.getText()==”Good                Morning”) jLabel2.setText(“Good evening”);

else

jLabel2.setText(“Good                   Morning”);

}

 

 

Alternative 1

private void jButton1ActionPerformed (java.awt.event.ActionEvent evt)

{

jTextField4.setText (Double.toString(

(Double.parseDouble(jTextField1.getText())

*Double.parseDouble(jTextField2.getText())

*Double.parseDouble(jTextField3.getText()))

/100));

}

Alternative 2

private void jButton1ActionPerformed (java.awt.event.ActionEvent evt)

{

double P,R,T,SI;

P= Double.parseDouble (jTextField1.getText()); R= Double.parseDouble (jTextField2.getText());

T= Double.parseDouble (jTextField3.getText()); SI = P*R*T/100; jTextField4.setText(Double.toString(SI));

}

 

 

To accept values from Text Boxes and perform arithmetic operation and display in a MessageBox and final result in a Text Box on click of

 CalculateButton

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

private void jButton1ActionPerformed (java.awt.event.ActionEvent evt)

{

int sp = Integer.parseInt
    (jTextField1.getText());
int cp = Integer.parseInt
    (jTextField2.getText());
if (sp < cp )

{

JOptionPane.showMessageDialog

(this, “You have suffered a loss”); jTextField3.setText

(Integer.toString(cp – sp));

}

else

{

JOptionPane.showMessageDialog

(null, “You have made a profit”); jTextField3.setText

(Integer.toString(sp – cp));

}

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

private void jButton1ActionPerformed (java.awt.event.ActionEvent evt)

{

String Gender;

String Disp = “You R playing – “;

if (jRadioButton3.isSelected())

{

Gender = “Boy”;

JOptionPane.showMessageDialog (null,”Please go to the Boys stadium”);

}

if (jRadioButton4.isSelected())

{

Gender = “Girl”;

JOptionPane.showMessageDialog (null,”Please go to the Girls stadium”);

}

if (jCheckBox1.isSelected())

{

Disp = Disp + ” Basketball “;

}

if (jCheckBox2.isSelected())

 

 

{

Disp = Disp + ” Football “;

}

if (jCheckBox3.isSelected())

{

Disp = Disp + ” Swimming “;

}

if (jCheckBox4.isSelected())

{

Disp = Disp + ” Hockey “;

}

jTextField1.setText(Disp);

}

 

 

private void jButton1ActionPerformed (java.awt.event.ActionEvent evt)

{

String chosen;

chosen=”Great to know that you are from “

+(String) jComboBox1.getSelectedItem();

JOptionPane.showMessageDialog (null, chosen);

}

 

To accept value from Text Boxes and display relevant message in a Dialog Box and Concatenated Message in a Text area on click of OK Button

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

On Click of [OK] Button

private void jButton1ActionPerformed (java.awt.event.ActionEvent evt)

{

JOptionPane.showMessageDialog (null,”Something Happening…”);

String Text=”Hi”;

for (int I=Integer.parseInt(jTextField1.getText());

I<=Integer.parseInt(jTextField2.getText()); I++)

{

Text=Text+” Hello”;

}

jTextArea1.setText(Text);

}

 

On Click of [Cancel] Button

private void jButton2ActionPerformed (java.awt.event.ActionEvent evt)

{

System.exit(0);

}

 

 

 

 

Creating a New Project

 

The steps to create a new project are:

 

  1. Select New Project from the File menu. You can also click the New Project button in the IDE toolbar.

 

  1. In the Categories pane, select the General node. In the Projects pane, choose the Java Application type. Click the Next button.

 

  1. Enter the name of the project in the Project Name field and specify the project location. Do not create a Main class here.

 

  1. Click the Finish button.

 

Let us recap the relation between a Project, Form and Components. Each application is treated as a Project in NetBeans and each project can have one or multiple forms and this fact is clear from the Projects.

 

Further each form can have one or more elements – some of which may be visible and some invisible. The visible components are all shown under the Frame Component and the non-visible components are part of Other components.

We use the drag and drop feature of NetBeans to place components on the form to design an effective interface for our applications. The first step that we undertook while designing our applications was adding a new jFrame form. The jFrame is a window with

title, border, (optional) menu bar and is used to contain all other components placed by the       user   on   the   form.   Some  of   the   properties  of   the   jFrame   form   are

defaultCloseOperation and Title.

 

Property Description
defaultCloseOperation Sets  action  to  be  performed  when  the  user attempts to close the form.
 

Title

Sets the text to be displayed in the Title bar of the form window.

 

Figure 3.4 Properties of the jFrame Form

 

Any component of GUI front-end (the form itself and the swing containers and controls placed in the form) of an application is an object.  Each of these objects belongs to its corresponding class predefined in Java. For example, a form is an object of JFrame class, all the textfields are objects of JTextField class, and so on. Each object has some properties, methods, and events associated with it using which you can control the object’s appearance and behaviour.

Properties of an object are used to specify its appearance on the form. For example to set the background colour of a textfield  you change its background property; to set its font you change its font property; and so on.

Methods are used to perform some action on the object. For example to display something in a textfield you can use its setText() method, to extract the contents of a textfield you can use its getText() method. Methods can be divided into two categories- getters and setters.

 

  • Getters are the methods which extract some information from the object and return it to the program. Getters start with the word get. Examples of getters are: getText(), getForeground(), getModel(), isEditable etc.
  • Setters are the methods which set some properties of the object so that the object’s appearance changes. Setters start with the word set. Examples of setters are: setText(), setForground(), setModel() etc.

 

Events are the actions which are performed on controls. Examples of events are:

mouseClick, mouseMoved,keyPressed etc. When the user performs any action on a

control, an event happens and that event invokes (sends a call to) the corresponding part of the code and the application behaves accordingly.

After setting the properties of the jFrame we can start placing components like jButton on the jFrame form. A button is a component that the user presses or pushes to trigger a specific action. When the user clicks on the button at runtime, the code associated with the click action gets executed. The various methods and properties associated with the jButton are summarized in Figure 3.5.

 

Property                    Description

 

Background                Sets the background color.

 

Enabled                      Contains enabled state of component – true if enabled else false.

Font                           Sets the font.

 

Foreground                Sets the foreground color.

 

horizontal alignment   Sets the horizontal alignment of text displayed on the button.

Label                         Sets the display text.

 

Text                           Sets the display text

 

Method                      Description

 

getText()                    Retrieves the text typed in jButton.

 

String result=<button-name>.getText( );

 

setEnabled                 Enables or disables the button.

<button-name>.setEnabled(boolean b);

 

setText()                    Changes the display text at runtime.

 

<button-name>.setText(String text);

 

setVisible                   Makes the component visible or invisible – true to make the component visible; false to make it invisible.

<button-name>.setVisible(boolean aFlag);

 

Figure 3.5 Properties and Methods of the jButton

We developed simple real life applications wherein on the click of the button we accepted the data from the user in the jTextField and after processing the data the result was displayed in a jTextField or a jLabel. jTextField allows editing/displaying of a single line of text. jTextField is an input area where the user can type in characters whereas a jLabel provides text instructions or information. It displays a single line of read-only text, an image or both text and image. The various methods and properties associated with the

jTextField and jLabel are summarized in Figure 3.6 and 3.7 respectively.

 

Property                    Description

 

Background                Sets the background color.

 

Border                       Sets the type of border that will surround the text field.

 

editable                     If set true user can edit textfield. Default is true.

 

enabled                      Contains enabled state of component- True if enabled else false.

 

font                           Sets the font.

 

foreground                 Sets the foreground color.

 

horizontalAlignment   Sets the horizontal alignment of text displayed in the textField.

 

text                           Sets the display text

 

toolTipText                 Sets the text that will appear when cursor moves over the component.

 

 

Method                      Description

 

getText()                    Retrieves the text in typed in jTextField.

 

String result=<textfield-name>.getText( );

 

isEditable()                Returns true if the component is editable else returns false.

boolean b=<textfield-name>.isEditable( );

 

 

isEnabled()                 Returns true if the component is enabled,else returns false.

 

boolean b =<textfield-name>.isEnabled( );

 

setEditable                 Sets whether the user can edit the text in the textField.

true if editable else false.

 

<textfield-name>.setEditable(boolean b);

 

setText()                     Changes the display text at runtime.

 

<textfield-name>.setText(String t);

 

setVisible()                 Makes the component visible or invisible – true to make the component visible; false to make it invisible.

 

<textfield-name>.setVisible(boolean b);

 

Figure 3.6 Properties and Methods of the jTextField

 

 

 

Property                    Description

 

background                Sets the background color.

 

enabled                      Contains enabled state of component- true if enabled else false.

 

font                           Sets the font.

 

foreground                 Sets the foreground color.

 

horizontalAlignment   Sets the horizontal alignment of text displayed in the component.

 

text                            Sets the display text

 

 

 

Method Description
 

getText()

 

Retrieves the text in typed in jLabel.

 

String result=<label-name>.getText();

 

isEnabled()

 

Returns true if the component is enabled,else returns false.

 

boolean b=<label-name>.isEnabled();

 

setText()

 

Changes the display text at runtime.

 

<label-name>.setText(String t);

 

setVisible()

 

Makes the component visible or invisible – true to make the component visible; false to make it invisible.

 

<label-name>.setVisible(boolean b);

Figure 3.7 Properties and Methods of the jLabel

 

When we had become familiar with the usage of jTextField and jLabel controls then we developed an application in which we wanted to accept multiline input and display multiline output. Well can you recall the name of the component. Exactly the component is Text Area component. This component allows us to accept multiline input from the user or display multiple lines of information. This component automatically adds vertical or horizontal scroll bars as and when required during run time. The various methods and properties associated with the jTextArea are summarized in Figure 3.8.

 

Property                    Description

 

background                Sets the background color.

 

columns                     Sets number of columns preferred for display.

 

editable                     If set true user can edit textfield. Default is true.

 

enabled                      Contains enabled state of component- true if enabled else false.

 

font                           Sets the font.

 

 

foreground Sets the foreground color.
 

lineWrap

 

Indicates whether line of text should wrap in case it exceeds allocated width.(Default is false)

 

rows

 

Sets number of rows preferred for display.

 

text

 

Sets the display text

 

wrapStyleWord

Sends word to next line in case lineWrap is true and it results in breaking of a word, when lines are wrapped.

 

 

Method                      Description

 

append()                    Adds data at the end.

 

<textarea-name>.append(String str);

 

getText()                    Retrieves the text in typed in jTextArea.

 

String str = <textarea-name>.getText();

 

isEditable()                 Returns true if the component is editable else returns false.

boolean b = <textarea-name>.isEditable();

 

isEnabled()                 Returns true if the component is enabled, else returns false.

boolean b = <textarea-name>.isEnabled();

 

setText()                     Changes the display text at runtime.

 

<textarea-name>.setText(String t);

 

Figure 3.8 Properties and Methods of the jTextArea

 

Let us try and recollect the name of the component which can be used to enter confidential input like passwords which are single line. That’s right the component is jPassword. We can suppress the display of input as this component allows us to input confidential information like passwords. Each character entered can be replaced by an echo character. By default, the echo character is the asterisk, *. The properties of jPassword are summarized below:

 

 

Property Description
 

background

 

Sets the background color.

 

font

 

Sets the font.

 

foreground

 

Sets the foreground color.

 

text

 

Sets the display text

 

echoChar

 

Sets the character that will be displayed instead of text.

 

Figure 3.9 Properties of jPassword

 

Well we used radio buttons when we wanted to provide the user several choices and allowed him to select one of the choices (the radio buttons belong to a group allowing the user to select single option). But radio buttons occupy a lot of space. Thus, in case of too many options we used Combo boxes as they help save space and are less cumbersome to design as compared to radio button. We used check box and list when we wanted to display multiple options like selecting favourite sports or ordering multiple food items in a restaurant. The list is a preferred option over check box in situations wherever multiple options are required to be selected from a large number of known set of options as they help save space and are less cumbersome to design as compared to check boxes. The

properties and methods of jRadioButton are summarized below:

 

Property          Description

 

background      Sets the background color.

 

buttonGroup    Specifies  the  name  of  the  group  of  button  to  which  the jRadioButton belongs.

 

enabled           Contains enabled state of component -true if enabled else false.

 

font                 Sets the font.

 

foreground      Sets the foreground color.

 

label                Sets the display text.

 

text                 Sets the display text.

 

Selected          Sets the button as selected, if set to true, default is false.

 

 

Method Description
 

getText()

 

Retrieves the text displayed by radio button.

 

String str = <radiobutton-name>.getText();

isSelected() Returns true if the component is checked else returns false.

boolean b = <radiobutton-name>.isSelected();

setText() Changes the display text at runtime.

 

<radiobutton-name>.setText(String t);

 

setSelected()

 

Checks(true) or unchecks the radio button.

 

<radiobutton-name>.setSelected(boolean b);

 

Figure 3.10 Properties and methods of the jRadioButton

 

jCheckBox is a small box like component that is either marked or unmarked. When you click on it, it changes from checked to unchecked or vice versa automatically. The properties and methods of jCheckBox are summarized below:

 

 

Property                 Description

 

background             Sets the background color.

 

buttonGroup            Specifies the name of the group of button to which the jCheckBox belongs.

 

font                        Sets the font.

 

foreground              Sets the foreground color.

 

label                       Sets the display text.

 

text                         Sets the display text

 

selected                  Sets the check box as selected if set to true, default is false.

 

 

 

 

Method Description
getText() Retrieves the text typed in

String str = <checkbox-name>.getText();

isSelected() Returns true if the component is checked else returns false.

boolean b = <checkbox-name>.isSelected();

 

setText()

 

Changes the display text at runtime.

<checkbox-name>.setText(String t);

setSelected() Checks(true) or unchecks the checkbox.

<checkbox-name>.setSelected(boolean b);

 

Figure 3.11 Properties and methods of the jCheckBox

 

jComboBox is like a drop down box – you can click a drop-down arrow and select an option from a list whereas jList provides a scrollable set of items from which one or more may be selected. The properties and methods of jComboBox and jList are summarized below:

 

Property           Description

 

background       Sets the background color.

 

buttongroup      Specifies  the  name  of  the  group  of  button  to  which  the jComboBox belongs.

editable            If set true user can edit ComboBox. Default is true.

 

enabled            Contains enabled state of component- True if enabled else false.

 

font                  Sets the font.

 

foreground        Sets the foreground color.

 

model               Contains the values to be displayed in the combobox.

 

text                  Sets the display text

 

selectedIndex    Sets the index number of the element which should be selected by default.

selectedItem     Sets the selected item in the combobox. selectedItem and selectedIndex are in synchronization with each other.

 

 

 

 

Method Description
 

getSelectedItem()

 

Retrieves the selected item.

Object result =

<combobox-name>.getSelectedItem();

getSelectedIndex() Retrieves the index of the selected item.

int result =

<combobox-name>.getSelectedIndex();

 

setModel()

 

Sets the data model that the combo box uses to get its list of elements.

<combobox-name>.setModel

(ComboBoxModel aModel);

 

Figure 3.12 Properties and methods of the jComboBox

 

Property                    Description

 

background                Sets the background color.

 

enabled                      Contains enabled state of component- true if enabled else false.

 

font                           Sets the font.

 

foreground                 Sets the foreground color.

 

model                        Contains the values to be displayed in the list.

 

selectedIndex             Contains the index value of selected option of the control.

 

selectionMode            Describes the mode for selecting values.

 

– SINGLE (List box allows single selection only)

 

–  SINGLE_INTERVAL (List box allows single  continuous selection of options using shift key of keyboard)

 

–     MULTIPLE_INTERVAL    (List   box   allows   multiple selections of options using ctrl key of keyboard)

 

 

 

 

Method Description
getSelectedValue() Returns the selected value when only a single item is selected, if multiple items are selected then returns first selected value. Returns null in case no item selected

 

Object result=

<list-name>.getSelectedValue();

 

isSelectedIndex()

 

Returns true if specified index is selected.

 

boolean b =

<list-name>.isSelectedIndex(int index);

 

Figure 3.13 Properties and methods of the jList

 

We used JOptionPane when we wanted to request information from the user, display information to the user or a combination of both. It required an import statement at the top of the program. Well can you recollect the import statement? That’s right it is:

 

import javax.swing.JOptionPane;

 

OR

 

import javax.swing.*;

 

Either of them is acceptable. The difference is that the latter will import the entire library as denoted by the star whereas the first statement will just import the JOptionPane library.

 

 

Method                      Description

 

showMessageDialog()  Shows a one-button, modal dialog box that gives the user some information.

 

Example :

 

JOptionPane.showMessageDialog(this,”Java and NetBeans”);

 

 

 

 

showConfirmDialog()  Shows a three-button modal dialog that asks the user a question. User can respond by pressing any of the suitable buttons.

 

Example: Confirm= JOptionPane.showConfirmDialog(null,”quit?”)

 

showInputDialog()       Shows a modal dialog that prompts the user for input. It prompts the user with a text box in which the user can enter the relevant input.

 

Example :

name=

JOptionPane.showInputDialog(this,”Name:”);

 

 

 

 

Text Field :

A text field is a basic text control that enables the user to type a small amount of text. When the user indicates that text entry is complete (usually by pressing Enter), the text field fires an action event. If you need to obtain more than one line of input from the user, use a text area.

The Swing API provides several classes for components that are either varieties of text fields or that include text fields.

 

JTextField What this section covers: basic text fields.
JFormattedTextField A JTextField subclass that allows you to specify the legal set of characters that the user can enter. See How to Use Formatted Text Fields.
JPasswordField A JTextField subclass that does not show the characters that the user types. See How to Use Password Fields.
JComboBox Can be edited, and provides a menu of strings to choose from. See How to Use Combo Boxes.
JSpinner Combines a formatted text field with a couple of small buttons that enables the user to choose the previous or next available value. See How to Use Spinners.

The following example displays a basic text field and a text area. The text field is editable. The text area is not editable. When the user presses Enter in the text field, the program copies the text field’s contents to the text area, and then selects all the text in the text field.

 

You can find the entire code for this program in TextDemo.java. The following code creates and sets up the text field:

textField = new JTextField(20);

The integer argument passed to the JTextField constructor, 20 in the example, indicates the number of columns in the field. This number is used along with metrics provided by the field’s current font to calculate the field’s preferred width. It does not limit the number of characters the user can enter. To do that, you can either use a formatted text field or a document listener, as described in Text Component Features.


Note:

We encourage you to specify the number of columns for each text field. If you do not specify the number of columns or a preferred size, then the field’s preferred size changes whenever the text changes, which can result in unwanted layout updates.


The next line of code registers a TextDemo object as an action listener for the text field.

textField.addActionListener(this);

The actionPerformed method handles action events from the text field:

private final static String newline = "\n";
...
public void actionPerformed(ActionEvent evt) {
    String text = textField.getText();
    textArea.append(text + newline);
    textField.selectAll();
}

Notice the use of JTextField‘s getText method to retrieve the text currently contained by the text field. The text returned by this method does not include a newline character for the Enter key that fired the action event.

You have seen how a basic text field can be used. Because the JTextField class inherits from the JTextComponent class, text fields are very flexible and can be customized almost any way you like. For example, you can add a document listener or a document filter to be notified when the text changes, and in the filter case you can modify the text field accordingly. Information on text components can be found in Text Component Features. Before customizing a JTextField, however, make sure that one of the other components based on text fields will not do the job for you.

Often text fields are paired with labels that describe the text fields. See Examples That Use Text Fields for pointers on creating these pairs.

Another Example: TextFieldDemo

The TextFieldDemo example introduces a text field and a text area. You can find the entire code for this program in TextFieldDemo.java.

As you type characters in the text field the program searches for the typed text in the text area. If the entry is found it gets highlighted. If the program fails to find the entry then the text field’s background becomes pink. A status bar below the text area displays a message whether text is found or not. The Escape key is used to start a new search or to finish the current one. Here is a picture of the TextFieldDemo application.

 

 

To highlight text, this example uses a highlighter and a painter. The code below creates and sets up the highlighter and the painter for the text area.

final Highlighter hilit;
final Highlighter.HighlightPainter painter;
...
hilit = new DefaultHighlighter();
painter = new DefaultHighlighter.DefaultHighlightPainter(HILIT_COLOR);
textArea.setHighlighter(hilit);

This code adds a document listener to the text field’s document.

entry.getDocument().addDocumentListener(this);

Document listener’s insertUpdate and removeUpdate methods call the search method, which not only performs a search in the text area but also handles highlighting. The following code highlights the found text, sets the caret to the end of the found match, sets the default background for the text field, and displays a message in the status bar.

hilit.addHighlight(index, end, painter);
textArea.setCaretPosition(end);
entry.setBackground(entryBg);
message("'" + s + "' found. Press ESC to end search");

The status bar is a JLabel object. The code below shows how the message method is implemented.

private JLabel status;
...
void message(String msg) {
    status.setText(msg);
}

If there is no match in the text area, the following code changes the text field’s background to pink and displays a proper information message.

entry.setBackground(ERROR_COLOR);
message("'" + s + "' not found. Press ESC to start a new search");

The CancelAction class is responsible for handling the Escape key as follows.

   class CancelAction extends AbstractAction {
       public void actionPerformed(ActionEvent ev) {
               hilit.removeAllHighlights();
               entry.setText("");
               entry.setBackground(entryBg);
           }
   }

The Text Field API

The following tables list the commonly used JTextField constructors and methods. Other methods you are likely to call are defined in the JTextComponent class. Refer to The Text Component API.

You might also invoke methods on a text field inherited from the text field’s other ancestors, such as setPreferredSize, setForeground, setBackground, setFont, and so on. See The JComponent Class for tables of commonly used inherited methods.

The API for using text fields falls into these categories:

Setting or Obtaining the Field’s Contents
Method or Constructor Purpose
JTextField()
JTextField(String)
JTextField(String, int)
JTextField(int)
Creates a text field. When present, the int argument specifies the desired width in columns. The String argument contains the field’s initial text.
void setText(String)
String getText()
(defined in JTextComponent)
Sets or obtains the text displayed by the text field.

 

Fine Tuning the Field’s Appearance
Method Purpose
void setEditable(boolean)
boolean isEditable()
(defined in JTextComponent)
Sets or indicates whether the user can edit the text in the text field.
void setColumns(int);
int getColumns()
Sets or obtains the number of columns displayed by the text field. This is really just a hint for computing the field’s preferred width.
void setHorizontalAlignment(int);
int getHorizontalAlignment()
Sets or obtains how the text is aligned horizontally within its area. You can use JTextField.LEADING, JTextField.CENTER, and JTextField.TRAILING for arguments.

 

Implementing the Field’s Functionality
Method Purpose
void addActionListener(ActionListener)
void removeActionListener(ActionListener)
Adds or removes an action listener.
void selectAll()
(defined in JTextComponent)
Selects all characters in the text field.

 

String Processing

 

 

 

The String Class

 

After reading Chapters 9.1 to 9.3, you should be familiar with the

following terms and concepts (note: we’ll cover section 9.2.3 in the

next session):

 

* Terms:

o What is a string (definition)? What is a string literal?

o What does it mean when we say that a String is an object?

o What does it mean when we say that “strings are immutable”?

o What is an interned string?

o String indexes, string index range, StringIndexOutOfBoundsException

* Concepts:

o Counting characters in a string, retrieving a character in a string

o How characters are stored in a string object

o How string objects are created

o How string object are stored in memory

o String Methods – substring(), trim(), replace(), indexOf(),

matches(), etc.

o The Character wrapper class and its methods (e.g. isDigit(),

isLetter(), toLowerCase(), isUpperCase(), etc)

 

 

The chapter makes some reference to *arrays*, which we will learn about

later in the course. Simply put, arrays are variables that can contain a

list of values, and each value can be accessed by an index. This is very

similar to how Strings are stored (each character in the string is

accessed by an index). You don’t need to know much more at this point,

so feel free to skip over anything in this chapter that refers to arrays.

 

One of the important concepts we often forget or ignore when working

with strings is that strings are objects. When you create a string using

a statement such as:

 

String s = “Java”;

 

You are creating an object variable that points to a String object in

memory (see page 303, Fig 9.1 for example). This would be just as if you

had typed the statement:

 

String s = new String(“Java”);

 

The people who developed Java figured that since we work with Strings

all the time, they’d make it easier to declare Strings as if they were

primitive data, so you don’t have to use the String() constructor all

the time.

 

Another important concept is that *Strings are immutable*: once created,

they can’t be changed. Figure 9.1 on page 303 also shows the effects of

the following:

 

String s = “Java”;

s = “HTML”;

 

In this example, the String object referenced by the variable s is not

being altered. In the first statement, a new String object with the

value “Java” is created and its address stored in the variable s. Then

when the second statement executes, a new String object with the value

“HTML” is constructed and it’s address stored in the variable s. This

wipes out the previous contents, which was the address to the first

String object (“Java”).

 

Since strings are used so

often in programming, Java creates a pool of strings that are created in

a program. When you create a string object, Java checks to see if there

is a similar string object in the pool. If there is, Java will use that

string object instead of creating a new one.

 

When the first statement executes, which assigns the string literal

“Welcome to Java.” to the String variable *s*, the String class adds the

string “Welcome to Java” to the pool of strings. When the second

statement executes, which constructs a new String object with the value

“Welcome to Java” and assigns that object reference to the variable

*s2*, a brand new object is created in memory, so the s2 variable gets

its own object reference. The third statement creates a String variable

using the same string literal, “Welcome to Java”. In this case, Java

searches the pool of Strings to see if one matches. It finds the one

that is being references by s1, so it uses that one. This causes s3 to

point to the same String object as s1.

 

This is why the two println() statements product the output you see in

the middle of the page. The s1 and s2 variables are pointing to, or

referencing, different objects, so they are not equal. The s1 and s3

variables are referencing the same object, so they are equal.

 

s1 and s3 are called *interned strings*.

 

 

String Processing

 

 

* String class methods:

o length()

o charAt()

o substring()

o toLowerCase(), toUpperCase()

o trim()

o replace(), replaceAll()

o matches()

o indexOf(), lastIndexOf()

* Character class methods:

o compareTo()

o isDigit(), isLetter()

o isLetterOrDigit(), isSpaceChar()^* , isWhiteSpace()^*

o isLowerCase(), isUpperCase()

o toLowerCase(), toUpperCase()

Variables

 

 

Let us try and recollect why the need for variables arose. Well, we used variables when we required containers to store the values for some input, intermediate result or the final

result of an operation. The characteristics of a variable are:

 

  • It has a name.

 

  • It is capable of storing values.

 

  • It provides temporary storage.

 

  • It is capable of changing its value during program execution.

 

 

Variables help us to hold value for some input coming from the user or to hold intermediate result of some calculation or the final result of an operation. In other words, variables are like containers that can be used to store whatever values are needed for a specific computation. However, as different materials require different containers, and so we used different data types to hold different values.

 

 

 

 

 

Java programming language requires that all variables must first be declared before they can be used.

 

When programming, we store the variables in our computer’s memory, but the computer has to know what kind of data we want to store in them, since it is not going to occupy the same amount of memory to store a simple number or to store a single letter or a large number, and they are not going to be interpreted the same way so variables were used along with datatypes. The data types supported by java are summarized as follows:

Data type states the way the values of that type are stored, the operations that can be done on that type, and the range for that type.

 

Numeric Data Types :

These data types are used to store integer values only i.e. whole numbers only. The storage size and range is listed below :

 

Name Size Range Example
 

byte

 

1 byte(8 bits)

 

-128 to 127(-27 to +(27-1))

 

byte rollno;

short 2 bytes(16 bits) -32768 to 32767(-215 to +(215-1)) short rate;
int 4 bytes(32 bits) -231 to +(231-1) int num1;
 

long

 

8 bytes (64 bits)

-263 to +(263-1)  

long amount;

Figure 3.15 Storage size and range of numeric data types

 

Floating Data Types:

These data types are used to store numbers having decimal points i.e. they can store numbers having fractional values.

 

Name      Description          Size           Range                                Example

 

float       Single precision   4 bytes       (3.4×10-38) to +(3.4×1038)       float floating point         (32 bits)                                     average;

double    Double precision  8 bytes       (1.8×10-308) to +(1.8×10308)     double floating point      (64 bits)                                     principal;

 

Figure 3.16 Storage size and range of floating data types

 

 

 

 

The decision about which numeric data type to use should be based on the range of values

that a variable can take.

 

Character Data Types:

 

 

These data types are used to store characters. Character data types can store any type of values – numbers, characters and special characters. When we want to store a single character, we use char data type and when we want to store a group of characters we use string data type. For example to store grades (A, B, C, D, E) of a student we will use char type but to store name of a student, we will use string type. The char data type value is always enclosed inside ‘ ‘ (single quotes), whereas a string data type value is enclosed in ” ” (double quotes).

 

Operators are symbols that manipulate, combine or compare variables.

 

 

Operators

With the introduction of variables and constants there arose a need to perform certain operations on them. We performed operations on variables and constants using operators. The operators available in java are summarized below:

 

Assignment Operator :

 

One of the most common operator is the assignment operator “=” which is used to assign a value to a variable. We assign the value given on the right hand side to the variable specified on the left hand side. The value on the right hand side can be a number or an arithmetic expression. For example:

int sum = 0;

 

int prime = 4*5;

 

Arithmetic Operators :

 

These operators perform addition, subtraction, multiplication, and division. These symbols are similar to mathematical symbols. The only symbol that is different is “%”, which divides one operand by another and returns the remainder as its result.

+ additive operator

 

– subtraction operator

 

 

 

 

* multiplication operator

 

/ division operator

 

% remainder operator

 

Relational Operator :

A relational operator is used to test for some kind of relation between two entities. A mathematical expression created using a relational operator forms a relational expression or a condition. The following table lists the various relational operators and their usage:

 

Operator   Meaning              Usage

 

==      equal to               Tests whether two values are equal.

 

!=      not equal to         Tests whether two values are unequal.

 

>       greater than         Tests if the value of the left expression is greater than that of the right.

<       less than              Tests if the value of the left expression is less than that of the right.

>=      greater than or    Tests if the value of the left expression is greater equal to                          than or equal to that of the right.

<=      less than or         Tests if the value of the left expression is less equal to  than or equal to that of the right.

Figure 3.17 Relational Operators

 

Logical Operator :

 

A logical operator denotes a logical operation. Logical operators and relational operators are used together to form a complex condition. Logical operators are:

 

Operator        Use                       Meaning

 

&&         a>10 && b<8    a and b are both true

 

||         a>10 || b<8    Either a or b is true

 

!          ! a            a is false

 

Figure 3.18 Logical Operators

 

 

 

 

Unary Operators :

The unary operators perform different kind of operations on a single operand .The operations performed are increasing/decreasing a value, negating a value/ expression, or inverting a boolean value.

 

Symbol Name of the Operator Operation Example
 

+

Unary plus operator indicates positive value  

num = +1;

 

 

Unary minus operator

 

negates an expression

 

num = – num;

 

++

 

Increment operator

 

increments a value by 1

 

num = ++ num;

 

 

Decrement operator

 

decrements a value by 1

 

num = — num;

 

Figure 3.19 Unary Operators

 

Increment/Decrement Operators :

 

The increment/decrement (++,–) operators can be a prefix or a postfix. In a pre increment/decrement expression (++ x or — x), an operator is applied before an operand while in a post increment/decrement expression (x++ or x –) an operator is applied after an operand. In both conditions 1 is added to the value of the variable and the result is stored back to the variable. However, in a prefix expression, value is incremented first then this new value is restored back to the variable. In postfix expression the current value is assigned to a variable then it is incremented by 1 and restored back to the original variable.

Let us now try and recollect the conversion methods that we have used in java. When a Java program receives input data from a user, it must often convert it from one form (e.g., String) into another (e.g., double or int) for processing.

 

Conversion methods

 

  • To convert a string value to a number (For example, to convert the String value in a text field(jTextField1) to an int, long, float or double), we can use parse methods. Assume the following declarations:

String num1=jTextField1.getText(); int sum; long product;

float amount; double simple_int;

 

 

 

 

Type Example statement
int sum=Integer.parseInt(num1);
int sum=Integer.parseInt(jTextField1.getText());
long product=Long.parseLong(num1);
long product=Long.parseLong(jTextField1.getText());
float amount=Float.parseFloat(num1);
float amount=Float.parseFloat(jTextField1.getText());
double simple_int=Double.parseDouble(num1);

 

OR

simple_int=Double.parseDouble(jTextField1.getText());

 

Figure 3.20 Usage of Parse Methods

 

  • To convert a number to string we used valueOf method. Assume the following code:

 

 

int i   = 100;

 

float f = (float) 200.0; double d = 400.0;

long l  = 100000;

 

string str1 = String.valueOf(i); string str2 = String.valueOf(f); string str3 = String.valueOf(d); string str4 = String.valueOf(l);

jTextField1.setText(“Values of int, float, double and long are “+str1+”, “+str2+”, “+str3+” and “+str4);

 

Figure 3.21 Usage of valueOf Method

 

 

 

 

  • To convert a number to string, we also used toString method. Assume the following code :

 

int i   = 100;

 

float f = (float) 200.0; double d = 400.0;

long l  = 100000;

 

string str1 = Integer.toString(i); string str2 = Float.toString(f); string str3 = Double.toString(d); string str4 = Long.toString(l);

jTextField1.setText(“Values of int, float, double and long are “+str1+”, “+str2+”, “+str3+” and “+str4);

 

Figure 3.22 Usage of toString Method

 

  • To convert a number to string, we also used concatenation operator(+). If either operand of a concatenation is a string, the other operand is converted to string. Assume the following code :

 

int sum = 103; String convertsum; convertsum = “” + sum;

// Converts int 103 to String “103” convertsum = sum + ” is a number”;

// Assigns “103 is a number” to convertsum.

convertsum = “” + 10.9;

// Assigns “10.9” to convertsum convertsum = “” + 10.0/3.0;

// Assigns “3.3333333333333333” to convertsum

 

Figure 3.23 Concatenation operator

 

 

 

 

Control Structures

 

We used control structures when we wanted to control the flow of the program. We learnt two types of control structures in class XI namely, Selection statements and Iteration statements.

Control structures allow us to control the flow of our program’s execution. If left unchecked by control-flow statements, a program’s logic will flow through statements from top to bottom. We can have some control on the flow of a program by using operators to regulate precedence of operations, but control structures provide the power to change statement order and govern the flow of control in a program.

 

Selection Statements:

 

A selection statement selects among a set of statements depending on the value of a controlling expression. The selection statements are the if statement and the switch statement, which are discussed below:

 

Simple if Statement – The if statement allows selection (decision making) depending upon the outcome of a condition. If the condition evaluates to true then the statement immediately following if will be executed and otherwise if the condition evaluates to false then the statements following the else clause will be executed. The selection statements are also called conditional statements or decision statements.

The syntax of if statement is as shown below:

 

Syntax:

 

if (conditional expression)

 

{

 

Statement Block;

 

}

 

else

 

{

 

Statement Block;

 

}

 

 

 

 

 

 

 

 

GUI PROGRAMMING – A REVIEW

 

 

 

Points to remember about if statement :

 

  • The conditional expression is always enclosed in parenthesis.

 

  • The conditional expression may be a simple expression or a compound expression.

 

  • Each statement block may have a single or multiple statements to be executed. In case there is a single statement to be executed then it is not mandatory to enclose it in curly braces ({}) but if there are multiple statements then they must be enclosed in curly braces ({}).
  • The else clause is optional and needs to be included only when some action is to be taken if the test condition evaluates to false.

 

Nested if . . . else – These control structures are used to test for multiple conditions as against the simple if statement which can be used to test a single condition. The syntax of nested if else is as follows:

 

Syntax:

 

if (conditional expression1)

{

statements1;

}

else if (conditional expression2)

{

statements2;

}

else if (conditional expression3)

{

statements3;

}

else

{

statements4;

}

 

 

 

 

 

80

 

 

 

 

 

 

 

 

GUI PROGRAMMING – A REVIEW

 

 

 

Now let us design a form as shown in figure 3.24

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 3.24 To check whether the given number is a multiple of 3,5 or 7

 

Follow the steps enumerated below to design the form:

 

  1. Add a new JFrame Form and change its title property to Quick Multiple Checker.

 

  1. Add a label set its Text as Enter Number

 

  1. Add a jTextField and set its initial Text as “”

 

  1. Add three radio buttons on the form – Set the text of each of them as “Multiple of 3”, “Multiple of 5” and “Multiple of 7”.Group the radio buttons so that only one can be selected.

In this application we ask the user to enter a number and then the user will select one of the radio buttons and depending upon the button selected the multiple check for that number will be performed. Let us now write the code for the above mentioned application. Code to check for multiple of 3 is given. Try and write the code to perform a similar check for multiple of 5 and multiple of 7.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt)

 

{

 

double Number=Double.parseDouble(jTextField1.getText()); if (Number%3==0)

JOptionPane.showMessageDialog(this,”It is multiple of 3″); else

JOptionPane.showMessageDialog

(this,”It is NOT multiple of 3″);

 

}

 

Figure 3.25 Code for Multiple Checker

 

Let us now understand this code in detail.

 

Double.parseDouble(jTextField1.getText())

 

  • retrieves the value entered by the user in the text field using getText().This value by default is treated as a string and not as a number so it needs to be converted to a double type and this is achieved using the parseDouble()

method.The value is then stored in the variable Number.

 

if (Number%3=0)

 

  • check whether the number when divided by 3 gives 0 as the remainder.If the

remainder is zero then the number is divisible by 3 else it is not.

 

Switch Statement – This selection statement allows us to test the value of an expression with a series of character or integer values. On finding a matching value the control jumps to the statement pertaining to that value and the statement is executed, till the break statement is encountered or the end of switch is reached. The expression must either evaluate to an integer value or a character value. It cannot be a string or a real

number. The syntax of the switch statement is as follows:

switch (Variable/Expression)

 

{

 

case Value1:statements1 ; break ;

case Value2:statements2 ; break ;

.

 

.

 

default:statements3 ;

 

}

 

 

Comparing Switch and If..else Statements – Switch is used to select sections of code depending on specific integer or character values. If we are handling specific coded values (eg, the number of the button that was clicked in a JOptionPane), or processing characters(whose codes are treated like numbers), then switch is useful. The limitations

of switch are as follows:

 

  • It doesn’t allow ranges, eg case 90-100.

 

  • It requires either integers or characters and doesn’t allow useful types like String.

 

String comment; // The generated result.

 

int choice = Integer.ParseInt(jTextField.getText);

//Enter 0, 1, or 2.

 

switch (choice)

{

 

case 0: comment = “You look so much better than usual.”; break;

case 1: comment = “Your work is up to its usual standards.”;

 

break;

 

case 2: comment =

“You’re quite competent for so little experience.”; break;

default: comment =

“Oops — something is wrong with this code.”;

 

}

 

 

Equivalent if statement

 

 

String comment; // The generated result.

 

int choice= Integer.ParseInt(jTextField.getText);

//Enter is 0, 1,or 2.

 

if (choice == 0)

 

comment = “You look so much better than usual.”; else if (choice == 1)

comment = “Your work is up to its usual standards.”; else if (choice == 2)

comment=”You’re quite competent for so little experience”;

else

comment = “Oops — something is wrong with this code.”;

 

A switch statement can often be rewritten as an if statement. Let us look at the example given above, when a selection is to be made based on a single value, the switch statement is generally easier to read. The switch is useful when you need to manage a lot of if /else if / else. It has a shorter syntax and is more appropriate in this case.

 

Let us now design an application in which we will calculate the selling price depending upon the profit percent selected by the user. Design the application as shown in figure

3.26. Set the relevant properties of the components.

 

 

GUI

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 3.26 To calculate selling price depending upon profit margin

 

In this application depending upon the profit percent selected by the user we will calculate the selling price .Let us now write the code.

//Business Calculator private void

jButton1ActionPerformed(java.awt.event.ActionEvent evt)

 

{

 

double CP,Profit=0,SP; CP=Double.parseDouble(jTextField1.getText()); Profit=jComboBox1.getSelectedIndex(); SP=CP+CP*(Profit/100); jTextField2.setText(Double.toString(SP));

}

 

 

 

 

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)

 

{

 

jTextField1.setText(“”); jComboBox1.setSelectedIndex(0);

jTextField2.setText(“”);

 

}

 

Figure 3.27 Code to calculate selling price

 

Let us now understand the code in detail.

 

Double.parseDouble(jTextField1.getText())

 

  • retrieves the value entered by the user in the text field using getText().This value by default is treated as a string and not as a number so it needs to be converted to a double type and this is achieved using the parseDouble()

method. The value is then stored in the variable CP.

 

jComboBox.getSelectedIndex()

 

  • retrieves the index of the selected item so if the user selects 1st item profit is 0 and if the user selects 3rd, item profit is 2.This value is saved in a variable

profit.

 

SP=CP+CP*(Profit/100)

 

  • Formula to calculate selling Price.

 

jTextField2.setText(Double.toString(SP)

 

  • The variable SP is a numeric value so it is converted to a string using the toString() method and then the value is displayed in the text field using the

setText() method.

 

In the above application the profit margin is obtained from the Index value of the selected item of the combo box but what happens if the values in the combobox are as

shown in the figure 3.28.

PROGRAMMING – A REVIEW

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 3.28 Business Calculator version 1.2

 

We will use switch case to write the code. Only the code using switch case is given below but it is recommended that you think and try writing the code on your own.

 

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)

{

 

double CP,Profit=0,SP; CP=Double.parseDouble(jTextField1.getText()); switch (jComboBox1.getSelectedIndex())

{

 

case 0:Profit=5;break;//if first item selected profit is 5 case 1:Profit=10;break;//if second item selected profit is 10 case 2:Profit=15;break;

case 3:Profit=20;break; case 4:Profit=25;break; default:Profit=0;break;

}

 

Figure 3.29 Code for Business Calculator version 1.2

 

Iteration Statements :

 

These statements are used to perform a set of instructions repeatedly while the condition is true. Iteration statements are also called looping statements.

 

for loop – The loop has four different elements that have different purposes. These elements are:

 

a)       Initialization expression: Before entering in a loop, its variables must be initialized.

 

b)       Test Expression: The test expression decides whether the loop body will be executed or not. If the test condition is true, the loop body gets executed otherwise the loop is terminated.

 

c)       Increment/Decrement Expression: The Increment/Decrement expression changes the value of the loop variable.

 

d)       The Body of the loop: The statements, which are executed repeatedly while the test expression evaluates to true form the body of the loop.

 

The syntax of the for loop is:

 

Syntax

 

for( initialization; test exp; increment/decrement exp)

 

{ statements;

}

 

The three expressions inside the round braces of for loop are optional. Using this fact an infinite loop can be created as follows:

 

for (int I = 1 ;I <= 5 ;I++ )

 

{

 

jTextArea1.setText (jTextArea1.getText()+I);

 

//It will display 12345 in jTextArea1

 

}

While Loop – The while loop is an entry-controlled loop. It means that the loop condition is tested before executing the loop body. If the loop condition is initially false, for the first iteration, then loop may not execute even once. The main characteristic of the while loop is that it can be used in both cases i.e. when the number of iterations is known as well as when it is unknown. The syntax of the while loop is as follows:

 

Syntax

 

while(test expression)

 

{

 

loop body

 

}

 

Remember that in while loop, a loop control variable should be initialized before the loop begins and the loop variable should be updated inside the body of the while loop (else it will become an endless loop).

 

Do..While Loop – Do..While loop is an exit-controlled loop. In the do..while loop, the test occurs at the end of the loop. This ensures that the do..while loop executes the statements included in the loop body at least once. After the first execution of the statement, it evaluates the test expression. If the expression evaluates to true, then it executes the statements of the loop body again. Like if and while statements, the condition being checked must be included between parenthesis. The while statement must end with a semicolon. The syntax of the loop is as follows:

 

Syntax

 

do

 

{

 

loop body

 

}

 

while (test expression);

Comparing Do…While and While – The difference between do-while and while is that do- while evaluates its expression at the end of the loop instead of at the beginning. Therefore, the statements within the do block are always executed at least once. Do- while is an exit controlled loop and while is an entry controlled loop.

 

int ctr; ctr=0;

while (ctr < 5)  // Test and Loop

 

{

 

JOptionPane.showMessageDialog(this,ctr);

 

// Display Number ctr = ctr + 1;

// Increment LoopCounter

 

}

 

The same code is written using do while. In do while counter is checked at the end of loop body,therefore loop body is executed at least once.

 

int ctr = 0;

 

do              // Loop Begins

 

{

 

JOptionPane.showMessageDialog(this,ctr);

 

// Display Number ctr = ctr + 1;

// Increment LoopCounter

 

}

 

while (ctr<5);  // Testing the value of counter

 

 

 

 

 

G>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

BUTTON :

  1.   Change Button Font Example
  2.         This java example shows how to change button’s font using
  3.         AWT Button class.
  4. */
  5. import java.applet.Applet;
  6. import java.awt.Button;
  7. import java.awt.Font;
  8. /*
  9. <applet code=”ChangeButtonFontExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class ChangeButtonFontExample extends Applet{
  13.         public void init(){
  14.                 //create buttons
  15.                 Button button1 = new Button(“Button 1”);
  16.                 Button button2 = new Button(“Button 2”);
  17.                 /*
  18.                  * To change font of a button use
  19.                  * setFont(Font f) method.
  20.                  */
  21.                 Font myFont = new Font(“Courier”, Font.ITALIC,12);
  22.                 button1.setFont(myFont);
  23.                 //add buttons
  24.                 add(button1);
  25.                 add(button2);
  26.         }
  27. }
  1. Change Button Background Color Example
  2.         This java example shows how to change button background color using
  3.         AWT Button class.
  4. */
  5. import java.applet.Applet;
  6. import java.awt.Button;
  7. import java.awt.Color;
  8. /*
  9. <applet code=”ChangeButtonBackgroundExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class ChangeButtonBackgroundExample extends Applet{
  13.         public void init(){
  14.                 //create buttons
  15.                 Button button1 = new Button(“Button 1”);
  16.                 Button button2 = new Button(“Button 2”);
  17.                 /*
  18.                  * To change background color of a button use
  19.                  * setBackground(Color c) method.
  20.                  */
  21.                 button1.setBackground(Color.red);
  22.                 button2.setBackground(Color.green);
  23.                 //add buttons
  24.                 add(button1);
  25.                 add(button2);
  26.         }
  27. }
  1. Change Button Foreground Color Example
  2.         This java example shows how to change button foreground color using
  3.         AWT Button class.
  4. */
  5. import java.applet.Applet;
  6. import java.awt.Button;
  7. import java.awt.Color;
  8. /*
  9. <applet code=”ChangeButtonForegroundExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class ChangeButtonForegroundExample extends Applet{
  13.         public void init(){
  14.                 //create buttons
  15.                 Button button1 = new Button(“Button 1”);
  16.                 Button button2 = new Button(“Button 2”);
  17.                 /*
  18.                  * To change foreground color of a button use
  19.                  * setForeground(Color c) method.
  20.                  */
  21.                 button1.setForeground(Color.magenta);
  22.                 button2.setForeground(Color.blue);
  23.                 //add buttons
  24.                 add(button1);
  25.                 add(button2);
  26.         }
  27. }
  1. Create AWT Button Example
  2.         This java example shows how to create a Button using AWT Button class.
  3. */
  4. import java.applet.Applet;
  5. import java.awt.Button;
  6. /*
  7. <applet code=”CreateAWTButtonExample” width=200 height=200>
  8. </applet>
  9. */
  10. public class CreateAWTButtonExample extends Applet{
  11.         public void init(){
  12.                 /*
  13.                  * To create a button use
  14.                  * Button() constructor.
  15.                  */
  16.                 Button button1 = new Button();
  17.                 /*
  18.                  * Set button caption or label using
  19.                  * void setLabel(String text)
  20.                  * method of AWT Button class.
  21.                  */
  22.                 button1.setLabel(“My Button 1”);
  23.                 /*
  24.                  * To create button with the caption use
  25.                  * Button(String text) constructor of
  26.                  * AWT Button class.
  27.                  */
  28.                 Button button2 = new Button(“My Button 2”);
  29.                 //add buttons using add method
  30.                 add(button1);
  31.                 add(button2);
  32.         }
  33. }
  1.   Determine If The Button Is Enabled Example
  2.         This java example shows how to determine if the button is enabled or not
  3.         using isEnabled method.
  4. */
  5. import java.applet.Applet;
  6. import java.awt.Graphics;
  7. import java.awt.Button;
  8. /*
  9. <applet code=”DetermineIfButtonEnabled” width=100 height=200>
  10. </applet>
  11. */
  12. public class DetermineIfButtonEnabled extends Applet{
  13.         boolean isButton1Enabled;
  14.         boolean isButton2Enabled;
  15.         public void init(){
  16.                 //create Buttons
  17.                 Button Button1 = new Button(“Ok”);
  18.                 Button Button2 = new Button(“Cancel”);
  19.                 //add Buttons
  20.                 add(Button1);
  21.                 add(Button2);
  22.                 Button1.setEnabled(false);
  23.                 /*
  24.                  * To determine if the Button is enabled or not use
  25.                  * boolean isEnabled() method.
  26.                  */
  27.                 isButton1Enabled = Button1.isEnabled();
  28.                 isButton2Enabled = Button2.isEnabled();
  29.         }
  30.         public void paint(Graphics g){
  31.                 g.drawString(“Is Button 1 enabled? ” + isButton1Enabled, 10,50);
  32.                 g.drawString(“Is Button 2 enabled? ” + isButton2Enabled, 10,70);
  33.         }
  34. }
  1.   Determine If The Button Is Visible Example
  2.         This java example shows how to determine if the Button is visible or not
  3.         using isVisible method.
  4. */
  5. import java.applet.Applet;
  6. import java.awt.Graphics;
  7. import java.awt.Button;
  8. /*
  9. <applet code=”DetermineIfButtonVisible” width=100 height=200>
  10. </applet>
  11. */
  12. public class DetermineIfButtonVisible extends Applet{
  13.         boolean isButton1Visible;
  14.         boolean isButton2Visible;
  15.         public void init(){
  16.                 //create Buttons
  17.                 Button Button1 = new Button(“Ok”);
  18.                 Button Button2 = new Button(“Cancel”);
  19.                 //add Buttons
  20.                 add(Button1);
  21.                 add(Button2);
  22.                 Button2.setVisible(false);
  23.                 /*
  24.                  * To determine if the Button is visible or not use
  25.                  * boolean isVisible() method.
  26.                  */
  27.                 isButton1Visible = Button1.isVisible();
  28.                 isButton2Visible = Button2.isVisible();
  29.         }
  30.         public void paint(Graphics g){
  31.                 g.drawString(“Is Button 1 visible? ” + isButton1Visible, 10,50);
  32.                 g.drawString(“Is Button 2 visible? ” + isButton2Visible, 10,70);
  33.         }
  34. }
  1. Disable Button Example
  2.         This java example shows how to disable a Button using setEnabled method.
  3. */
  4. import java.applet.Applet;
  5. import java.awt.Button;
  6. /*
  7. <applet code=”DisableButtonExample” width=100 height=200>
  8. </applet>
  9. */
  10. public class DisableButtonExample extends Applet{
  11.         public void init(){
  12.                 //create Buttons
  13.                 Button Button1 = new Button(“Ok”);
  14.                 Button Button2 = new Button(“Cancel”);
  15.                 //add Buttons
  16.                 add(Button1);
  17.                 add(Button2);
  18.                 /*
  19.                  * To disable a Button, use
  20.                  * void setEnabled(Boolean enable)
  21.                  * method.
  22.                  */
  23.                 Button2.setEnabled(false);
  24.         }
  25. }
  1. Handle Action Events for AWT Button Example
  2.         This java example shows how to handle action event of AWT Button by implementing
  3.         ActionListener interface.
  4. */
  5. import java.applet.Applet;
  6. import java.awt.Button;
  7. import java.awt.Graphics;
  8. import java.awt.event.ActionEvent;
  9. import java.awt.event.ActionListener;
  10. /*
  11. <applet code=”HandleActionEventExample” width=200 height=200>
  12. </applet>
  13. */
  14. public class HandleActionEventExample extends Applet implements ActionListener{
  15.         String actionMessage=””;
  16.         public void init(){
  17.                 //create Buttons
  18.                 Button Button1 = new Button(“Ok”);
  19.                 Button Button2 = new Button(“Cancel”);
  20.                 //add Buttons
  21.                 add(Button1);
  22.                 add(Button2);
  23.                 //set action listeners for buttons
  24.                 Button1.addActionListener(this);
  25.                 Button2.addActionListener(this);
  26.         }
  27.         public void paint(Graphics g){
  28.                 g.drawString(actionMessage,10,50);
  29.         }
  30.         public void actionPerformed(ActionEvent ae){
  31.                 /*
  32.                  * Get the action command using
  33.                  * String getActionCommand() method.
  34.                  */
  35.                 String action = ae.getActionCommand();
  36.                 if(action.equals(“Ok”))
  37.                         actionMessage = “Ok Button Pressed”;
  38.                 else if(action.equals(“Cancel”))
  39.                         actionMessage = “Cancel Button Pressed”;
  40.                 repaint();
  41.         }
  42. }
  1. Hide Button Example
  2.         This java example shows how to hide a Button using setVisible method.
  3. */
  4. import java.applet.Applet;
  5. import java.awt.Button;
  6. /*
  7. <applet code=”HideButtonExample” width=100 height=200>
  8. </applet>
  9. */
  10. public class HideButtonExample extends Applet{
  11.         public void init(){
  12.                 //create Buttons
  13.                 Button Button1 = new Button(“Ok”);
  14.                 Button Button2 = new Button(“Cancel”);
  15.                 //add Buttons
  16.                 add(Button1);
  17.                 add(Button2);
  18.                 /*
  19.                  * To hide a Button, use
  20.                  * void setVisible(Boolean visible)
  21.                  * method.
  22.                  */
  23.                 Button2.setVisible(false);
  24.         }
  25. }
  1. Remove AWT Button From Applet or Window Frame Example
  2.         This java example shows how to remove a Button from window frame or an applet.
  3. */
  4. import java.applet.Applet;
  5. import java.awt.Button;
  6. /*
  7. <applet code=”RemoveButtonExample” width=200 height=200>
  8. </applet>
  9. */
  10. public class RemoveButtonExample extends Applet{
  11.         public void init(){
  12.                 //create Buttons
  13.                 Button Button1 = new Button(“Ok”);
  14.                 Button Button2 = new Button(“Cancel”);
  15.                 //add Buttons
  16.                 add(Button1);
  17.                 add(Button2);
  18.                 /*
  19.                  * To remove a Button from window, use
  20.                  * void remove(Component c)
  21.                  * method.
  22.                  *
  23.                  * Remove method removes the specified component from the
  24.                  * container.
  25.                  */
  26.                 remove(Button1);
  27.         }
  28. }
  1. Set Action Command For AWT Button Example
  2.         This java example shows how to set custom action command for AWT button using
  3.         setActionCommand method of Java AWT Button class.
  4. */
  5. import java.applet.Applet;
  6. import java.awt.Button;
  7. import java.awt.Graphics;
  8. import java.awt.event.ActionEvent;
  9. import java.awt.event.ActionListener;
  10. /*
  11. <applet code=”ButtonSetActionCommandExample” width=200 height=200>
  12. </applet>
  13. */
  14. public class ButtonSetActionCommandExample extends Applet implements ActionListener{
  15.         String actionMessage=””;
  16.         public void init(){
  17.                 //create Button
  18.                 Button Button1 = new Button(“I agree with the terms and conditions”);
  19.                 //add Button
  20.                 add(Button1);
  21.                 //set action listeners for buttons
  22.                 Button1.addActionListener(this);
  23.                 /*
  24.                  * By default, button’s action command is it’s label. But in
  25.                  * some cases, labels are too long and is not appropriate to use
  26.                  * it as an action command. In such situation you would want to
  27.                  * define custom short action command for a button.
  28.                  *
  29.                  * To set custom action command for a button, use
  30.                  * void setActionCommand(String command)
  31.                  * method of AWT Button class.
  32.                  */
  33.                 Button1.setActionCommand(“Agree”);
  34.         }
  35.         public void paint(Graphics g){
  36.                 g.drawString(actionMessage,10,50);
  37.         }
  38.         public void actionPerformed(ActionEvent ae){
  39.                 /*
  40.                  * Get the action command using
  41.                  * String getActionCommand() method.
  42.                  */
  43.                 String action = ae.getActionCommand();
  44.                 actionMessage = action + ” button pressed!”;
  45.                 repaint();
  46.         }
  47. }

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

LABEL

  1. Align Icon in JLabel Example
  2.         This java example shows how to align icon displayed in JLabel
  3.         using Java Swing JLabel class.
  4. */
  5. import javax.swing.ImageIcon;
  6. import javax.swing.JApplet;
  7. import javax.swing.JLabel;
  8. /*
  9. <applet code=”JLabelWithIconTextExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class JLabelIconAlignmentExample extends JApplet{
  13.         public void init(){
  14.                 /*
  15.                  * Create an icon from an image using
  16.                  * ImageIcon(String imagePath, String description)
  17.                  * constructor.
  18.                  */
  19.                 ImageIcon icon = new ImageIcon(“images/copy.gif”);
  20.                 /*
  21.                  * To create an Image label and set horizontal alignment, use
  22.                  * JLabel(Icon icon, int horizontalAlignment) or
  23.                  * JLabel(String text, Icon icon, int horizontalAlignment)
  24.                  *
  25.                  * where horizontalAlignment can be one of the following SwingConstants,
  26.                  * LEFT, CENTER, RIGHT, LEADING or TRAILING.
  27.                  */
  28.                 //center aligned JLabel
  29.                 JLabel imageLabel = new JLabel(“Copy”,icon, JLabel.CENTER);
  30.                 /*
  31.                  * Add JLabel to an Applet
  32.                  */
  33.                 add(imageLabel);
  34.                 /*
  35.                  * Please note that the label is centered vertically in its display area.
  36.                  */
  37.         }
  38. }

8888888888888888

  1.   Check whether JLabel is Visible or Enabled Example
  2.         This java example shows how to create check whether the JLabel is visible or
  3.         enabled using Java Swing JLabel class.
  4. */
  5. import javax.swing.JApplet;
  6. import javax.swing.JLabel;
  7. /*
  8. <applet code=”JLabelCheckVisibleOrEnableExample” width=200 height=200>
  9. </applet>
  10. */
  11. public class JLabelCheckVisibleOrEnabledExample extends JApplet{
  12.         public void init(){
  13.                 /*
  14.                  * To create JLabel use
  15.                  * JLabel(String caption) constructor
  16.                  * of JLabel class.
  17.                  */
  18.                 JLabel label1 = new JLabel(“This is JLabel Example.”);
  19.                 //add label to applet
  20.                 add(label1);
  21.                 /*
  22.                  * To check whether the JLabel is visible use,
  23.                  * void isVisible(boolean visible)
  24.                  * method.
  25.                  */
  26.                 boolean visible = label1.isVisible();
  27.                 /*
  28.                  * To check whether the JLabel is enabled use,
  29.                  * void isEnabled(boolean enable)
  30.                  * method.
  31.                  */
  32.                 boolean enabled = label1.isEnabled();
  33.         }
  34. }

8888888888888888

  1.   Create JLabel With Image Icon Example
  2.         This java example shows how to create a label with image icon using
  3.         Java Swing JLabel class.
  4. */
  5. import javax.swing.ImageIcon;
  6. import javax.swing.JApplet;
  7. import javax.swing.JLabel;
  8. /*
  9. <applet code=”JLabelWithIconExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class JLabelWithIconExample extends JApplet{
  13.         public void init(){
  14.                 /*
  15.                  * Create an icon from an image using
  16.                  * ImageIcon(String imagePath, String description)
  17.                  * constructor.
  18.                  */
  19.                 ImageIcon icon = new ImageIcon(“images/copy.gif”);
  20.                 /*
  21.                  * To create a JLabel with image icon use,
  22.                  * JLabel(Icon icon)
  23.                  * constructor of JLabel class.
  24.                  */
  25.                 JLabel copyLabel = new JLabel(icon);
  26.                 /*
  27.                  * Add label to an applet
  28.                  */
  29.                 add(copyLabel);
  30.         }
  31. }

888888888888888888888

  1.   Create JLabel With Image Icon and Text Example
  2.         This java example shows how to create a label with image icon
  3.         and text using Java Swing JLabel class.
  4. */
  5. import javax.swing.ImageIcon;
  6. import javax.swing.JApplet;
  7. import javax.swing.JLabel;
  8. /*
  9. <applet code=”JLabelWithIconTextExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class JLabelWithIconTextExample extends JApplet{
  13.         public void init(){
  14.                 /*
  15.                  * Create an icon from an image using
  16.                  * ImageIcon(String imagePath, String description)
  17.                  * constructor.
  18.                  */
  19.                 ImageIcon icon = new ImageIcon(“images/copy.gif”);
  20.                 /*
  21.                  * To create a JLabel with image icon and text use,
  22.                  * JLabel(String text, Icon icon, int horizontalAlignment)
  23.                  * constructor of JLabel class.
  24.                  */
  25.                 JLabel copyLabel = new JLabel(“Copy”, icon, JLabel.CENTER);
  26.                 /*
  27.                  * Add label to an applet
  28.                  */
  29.                 add(copyLabel);
  30.         }
  31. }

8888888888888888

 

  1. Disable JLabel Example
  2.         This java example shows how to disable JLabel using
  3.         Java Swing JLabel class.
  4. */
  5. import javax.swing.JApplet;
  6. import javax.swing.JLabel;
  7. /*
  8. <applet code=”DisableJLabelExample” width=200 height=200>
  9. </applet>
  10. */
  11. public class DisableJLabelExample extends JApplet{
  12.         public void init(){
  13.                 /*
  14.                  * To create JLabel use
  15.                  * JLabel (String caption) constructor
  16.                  * of JLabel class.
  17.                  */
  18.                 JLabel label1 = new JLabel(“JLabel Disable Example.”);
  19.                 //add label to applet
  20.                 add(label1);
  21.                 /*
  22.                  * To disable JLabel use,
  23.                  * void setEnabled(boolean enabled)
  24.                  * method.
  25.                  */
  26.                 label1.setEnabled(false);
  27.                 /*
  28.                  * To re-enable the same JLabel use
  29.                  * setEnabled(true) method.
  30.                  */
  31.         }
  32. }

888888888888888888888888888888888

  1.   Get Horizontal Alignment of JLabel Example
  2.         This java example shows how to get horizontal alignment of label’s content using
  3.         Java Swing JLabel class.
  4. */
  5. import javax.swing.JApplet;
  6. import javax.swing.JLabel;
  7. /*
  8. <applet code=”GetHorizontalAlignmenntExample” width=200 height=200>
  9. </applet>
  10. */
  11. public class GetHorizontalAlignmentExample extends JApplet{
  12.         public void init(){
  13.                 /*
  14.                  * To create JLabel use
  15.                  * JLabel(String caption) constructor
  16.                  * of JLabel class.
  17.                  */
  18.                 JLabel label1 = new JLabel(“JLabel Get Horizontal Alignment Example.”);
  19.                 //add label to applet
  20.                 add(label1);
  21.                 /*
  22.                  * To get horizontal alignment of label’s content use,
  23.                  * int getHorizontalAlignment()
  24.                  * method of JLabel’s class.
  25.                  *
  26.                  *
  27.                  * Return value is one of the following constants,
  28.                  * LEFT, CENTER, RIGHT, LEADING or TRAILING.
  29.                  *
  30.                  */
  31.                 int alignment = label1.getHorizontalAlignment();
  32.                 switch(alignment){
  33.                         case JLabel.LEFT:
  34.                                 label1.setText(“Left”);
  35.                                 break;
  36.                         case JLabel.CENTER:
  37.                                 label1.setText(“Center”);
  38.                                 break;
  39.                         case JLabel.RIGHT:
  40.                                 label1.setText(“Right”);
  41.                                 break;
  42.                         case JLabel.LEADING:
  43.                                 label1.setText(“Leading”);
  44.                                 break;
  45.                         case JLabel.TRAILING:
  46.                                 label1.setText(“Trailing”);
  47.                                 break;
  48.                 }
  49.         }
  50. }

8888888888888888888888888888888

  1. Get JLabel’s Text Example
  2.         This java example shows how to get JLabel’s text using getText method of
  3.         Java Swing JLabel class.
  4. */
  5. import javax.swing.ImageIcon;
  6. import javax.swing.JApplet;
  7. import javax.swing.JLabel;
  8. /*
  9. <applet code=”GetLabelTextExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class GetLabelTextExample extends JApplet{
  13.         public void init(){
  14.                 /*
  15.                  * To create JLabel use
  16.                  * JLabel (String caption) constructor
  17.                  * of JLabel class.
  18.                  */
  19.                 JLabel label1 = new JLabel(“This is JLabel Get Text Example.”);
  20.                 //add label to applet
  21.                 add(label1);
  22.                 /*
  23.                  * To get text displayed in JLabel use,
  24.                  * String getText()
  25.                  * method of JLabel class.
  26.                  */
  27.                 String text = label1.getText();
  28.         }
  29. }

8888888888888888888888888888888

  1.   Get X and Y Coordinates of JLabel Example
  2.         This java example shows how to get X and Y coordinates using
  3.         Java Swing JLabel class.
  4. */
  5. import javax.swing.JApplet;
  6. import javax.swing.JLabel;
  7. /*
  8. <applet code=”JLabelGetXYCoordinatesExample” width=200 height=200>
  9. </applet>
  10. */
  11. public class JLabelGetXYCoordinatesExample extends JApplet{
  12.         public void init(){
  13.                 /*
  14.                  * To create JLabel use
  15.                  * JLabel (String caption) constructor
  16.                  * of JLabel class.
  17.                  */
  18.                 JLabel label1 = new JLabel(“This is JLabel Example.”);
  19.                 //add label to applet
  20.                 add(label1);
  21.                 /*
  22.                  * To get X coordinate of JLabel use,
  23.                  * int getX()
  24.                  * method.
  25.                  *
  26.                  * To get Y coordinate of JLabel use,
  27.                  * int getY()
  28.                  * method.
  29.                  */
  30.                 label1.setText(label1.getX() + “, ” + label1.getY());
  31.         }
  32. }

888888888888888888888888888

  1. Get or Set Gap Between JLabel’s Icon and Text Example
  2.         This java example shows how to get gap between JLabel’s icon and text
  3.         using Java Swing JLabel class.
  4. */
  5. import javax.swing.ImageIcon;
  6. import javax.swing.JApplet;
  7. import javax.swing.JLabel;
  8. /*
  9. <applet code=”JLabelGapBetweenTextAndIconExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class JLabelGapBetweenTextAndIconExample extends JApplet{
  13.         public void init(){
  14.                 //create ImageIcon
  15.                 ImageIcon icon = new ImageIcon(“images/copy.gif”);
  16.                 //create JLabel
  17.                 JLabel copyLabel = new JLabel(“Copy”, icon, JLabel.CENTER);
  18.                 add(copyLabel);
  19.                 /*
  20.                  * To determine gap between Icon and Text use,
  21.                  * int getIconTextGap()
  22.                  * method.
  23.                  *
  24.                  * Return value is the number of pixels between
  25.                  * icon and text.
  26.                  *
  27.                  * Default gap between JLabel’s text and Icon is
  28.                  * 4 pixels.
  29.                  */
  30.                 int gap = copyLabel.getIconTextGap();
  31.                 /*
  32.                  * To set gap between JLabel’s icon and text, use
  33.                  * void setIconTextGap(int gap)
  34.                  * method.
  35.                  *
  36.                  * where gap is number of pixels.
  37.                  */
  38.                 copyLabel.setIconTextGap(50);
  39.         }
  40. }

8888888888888888888888888

  1. JLabel Disabled Icon Example
  2.         This java example shows how to get and set icon when JLabel is disabled using
  3.         setDisabled and getDisabled methods of Java Swing JLabel class.
  4. */
  5. import javax.swing.Icon;
  6. import javax.swing.ImageIcon;
  7. import javax.swing.JApplet;
  8. import javax.swing.JLabel;
  9. /*
  10. <applet code=”JLabelDisabledIconExample” width=200 height=200>
  11. </applet>
  12. */
  13. public class JLabelDisabledIconExample extends JApplet{
  14.         public void init(){
  15.                 /*
  16.                  * To create JLabel use
  17.                  * JLabel (String caption) constructor
  18.                  * of JLabel class.
  19.                  */
  20.                 JLabel label1 = new JLabel(“JLabel Disabled Icon Example.”);
  21.                 //add label to applet
  22.                 add(label1);
  23.                 /*
  24.                  * To set icon when particular JLabel is disabled use,
  25.                  * void setDisabledIcon(Icon icon)
  26.                  * method.
  27.                  */
  28.                 label1.setDisabledIcon(new ImageIcon(“images/copy.gif”));
  29.                 /*
  30.                  * To get Icon which is displayed when JLabel is disabled use,
  31.                  * Icon getDisabledIcon()
  32.                  * method of JLabel class.
  33.                  */
  34.                 Icon icon = label1.getDisabledIcon();
  35.         }
  36. }

888888888888

  1.   JLabel Get Tooltip Example
  2.         This java example shows how to get tooltip text for JLabel using
  3.         getToolTipText method of Java Swing JLabel class.
  4. */
  5. import javax.swing.JApplet;
  6. import javax.swing.JLabel;
  7. /*
  8. <applet code=”JLabelGetTooltipExample” width=200 height=200>
  9. </applet>
  10. */
  11. public class JLabelGetTooltipExample extends JApplet{
  12.         public void init(){
  13.                 /*
  14.                  * To create JLabel use
  15.                  * JLabel (String caption) constructor
  16.                  * of JLabel class.
  17.                  */
  18.                 JLabel label1 = new JLabel(“JLabel Get ToolTip Example.”);
  19.                 //add label to applet
  20.                 add(label1);
  21.                 /*
  22.                  * To get ToolTip text of JLabel use,
  23.                  * String getToolTipText()
  24.                  * method of JLabel class.
  25.                  */
  26.                 String toolTipText = label1.getToolTipText();
  27.         }
  28. }

888888888888888888888

  1.   JLabel Horizontal Text Position Example
  2.         This java example shows how to set and get horizontal position of text relative to
  3.         the image using Java Swing JLabel class.
  4. */
  5. import javax.swing.ImageIcon;
  6. import javax.swing.JApplet;
  7. import javax.swing.JLabel;
  8. /*
  9. <applet code=”JLabelHorizontalPositionExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class JLabelHorizontalPositionExample extends JApplet{
  13.         public void init(){
  14.                 /*
  15.                  * Create an icon from an image using
  16.                  * ImageIcon(String imagePath, String description)
  17.                  * constructor.
  18.                  */
  19.                 ImageIcon icon = new ImageIcon(“images/copy.gif”);
  20.                 /*
  21.                  * To create a JLabel with image icon and text use,
  22.                  * JLabel(String text, Icon icon, int horizontalAlignment)
  23.                  * constructor of JLabel class.
  24.                  */
  25.                 JLabel copyLabel = new JLabel(“Copy”, icon, JLabel.CENTER);
  26.                 /*
  27.                  * Add label to an applet
  28.                  */
  29.                 add(copyLabel);
  30.                 /*
  31.                  * To get horizontal position of JLabel’s content relative to it’s
  32.                  * image use,
  33.                  *
  34.                  * int getHorizontalTextPosition()
  35.                  * method of JLabel class.
  36.                  *
  37.                  * Return value is one of the following constants,
  38.                  * LEFT, CENTER, RIGHT, LEADING or TRAILING.
  39.                  */
  40.                 int position = copyLabel.getHorizontalTextPosition();
  41.                 /*
  42.                  * To set horizontal position of text relative to it’s image use,
  43.                  * void setHorizontalTextPosition(int position)
  44.                  * method of JLabel class.
  45.                  *
  46.                  * Possible value is one of the following constants,
  47.                  * LEFT, CENTER, RIGHT, LEADING or TRAILING.
  48.                  */
  49.                 copyLabel.setHorizontalTextPosition(JLabel.RIGHT);
  50.         }
  51. }

8888888888888888

  1. JLabel Set Font Example
  2.         This java example shows how to set custom font for JLabel using
  3.         Java Swing JLabel class.
  4. */
  5. import java.awt.Font;
  6. import javax.swing.JApplet;
  7. import javax.swing.JLabel;
  8. /*
  9. <applet code=”JLabelSetFontExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class JLabelSetFontExample extends JApplet{
  13.         public void init(){
  14.                 /*
  15.                  * To create JLabel use
  16.                  * JLabel (String caption) constructor
  17.                  * of JLabel class.
  18.                  */
  19.                 JLabel label1 = new JLabel(“JLabel Set Font Example.”);
  20.                 /*
  21.                  * To set custom font for JLabel use,
  22.                  * void setFont(Font font)
  23.                  * method.
  24.                  */
  25.                 //create new Font
  26.                 Font font = new Font(“Courier”, Font.BOLD,12);
  27.                 //set font for JLabel
  28.                 label1.setFont(font);
  29.                 //add label to applet
  30.                 add(label1);
  31.         }
  32. }

888888888888888

  1. /*
  2.         JLabel Set Tooltop Example
  3.         This java example shows how to set tooltip text for JLabel using
  4.         setToolTipText method of Java Swing JLabel class.
  5. */
  6. import javax.swing.JApplet;
  7. import javax.swing.JLabel;
  8. /*
  9. <applet code=”JLabelSetToolTipExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class JLabelSetToolTipExample extends JApplet{
  13.         public void init(){
  14.                 /*
  15.                  * To create JLabel use
  16.                  * JLabel (String caption) constructor
  17.                  * of JLabel class.
  18.                  */
  19.                 JLabel label1 = new JLabel(“JLabel Set Tooltip Example”);
  20.                 //add label to applet
  21.                 add(label1);
  22.                 /*
  23.                  * To set tooltip for JLabel use,
  24.                  * void setToolTipText(String tooltip)
  25.                  * method of JLabel class.
  26.                  */
  27.                 label1.setToolTipText(“Demo Tooltip for JLabel”);
  28.         }
  29. }

8888888888888888888

  1. /*
  2.         Set Background Color of JLabel Example
  3.         This java example shows how to set background color of JLabel using
  4.         Java Swing JLabel class.
  5. */
  6. import java.awt.Color;
  7. import javax.swing.JApplet;
  8. import javax.swing.JLabel;
  9. /*
  10. <applet code=”JLabelSetBackgroundColorExample” width=200 height=200>
  11. </applet>
  12. */
  13. public class JLabelSetBackgroundColorExample extends JApplet{
  14.         public void init(){
  15.                 /*
  16.                  * To create JLabel use
  17.                  * JLabel (String caption) constructor
  18.                  * of JLabel class.
  19.                  */
  20.                 JLabel label1 = new JLabel(“JLabel Set Background Color Example.”);
  21.                 //this will create light blue color
  22.                 Color customColor = new Color(10,10,255);
  23.                 /*
  24.                  * NOTE: By default JLabel is set to transparent mode. Calling setBackground
  25.                  * directly will not set the background color of JLabel.
  26.                  *
  27.                  * In order to make the label set opaque, you need to call
  28.                  * void setOpaque(boolean opaque)
  29.                  * method.
  30.                  */
  31.                 label1.setOpaque(true);
  32.                 /*
  33.                  * To set background color of JLabel text use,
  34.                  * void setBackground(Color color)
  35.                  * method.
  36.                  */
  37.                 label1.setBackground(customColor);
  38.                 //add label to applet
  39.                 add(label1);
  40.         }
  41. }

88888888888888888888888888

  1. Set Foreground Color of JLabel Example
  2.         This java example shows how to set foreground color of JLabel using
  3.         Java Swing JLabel class.
  4. */
  5. import java.awt.Color;
  6. import javax.swing.JApplet;
  7. import javax.swing.JLabel;
  8. /*
  9. <applet code=”JLabelSetForegroundColorExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class JLabelSetForegroundColorExample extends JApplet{
  13.         public void init(){
  14.                 /*
  15.                  * To create JLabel use
  16.                  * JLabel (String caption) constructor
  17.                  * of JLabel class.
  18.                  */
  19.                 JLabel label1 = new JLabel(“JLabel Set Forground Color Example.”);
  20.                 /*
  21.                  * To set foreground color of JLabel text use,
  22.                  * void setForeground(Color color)
  23.                  * method.
  24.                  */
  25.                 //this will create light blue color
  26.                 Color customColor = new Color(10,10,255);
  27.                 label1.setForeground(customColor);
  28.                 //add label to applet
  29.                 add(label1);
  30.         }
  31. }

 

  1. Set Horizontal Alignment of JLabel Example
  2.         This java example shows how to set horizontal alignment of label’s content using
  3.         Java Swing JLabel class.
  4. */
  5. import javax.swing.JApplet;
  6. import javax.swing.JLabel;
  7. /*
  8. <applet code=”SetHorizontalAlignmentExample” width=200 height=200>
  9. </applet>
  10. */
  11. public class SetHorizontalAlignmentExample extends JApplet{
  12.         public void init(){
  13.                 /*
  14.                  * To create JLabel use
  15.                  * JLabel (String caption) constructor
  16.                  * of JLabel class.
  17.                  */
  18.                 JLabel label1 = new JLabel(“JLabel Set Horizontal Alignment Example.”);
  19.                 //add label to applet
  20.                 add(label1);
  21.                 /*
  22.                  * To set horizontal alignment of label’s content use,
  23.                  * void setHorizontalAlignment(int alignment)
  24.                  * method of JLabel’s class.
  25.                  *
  26.                  *
  27.                  * Where value of alignment is one of the following constants,
  28.                  * LEFT, CENTER, RIGHT, LEADING or TRAILING.
  29.                  *
  30.                  */
  31.                 label1.setHorizontalAlignment(JLabel.CENTER);
  32.         }
  33. }

 

  1. Set Icon for JLabel Example
  2.         This java example shows how to set image icon for JLabel using
  3.         setIcon method of Java Swing JLabel class.
  4. */
  5. import javax.swing.ImageIcon;
  6. import javax.swing.JApplet;
  7. import javax.swing.JLabel;
  8. /*
  9. <applet code=”SetJLabelIconExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class SetJLabelIconExample extends JApplet{
  13.         public void init(){
  14.                 /*
  15.                  * To create JLabel use
  16.                  * JLabel (String caption) constructor
  17.                  * of JLabel class.
  18.                  */
  19.                 JLabel label1 = new JLabel(“JLabel Set Icon Example.”);
  20.                 //add label to applet
  21.                 add(label1);
  22.                 /*
  23.                  * To set image icon for JLabel use,
  24.                  * void setLabel(Icon icon)
  25.                  * method of JLabel class.
  26.                  */
  27.                 label1.setIcon(new ImageIcon(“images/copy.gif”));
  28.         }
  29. }

 

  1. Set JLabel Border Example
  2.         This java example shows how to create a border for JLabel using
  3.         Java Swing JLabel class.
  4. */
  5. import java.awt.Color;
  6. import javax.swing.BorderFactory;
  7. import javax.swing.JApplet;
  8. import javax.swing.JLabel;
  9. import javax.swing.border.Border;
  10. /*
  11. <applet code=”JLabelSetBorderExample” width=200 height=200>
  12. </applet>
  13. */
  14. public class JLabelSetBorderExample extends JApplet{
  15.         public void init(){
  16.                 /*
  17.                  * To create JLabel use
  18.                  * JLabel (String caption) constructor
  19.                  * of JLabel class.
  20.                  */
  21.                 JLabel label1 = new JLabel(“JLabel Create Border Example.”);
  22.                 //add label to applet
  23.                 add(label1);
  24.                 /*
  25.                  * Create new custom border for JLabel
  26.                  */
  27.                 Border border = BorderFactory.createLineBorder(Color.blue);
  28.                 /*
  29.                  * To set JLabel’s border use,
  30.                  * void setBorder(Border b)
  31.                  * method.
  32.                  */
  33.                 label1.setBorder(border);
  34.         }
  35. }

 

  1. Set Vertical Alignment of JLabel Example
  2.         This java example shows how to set and get vertical alignment of label’s content using
  3.         Java Swing JLabel class.
  4. */
  5. import javax.swing.JApplet;
  6. import javax.swing.JLabel;
  7. /*
  8. <applet code=”JLabelVerticalAlignmentExample” width=200 height=200>
  9. </applet>
  10. */
  11. public class JLabelVerticalAlignmentExample extends JApplet{
  12.         public void init(){
  13.                 /*
  14.                  * To create JLabel use
  15.                  * JLabel (String caption) constructor
  16.                  * of JLabel class.
  17.                  */
  18.                 JLabel label1 = new JLabel(“JLabel Get Horizontal Alignment Example.”);
  19.                 //add label to applet
  20.                 add(label1);
  21.                 /*
  22.                  * To get vertical alignment of label’s content use,
  23.                  * int getVerticalAlignment()
  24.                  * method of JLabel’s class.
  25.                  *
  26.                  *
  27.                  * Return value is one of the following constants,
  28.                  * LEFT, CENTER, RIGHT, LEADING or TRAILING.
  29.                  *
  30.                  */
  31.                 int alignment = label1.getVerticalAlignment();
  32.                 switch(alignment){
  33.                         case JLabel.LEFT:
  34.                                 label1.setText(“Left”);
  35.                                 break;
  36.                         case JLabel.CENTER:
  37.                                 label1.setText(“Center”);
  38.                                 break;
  39.                         case JLabel.RIGHT:
  40.                                 label1.setText(“Right”);
  41.                                 break;
  42.                         case JLabel.LEADING:
  43.                                 label1.setText(“Leading”);
  44.                                 break;
  45.                         case JLabel.TRAILING:
  46.                                 label1.setText(“Trailing”);
  47.                                 break;
  48.                 }
  49.                 /*
  50.                  * To set vertical alignment of JLabel use,
  51.                  * void setVerticalAlignment(int alignment)
  52.                  * method
  53.                  */
  54.                 label1.setVerticalAlignment(JLabel.CENTER);
  55.         }
  56. }

 

  1. Show Or Hide JLabel Example
  2.         This java example shows how show or hide JLabel using
  3.         Java Swing JLabel class.
  4. */
  5. import java.awt.Color;
  6. import javax.swing.JApplet;
  7. import javax.swing.JLabel;
  8. /*
  9. <applet code=”JLabelShowHideExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class JLabelShowHideExample extends JApplet{
  13.         public void init(){
  14.                 /*
  15.                  * To create JLabel use
  16.                  * JLabel (String caption) constructor
  17.                  * of JLabel class.
  18.                  */
  19.                 JLabel label1 = new JLabel(“JLabel Show Or Hide Example.”);
  20.                 //add label to applet
  21.                 add(label1);
  22.                 /*
  23.                  * To hide the JLabel, use
  24.                  * void setVisible(boolean visible)
  25.                  * method with false argument.
  26.                  */
  27.                 label1.setVisible(false);
  28.                 /*
  29.                  * To show the JLabel again use the same method with true argument like,
  30.                  * label1.setVisible(true);
  31.                  */
  32.         }
  33. }

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

  1. /*
  2. Java String example.
  3. This Java String example describes how Java String object is created and used.
  4. */
  5. public class JavaStringExample{
  6.   public static void main(String args[]){
  7.   /*
  8.   String in java represents the character sequence.
  9.   */
  10.   /* creates new empty string */
  11.   String str1 = new String(“”);
  12.   /* creates new string object whose content would be Hello World */
  13.   String str2 = new String(“Hello world”);
  14.   /* creates new string object whose content would be Hello World */
  15.   String str3 = “Hello Wolrd”;
  16.   /*
  17.   IMPORTANT : Difference between above given two approaches is, string object
  18.   created using new operator will always return new string ojbect.
  19.   While the other may return the reference of already created string
  20.   ojbect with same content , if any.
  21.   */
  22.   System.out.println( str1.length());
  23.   }
  24. }
  25. /*
  26. OUTPUT of the above given Java String Example would be :
  27. */
  1. ·  *
  2. ·  Java substring example.
  3. ·  This Java substring example describes how substring method of java String class can
  4. ·  be used to get substring of the given java string object.
  5. ·  */
  6. ·
  7. ·  public class JavaSubstringExample{
  8. ·
  9. ·    public static void main(String args[]){
  10. ·
  11. ·    /*
  12. ·    Java String class defines two methods to get substring from the given
  13. ·    Java String object.
  14. ·
  15. ·    1) public String substring(int startIndex)
  16. ·    This method returns new String object containing the substring of the
  17. ·    given string from specified startIndex (inclusive).
  18. ·    IMPORTANT : This method can throw IndexOutOfBoundException if startIndex
  19. ·    is negative or grater than length of the string.
  20. ·
  21. ·    2) public String substring(int startIndex,int endIndex)
  22. ·    This method returns new String object containing the substring of the
  23. ·    given string from specified startIndex to endIndex. Here, startIndex is
  24. ·    inclusive while endIndex is exclusive.
  25. ·    IMPORTANT: This method can throw IndexOutOfBoundException if startIndex
  26. ·    is negative and if startIndex of endIndex is grater than the string length.
  27. ·    */
  28. ·
  29. ·    String name=”Hello World”;
  30. ·
  31. ·    /*
  32. ·    This will print the substring starting from index 6
  33. ·    */
  34. ·    System.out.println(name.substring(6));
  35. ·
  36. ·    /*
  37. ·    This will print the substring starting from index 0 upto 4 not 5.
  38. ·    IMPORTANT : Here startIndex is inclusive while endIndex is exclusive.
  39. ·    */
  40. ·    System.out.println(name.substring(0,5));
  41. ·
  42. ·    }
  43. ·
  44. ·  }
  45. ·
  46. ·  /*
  47. ·  OUTPUT of the above given Java substring Example would be :
  48. ·  World
  49. ·  Hello
  50. ·  */

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

TEXT FIELD

  1. Change Font of JTextField Example
  2.         This java example shows how to change font of JTextField’s text
  3.         using Java Swing JTextField class.
  4. */
  5. import java.awt.FlowLayout;
  6. import java.awt.Font;
  7. import javax.swing.JApplet;
  8. import javax.swing.JTextField;
  9. /*
  10. <applet code=”JTextFieldFontExample” width=200 height=200>
  11. </applet>
  12. */
  13. public class JTextFieldFontExample extends JApplet{
  14.         public void init(){
  15.                 //set flow layout for the applet
  16.                 this.getContentPane().setLayout(new FlowLayout());
  17.                 //create new JTextField
  18.                 JTextField field = new JTextField(“JTextField Change Font Example”,30);
  19.                 /*
  20.                  * To set custom font for JTextField use,
  21.                  * void setFont(Font font)
  22.                  * method.
  23.                  */
  24.                 //create new Font
  25.                 Font font = new Font(“Courier”, Font.BOLD,12);
  26.                 //set font for JTextField
  27.                 field.setFont(font);
  28.                 add(field);
  29.         }
  30. }
  1. *
  2.         Create New JTextField Example
  3.         This java example shows how to create new JTextField using
  4.         Java Swing JTextField class.
  5. */
  6. import java.awt.FlowLayout;
  7. import javax.swing.JApplet;
  8. import javax.swing.JTextField;
  9. /*
  10. <applet code=”CreateNewJTextFieldExample” width=200 height=200>
  11. </applet>
  12. */
  13. public class CreateNewJTextFieldExample extends JApplet{
  14.         public void init(){
  15.                 //set flow layout for the applet
  16.                 this.getContentPane().setLayout(new FlowLayout());
  17.                 /*
  18.                  * To create new JTextField use,
  19.                  * JTextField()
  20.                  * constructor.
  21.                  *
  22.                  * This will create new empty JTextField.
  23.                  */
  24.                 JTextField field1 = new JTextField();
  25.                 /*
  26.                  * To create new JTextField with default text, use
  27.                  * JTextField(String text)
  28.                  * constructor.
  29.                  *
  30.                  * This will create new JTextField with default text.
  31.                  */
  32.                 JTextField field2 = new JTextField(“JTextField Default Text”);
  33.                 /*
  34.                  * To create new JTextField with specified number of columns, use
  35.                  * JTextField(int columns)
  36.                  * constructor.
  37.                  *
  38.                  * This will create new empty JTextField with specified number of
  39.                  * columns.
  40.                  */
  41.                 JTextField field3 = new JTextField(10);
  42.                 /*
  43.                  * To create new JTextField with default text and columns use
  44.                  * JTextField(String text, int columns)
  45.                  * constructor.
  46.                  *
  47.                  * This will create new JTextField with default text and specified
  48.                  * number of columns.
  49.                  */
  50.                 JTextField field4 = new JTextField(“JTextField Default Text”, 20);
  51.                 /*
  52.                  * Add text field to the applet
  53.                  */
  54.                 add(field1);
  55.                 add(field2);
  56.                 add(field3);
  57.                 add(field4);
  58.         }
  59. }
  1. Create Read Only JTextField Example
  2.         This java example shows how to make JTextField read only or non editable
  3.         using Java Swing JTextField class.
  4. */
  5. import java.awt.FlowLayout;
  6. import javax.swing.JApplet;
  7. import javax.swing.JTextField;
  8. /*
  9. <applet code=”CreateReadOnlyJTextFieldExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class CreateReadOnlyJTextFieldExample extends JApplet{
  13.         public void init(){
  14.                 //set flow layout for the applet
  15.                 this.getContentPane().setLayout(new FlowLayout());
  16.                 //create new JTextField
  17.                 JTextField field = new JTextField(“Read Only JTextField Example”);
  18.                 /*
  19.                  * To make JTextField read only or non editable use,
  20.                  * void setEditable(boolean editable)
  21.                  * method with false argument.
  22.                  */
  23.                 field.setEditable(false);
  24.                 /*
  25.                  * To make the JTextField editable, use
  26.                  * void seEditable(boolean editable)
  27.                  * with true argument.
  28.                  */
  29.                 //field.setEditable(true);
  30.                 add(field);
  31.         }
  32. }
  1.   Get Current Caret Position in JTextField Example
  2.         This java example shows how to get current position of caret in JTextField
  3.         using Java Swing JTextField class.
  4. */
  5. import java.awt.FlowLayout;
  6. import javax.swing.JApplet;
  7. import javax.swing.JTextField;
  8. import javax.swing.event.CaretEvent;
  9. import javax.swing.event.CaretListener;
  10. /*
  11. <applet code=”GetCaretPositionInJTextFieldExample” width=200 height=200>
  12. </applet>
  13. */
  14. /*
  15.  * Implement CaretListener in order to listen for caret position
  16.  * change event.
  17.  */
  18. public class GetCaretPositionInJTextFieldExample extends JApplet implements CaretListener{
  19.         public void init(){
  20.                 //set flow layout for the applet
  21.                 this.getContentPane().setLayout(new FlowLayout());
  22.                 //create new JTextField
  23.                 JTextField field = new JTextField(“JTextField Caret Position Example”);
  24.                 add(field);
  25.                 //add CaretListener in order to listen for caret position changes
  26.                 field.addCaretListener(this);
  27.         }
  28.         //override caretUpdate event to capture caret position changes
  29.         public void caretUpdate(CaretEvent e) {
  30.                 /*
  31.                  * To get the current position of caret use,
  32.                  * int getDot()
  33.                  * method of CaretEvent class.
  34.                  */
  35.                 int position = e.getDot();
  36.                 //show current position in the status bar of an applet
  37.                 getAppletContext().showStatus(“Caret Position :” + position);
  38.         }
  39. }
  1.   Get X and Y Coordinates of JTextField Example
  2.         This java example shows how to get X and Y coordinates of JTextField
  3.         using Java Swing JTextField class.
  4. */
  5. import java.awt.FlowLayout;
  6. import javax.swing.JApplet;
  7. import javax.swing.JLabel;
  8. import javax.swing.JTextField;
  9. /*
  10. <applet code=”JTextFieldGetXYCoordinatesExample” width=200 height=200>
  11. </applet>
  12. */
  13. public class JTextFieldGetXYCoordinatesExample extends JApplet{
  14.         public void init(){
  15.                 //set flow layout for the applet
  16.                 this.getContentPane().setLayout(new FlowLayout());
  17.                 //create new JTextField
  18.                 JTextField field = new JTextField(“JTextField X Y Coordinates Example”,20);
  19.                 /*
  20.                  * To get X coordinate of JTextField use,
  21.                  * int getX()
  22.                  * method.
  23.                  *
  24.                  * To get Y coordinate of JTextField use,
  25.                  * int getY()
  26.                  * method.
  27.                  */
  28.                 int x = field.getX();
  29.                 int y = field.getY();
  30.         }
  31. }
  1.   Create New JTextField Example
  2.         This java example shows how to create new JTextField using
  3.         Java Swing JTextField class.
  4. */
  5. import java.awt.FlowLayout;
  6. import javax.swing.JApplet;
  7. import javax.swing.JTextField;
  8. /*
  9. <applet code=”CreateNewJTextFieldExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class CreateNewJTextFieldExample extends JApplet{
  13.         public void init(){
  14.                 //set flow layout for the applet
  15.                 this.getContentPane().setLayout(new FlowLayout());
  16.                 /*
  17.                  * To create new JTextField use,
  18.                  * JTextField()
  19.                  * constructor.
  20.                  *
  21.                  * This will create new empty JTextField.
  22.                  */
  23.                 JTextField field1 = new JTextField();
  24.                 /*
  25.                  * To create new JTextField with default text, use
  26.                  * JTextField(String text)
  27.                  * constructor.
  28.                  *
  29.                  * This will create new JTextField with default text.
  30.                  */
  31.                 JTextField field2 = new JTextField(“JTextField Default Text”);
  32.                 /*
  33.                  * To create new JTextField with specified number of columns, use
  34.                  * JTextField(int columns)
  35.                  * constructor.
  36.                  *
  37.                  * This will create new empty JTextField with specified number of
  38.                  * columns.
  39.                  */
  40.                 JTextField field3 = new JTextField(10);
  41.                 /*
  42.                  * To create new JTextField with default text and columns use
  43.                  * JTextField(String text, int columns)
  44.                  * constructor.
  45.                  *
  46.                  * This will create new JTextField with default text and specified
  47.                  * number of columns.
  48.                  */
  49.                 JTextField field4 = new JTextField(“JTextField Default Text”, 20);
  50.                 /*
  51.                  * Add text field to the applet
  52.                  */
  53.                 add(field1);
  54.                 add(field2);
  55.                 add(field3);
  56.                 add(field4);
  57.         }
  58. }

 

  1. JTextField Disable Enable Example
  2.         This java example shows how to enable or disable JTextField
  3.         using Java Swing JTextField class.
  4. */
  5. import java.awt.FlowLayout;
  6. import javax.swing.JApplet;
  7. import javax.swing.JTextField;
  8. /*
  9. <applet code=”JTextFieldDisableExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class JTextFieldDisableExample extends JApplet{
  13.         public void init(){
  14.                 //set flow layout for the applet
  15.                 this.getContentPane().setLayout(new FlowLayout());
  16.                 //create new JTextField
  17.                 JTextField field = new JTextField(“JTextField Disable Enable Example”,20);
  18.                 /*
  19.                  * To disable JTextField use
  20.                  * void setEnabled(boolean enabled)
  21.                  * method with false argument.
  22.                  */
  23.                 field.setEnabled(false);
  24.                 /*
  25.                  * To set the disabled JTextField enable, use the same method
  26.                  * with the true argument.
  27.                  */
  28.                 //field.setEnabled(true);
  29.                 add(field);
  30.         }
  31. }
  1.   JTextField Horizontal Alignment Example
  2.         This java example shows how to get or set horizontal alignment of
  3.         JTextField’s text using Java Swing JTextField class.
  4. */
  5. import java.awt.FlowLayout;
  6. import javax.swing.JApplet;
  7. import javax.swing.JTextField;
  8. /*
  9. <applet code=”JTextFieldHorizontalAlignmentExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class JTextFieldHorizontalAlignmentExample extends JApplet{
  13.         public void init(){
  14.                 //set flow layout for the applet
  15.                 this.getContentPane().setLayout(new FlowLayout());
  16.                 //create new JTextField
  17.                 JTextField field = new JTextField(“JTextField Horizontal Alignment Example”, 10);
  18.                 /*
  19.                  * To get horizontal alignment of JTextBox’s text use,
  20.                  * int getHorizontalAlignment()
  21.                  * method of JTextField class.
  22.                  *
  23.                  * Return value is one of the following values,
  24.                  * JTextField.LEFT, JTextField.CENTER, JTextField.RIGHT
  25.                  * JTextField.LEADING, Or JTextField.TRAILING
  26.                  */
  27.                 int horizontalAlignment = field.getHorizontalAlignment();
  28.                 switch(horizontalAlignment){
  29.                         case JTextField.LEFT:
  30.                                 field.setText(“Left”);
  31.                                 break;
  32.                         case JTextField.RIGHT:
  33.                                 field.setText(“Right”);
  34.                                 break;
  35.                         case JTextField.CENTER:
  36.                                 field.setText(“Center”);
  37.                                 break;
  38.                         case JTextField.LEADING:
  39.                                 field.setText(“Leading”);
  40.                                 break;
  41.                         case JTextField.TRAILING:
  42.                                 field.setText(“Trailing”);
  43.                                 break;
  44.                 }
  45.                 /*
  46.                  * To set horizontal alignment of JTextField’s text use,
  47.                  * void setHorizontalAlignment(int alignment)
  48.                  * method of JTextField class.
  49.                  */
  50.                 //field.setHorizontalAlignment(JTextField.CENTER);
  51.                 add(field);
  52.         }
  53. }
  1. JTextField Show Hide Example
  2.         This java example shows how to show or hide JTextField
  3.         using Java Swing JTextField class.
  4. */
  5. import java.awt.FlowLayout;
  6. import javax.swing.JApplet;
  7. import javax.swing.JTextField;
  8. /*
  9. <applet code=”JTextFieldShowHideExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class JTextFieldShowHideExample extends JApplet{
  13.         public void init(){
  14.                 //set flow layout for the applet
  15.                 this.getContentPane().setLayout(new FlowLayout());
  16.                 //create new JTextField
  17.                 JTextField field = new JTextField(“JTextField Show Hide Example”, 10);
  18.                 /*
  19.                  * To hide JTextField use
  20.                  * void setVisible(boolean visible)
  21.                  * method with false argument.
  22.                  */
  23.                 field.setVisible(false);
  24.                 /*
  25.                  * To set the hidden JTextField visible, use the same method
  26.                  * with the true argument.
  27.                  */
  28.                 //field.setVisible(true);
  29.                 add(field);
  30.         }
  31. }
  1. JTextField Show Hide Example
  2.         This java example shows how to show or hide JTextField
  3.         using Java Swing JTextField class.
  4. */
  5. import java.awt.FlowLayout;
  6. import javax.swing.JApplet;
  7. import javax.swing.JTextField;
  8. /*
  9. <applet code=”JTextFieldShowHideExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class JTextFieldShowHideExample extends JApplet{
  13.         public void init(){
  14.                 //set flow layout for the applet
  15.                 this.getContentPane().setLayout(new FlowLayout());
  16.                 //create new JTextField
  17.                 JTextField field = new JTextField(“JTextField Show Hide Example”, 10);
  18.                 /*
  19.                  * To hide JTextField use
  20.                  * void setVisible(boolean visible)
  21.                  * method with false argument.
  22.                  */
  23.                 field.setVisible(false);
  24.                 /*
  25.                  * To set the hidden JTextField visible, use the same method
  26.                  * with the true argument.
  27.                  */
  28.                 //field.setVisible(true);
  29.                 add(field);
  30.         }
  31. }
  1.   JTextField ToolTip Example
  2.         This java example shows how to set of get ToolTip for JTextField
  3.         using Java Swing JTextField class.
  4. */
  5. import java.awt.FlowLayout;
  6. import javax.swing.JApplet;
  7. import javax.swing.JTextField;
  8. /*
  9. <applet code=”JTextFieldTooltipExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class JTextFieldTooltipExample extends JApplet{
  13.         public void init(){
  14.                 //set flow layout for the applet
  15.                 this.getContentPane().setLayout(new FlowLayout());
  16.                 //create new JTextField
  17.                 JTextField field = new JTextField(“JTextField ToolTip Example”,20);
  18.                 /*
  19.                  * To set JTextField’s ToolTip use
  20.                  * void setToolTipText(String toolTip)
  21.                  * method.
  22.                  */
  23.                 field.setToolTipText(“This is JTextField’s ToolTip”);
  24.                 /*
  25.                  * To get the ToolTip of JTextField , use
  26.                  * String getToolTipText()
  27.                  * method of JTextField class.
  28.                  */
  29.                 String toolTip = field.getToolTipText();
  30.                 add(field);
  31.         }
  32. }
  1. This java example shows how to set background color of JTextField
  2.         using Java Swing JTextField class.
  3. */
  4. import java.awt.Color;
  5. import java.awt.FlowLayout;
  6. import javax.swing.JApplet;
  7. import javax.swing.JTextField;
  8. /*
  9. <applet code=”JTextFieldBackgroundColorExample” width=200 height=200>
  10. </applet>
  11. */
  12. public class JTextFieldBackgroundColorExample extends JApplet{
  13.         public void init(){
  14.                 //set flow layout for the applet
  15.                 this.getContentPane().setLayout(new FlowLayout());
  16.                 //create new JTextField
  17.                 JTextField field = new JTextField(“JTextField Background Color Example”,20);
  18.                 //create new custom color
  19.                 Color color = Color.GRAY;
  20.                 /*
  21.                  * To set background color of JTextField’s text use,
  22.                  * void setBackground(Color color)
  23.                  * method of JTextField class.
  24.                  */
  25.                 field.setBackground(color);
  26.                 add(field);
  27.         }
  28. }
  1. Set Foreground Color of JTextField Example
  2.         This java example shows how to set foreground color of JTextField’s text
  3.         using Java Swing JTextField class.
  4. */
  5. import java.awt.Color;
  6. import java.awt.FlowLayout;
  7. import javax.swing.JApplet;
  8. import javax.swing.JTextField;
  9. /*
  10. <applet code=”JTextFieldForegroundColorExample” width=200 height=200>
  11. </applet>
  12. */
  13. public class JTextFieldForegroundColorExample extends JApplet{
  14.         public void init(){
  15.                 //set flow layout for the applet
  16.                 this.getContentPane().setLayout(new FlowLayout());
  17.                 //create new JTextField
  18.                 JTextField field = new JTextField(“JTextField Foreground Color Example”,20);
  19.                 //create new custom color
  20.                 Color color = Color.RED;
  21.                 /*
  22.                  * To set foreground color of JTextField’s text use,
  23.                  * void setForeground(Color color)
  24.                  * method of JTextField class.
  25.                  */
  26.                 field.setForeground(color);
  27.                 add(field);
  28.         }
  29. }
  1.   Set JTextField Border Example
  2.         This java example shows how to create a border for JTextField using
  3.         Java Swing JTextField class.
  4. */
  5. import java.awt.Color;
  6. import java.awt.FlowLayout;
  7. import javax.swing.BorderFactory;
  8. import javax.swing.JApplet;
  9. import javax.swing.JLabel;
  10. import javax.swing.JTextField;
  11. import javax.swing.border.Border;
  12. /*
  13. <applet code=”JTextFieldSetBorderExample” width=200 height=200>
  14. </applet>
  15. */
  16. public class JTextFieldSetBorderExample extends JApplet{
  17.         public void init(){
  18.                 //set flow layout for the applet
  19.                 this.getContentPane().setLayout(new FlowLayout());
  20.                 //create new JTextField
  21.                 JTextField field = new JTextField(“JTextField Border Example”,20);
  22.                 /*
  23.                  * Create new custom border for JTextField
  24.                  */
  25.                 Border border = BorderFactory.createLineBorder(Color.red);
  26.                 /*
  27.                  * To set JTextField’s border use,
  28.                  * void setBorder(Border b)
  29.                  * method.
  30.                  */
  31.                 field.setBorder(border);
  32.                 add(field);
  33.         }
  34. }

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

 

 

 

Let us now develop a few applications which will help us to strengthen our programming concepts learnt in class XI.

 

Let us now design an application in which we will generate the series and its sum. Design the application as shown in figure 3.30. Set the relevant properties of the components.

 

Series and its Sum 1+2+3+4 2+4+6+8+10 2+7+12+17+22

 

Sum of Series Calculator

 

Let us now write the code as follows:

 

 

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)

 

{

 

int Start,Step,Terms,Sum=0; Start=Integer.parseInt(jTextField1.getText());

//Start point of series

 

 

 

Step =jComboBox1.getSelectedIndex()+1;

 

//step in the series Terms=Integer.parseInt(jTextField2.getText());

// no of terms for (int I=1;I<=Terms;I++)

{

 

Sum+=Start; Start+=Step;

}

 

jTextField3.setText(Integer.toString(Sum));

 

}

 

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)

{

 

jTextField1.setText(“”); jTextField2.setText(“”); jTextField3.setText(“”);

//Index -1 indicates no selection jComboBox1.setSelectedIndex(-1);

}

 

Figure 3.31 Code to generate the series and the Sum of Series

 

Let us now understand the code in detail.

 

Integer.parseInt(jTextField1.getText())

 

  • retrieves the value entered by the user in the text field using getText().This value by default is treated as a string and not as a number so it needs to be converted to an integer type and this is achieved using the parseInt() method.

The value is then stored in the variable Start.

 

jComboBox.getSelectedIndex()+1

 

  • retrieves the index of the selected item so if the user selects 1st item as Step then 1 is added to the index value of the 1st item. This value is saved in a

variable Step.

 

Integer.parseInt(jTextField1.getText())

 

  • retrieves the value entered by the user in the text field using getText().This value by default is treated as a string and not as a number so it needs to be converted  to an integer type and this is achieved  using  the  parseInt()

method.The value is then stored in the variable Terms.

 

Now we have the value from where the user wants to start the series, the terms in the series and the step between numbers of the series.

for (int I=1;I<=Terms;I++)

 

{

 

Sum+=Start; Start+=Step;

}

 

jTextField3.setText(Integer.toString(Sum));

 

  • the for loop is executed as many times as the Terms and the Step is added to Start which in turn is added to Sum and finally the Sum of the numbers is

displayed.

jTextField1.setText(“”); jTextField2.setText(“”); jTextField3.setText(“”); jComboBox1.setSelectedIndex(-1);

 

  • On clicking the reset button all the three textfields are set to “” and the setselectedIndex value of combobox is set to -1. Index -1 indicates that no item

is selected.

 

 

Let us now develop an application to reverse the given number and also find out whether the number is a palindrome or not.(The pattern that we found in the phrases was that each line had a palindrome hidden in it.)

 

Let us now write the code for reversing a given number and check whether the given number is a palindrome or not.

//Reverse Number Program with Palindrome Check private void

jButton1ActionPerformed(java.awt.event.ActionEvent evt)

 

{

long Number,Temp,RevNumber=0; Number=Long.parseLong(jTextField1.getText()); Temp=Number;

 

 

while (Temp>0) // till temp > 0 continue to perform the loop

 

{

 

RevNumber=(RevNumber*10)+(Temp%10);

 

// RevNumber is multiplied by 10 and added to the

 

// remainder of temp divided by 100

 

Temp=Temp/10;

 

} jTextField2.setText(Long.toString(RevNumber)); if (Number==RevNumber)

JOptionPane.showMessageDialog

 

(this,”Number is Palindrome”); else

JOptionPane.showMessageDialog

 

(this,”Number is not a Palindrome”);

 

}

 

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)

 

{

 

jTextField1.setText(“”); jTextField2.setText(“”);

}

Let us now understand the code in detail :

 

Long.parseLong(jTextField1.getText())

 

  • retrieves the value entered by the user in the text field using getText().This value by default is treated as a string and not as a number so it needs to be converted to long type and this is achieved using the parsetLog() method. The

value is then stored in the variable Number.

 

Temp=Number

 

  • the number is stored in another variable temp.

 

while (Temp>0)

 

{

 

RevNumber=(RevNumber*10)+(Temp%10); Temp=Temp/10;

}

 

  • while loop will continue as long as temp is greater than zero. In this loop we divide temp by 10 and obtain the remainder. The remainder is then added to the value in the variable RevNumber multiplied by 10.Initially RevNumber=0.The value of variable temp is divided by 10 every time the loop

is executed. The loop is executed as long as temp is greater than 0.

 

if (Number==RevNumber) JOptionPane.showMessageDialog

(this,”Number is Palindrome”);

 

else

 

JOptionPane.showMessageDialog

 

(this,”Number is not Palindrome”);

 

  • If the reverse of the number, which is stored in variable RevNumber and the number entered by the user which is stored in Number are the same then the

number is a palindrome otherwise it is not a palindrome.

 

We have revised the concepts learnt in class XI. Now in the next few chapters we will enhance our knowledge of NetBeans and delve further into programming concepts.

 

Summary

 

  • NetBeans is an IDE using which we can develop GUI applications in Java.

 

  • NetBeans  provides  various  components  used  to  create  a  GUI  front-end interface.

 

  • GUI components’ appearance and behaviour is controlled by their properties and methods.

 

  • We should use meaningful names for controls on the form and variables in the code. It makes programming convenient.

 

  • Some useful Data Types supported in Java are: int, double, char and boolean.

 

  • String is an Object (reference) type supported in Java.

 

  • A variable must be declared before it can be used.

 

  • Different types of operators are available in Java. Operators are used to perform various operations on data.
  • Control Statements available in java are: if..else, switch..case, for, while, do..while.

 

EXERCISES

 

MULTIPLE CHOICE QUESTIONS

 

  1. What will be the output of the program given below. Which number is printed twice?

 

int sum1 = 3; sum1++; jTextField1.setText(“”+sum1);

++sum1; jTextField2.setText(“”+sum1);

jTextField3.setText(“”+(++sum1));

 

jTextField4.setText(“”+sum1++); jTextField5.setText(“”+sum1);

  1. 5                                          b.       6

 

c.    4                                          d.       7

 

  1. Consider the following code snippet :

 

int anumber=14;

 

if (anumber >=10){ if (anumber == 10) jLabel1.setText(“first string”);

else jLabel1.setText(“second string”); jLabel2.setText(“third string”);

What will be the output when anumber=14

 

  1. first string                             b.       second string

 

c.    first string                             d.       second string third string          third string

  1. What value for X above will print EXACTLY 20 lines to standard output :

 

int count = 0; while(count++ < X ) { jTextField1.setText(“Line ” + count);

}

 

  1. 0                                          b.       5

 

c.    10                                        d.       11

 

  1. What will be the value of total after the loop finishes execution.

int total = 0; // must be initialized before the for (int count = 5; count <=10; count++ )

 

{

 

total += count;

 

}

 

jTextField1.setText(“The total is ” + total);

 

  1. 10                                                   b.      16

 

c.    45                                                   d.      36

 

  1. What’s wrong with the while statement?

 

while( (ctr < 5) && (ctr > 30))

 

a            the logical operator && cannot be used in a test condition.

 

b            the while loop is an exit-condition loop.

 

c            the test condition is always false.

 

d            the test condition is always true.

 

  1. If there is more than one statement in the block of a for loop, which of the following must be placed at the beginning and the ending of the loop block?

 

a       parentheses ()                                b        French curly braces { } c   brackets [ ]   d         arrows < >

  1. Given the following information: int a = 11;

int b = 22; int c = 33; int d = 11;

Which of the following statements are true :

 

i)     a = = b                         ii)      b != d                     iii)     c <= b

 

iv)   a < c                            v)       a = = d                    vi)      c > a

 

vii) a >= c

 

a     i),iv) & vii)                                      b        ii),iv), v) & vi)

 

c     ii),iv), vi) & vii)                               d        iii),v),vi) & vii)

 

  1. The statement i++; is equivalent to

a     i = i + i;                                           b        i = i + 1; c  i = i – 1; d        i – – ;

 

ANSWER THE FOLLOWING QUESTIONS

 

  1. Explain the following terms:

 

a)       IDE

 

b)       Inspector Window

 

c)       Form

 

  1. Differentiate between :

 

a)       TextField and TextArea

 

b)       ComboBox and ListBox

 

c)       getText() and setText()

 

  1. What is the significance of the following properties in TextArea ?

 

LineWrap          WrapStyleWord

 

  1. What are list type controls used for ?

 

  1. How would you determine whether a combo box is editable or not ?

 

  1. List different selection modes of a list.

 

  1. What is a button group? Which control is generally used with a buttongroup.

 

  1. Write and explain two methods each of check box and radio button.

 

 

 

UI

 

LAB EXERCISES

 

  1. Design a GUI application in which the user enters a number in the text field and on clicking the button the sum of the digits of the number should be displayed in a label.

 

Hint : Suppose user enters 123 the output should be 6(1+2+3).

 

  1. Design a GUI application to accept a String from the user in a text field and print using option pane whether it is a palindrome or not.

 

Hint ABBA is a palindrome.

 

  1. Design a GUI application to accept the cost price and selling price form the user in two text fields then calculate the profit or loss incurred.

 

  1. Design a GUI application to accept a  character in a text field and print in a label if that character is a vowel: a, e, i, o, or u. The application should be case sensitive.

 

  1. Design a GUI application that repeatedly accepts numbers in a option pane and once the typed number is 0 the maximum and minimum of all numbers typed are displayed.

 

  1. Design a GUI application in java to convert temperature from Celsius to Fahrenheit or vice versa using radio buttons and two text fields

 

  1. Design a GUI application in java to convert kilograms into grams, litres into milliliters, rupees into paisa using combobox and text fields.

 

  1. A book publishing house decided to go in for computerization. The database will be maintained at the back end but you have to design the front end for the company. You have to accept book code, Title, Author and Quantity sold from the user. The Price will be generated depending upon the book code. Net price should be calculated on the basis of the discount given.

 

Bookseller – 25% School     – 20%

Customer  – 5%A networking company decided to computerize its employee salary . Develop an application to store employee’s personal data which will be saved in the back end. The front end should accept Name, Father’s Name, Mother’s Name, Address, Gender,

Basic Salary, Medical and Conveyance. Calculate gross and net salary.

 

Basic

DA

HRA
 

>=40000

 

35%

 

37%

 

>=20000

 

25%

 

32%

 

>=10000

 

25%

 

30%

 

TEAM BASED TIME BOUND EXERCISE

(Team size  recommended : 3 students in each team)

  1. Students will visualize the details that have to be provided while creating a member registration for an e-reservation site. Each team has to design a layout for the form. The form has to be designed using NetBeans IDE. The team has to specify the following:

 

  • Controls that will be used to develop the application.

 

  • Data types of variables to be used.

 

  • Validations to be performed while accepting the data.

 

  1. Students will visualize the details that have to be provided while developing a domicile certificate for a student of class XII. Each team has to design the form using

NetBeans IDE. The team has to specify the following:

 

  • Controls that will be used to develop the application

 

  • Data types of variables to be used.

 

  • Validations to be performed while accepting the data.

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

 

Highlights of NetBeans IDE 7.2 Keyboard Shortcuts & Code Templates

Finding, Searching, and Replacing

Ctrl-F3                                                              Search word at insert point

F3/Shift-F3                                                        Find next/previous in file

Ctrl-F/H                                                             Find/Replace in file

Alt-F7                                                               Find usages

Ctrl-Shift-F/H                                                     Find/replace in projects

Alt-Shift-U                                                         Find usages results

Alt-Shift-H                                                         Turn off search result highlights

Ctrl-R                                                                Rename

Ctrl-U, then U                                                    Convert selection to uppercase

Ctrl-U, then L                                                     Convert selection to lowercase

Ctrl-U, then S                                                    Toggle case of selection

Ctrl-Shift-V                                                        Paste formatted

Ctrl-I                                                                 Jump to quick search field

Navigating through Source Code

Ctrl-O/Alt-Shift-O                                               Go to type/file

Ctrl-Shift-T                                                        Go to JUnit test

Alt-O                                                                 Go to source

Ctrl-B                                                                Go to declaration

Ctrl-G                                                                Go to line

Ctrl-Shift-M                                                       Toggle add/remove bookmark

Ctrl-Shift-Period /Comma                                   Next/previous bookmark

Ctrl-Period /Comma                                           Next/previous usage/compile error

Alt-Shift-Period /Comma                                    Select next/previous element

Ctrl-Shift-1/2/3                                                   Select in Projects/Files/Favorites

Ctrl-[                                                                 Move caret to matching bracket

Ctrl-K/Ctrl-Shift K                                               Next/previous word match

Alt-Left/Alt-Right/Ctrl-Q                                      Go backward/forward/to last edit

Alt Up / Down                                                   Next/previous marked occurrence

Coding in C/C++

Alt-Shift-C                                                         Go to declaration

Ctrl-F9                                                              Evaluate expression

Coding in Java

Alt-Insert                                                           Generate code

Ctrl-Shift-I                                                         Fix all class imports

Alt-Shift-I                                                          Fix selected class’s import

Alt-Shift-F                                                         Format selection

Alt-Shift Left/Right/Up/Down                              Shift lines left/right/up/down

Ctrl-Shift-R                                                        Rectangular Selection (Toggle)

Ctrl-Shift-Up/D                                                  Copy lines up/down

Ctrl/Alt-F12                                                        Inspect members/hierarchy

Ctrl-/                                                                 Add/remove comment lines

Ctrl-E                                                                Delete current line

Compiling, Testing, and Running

F9                                                                    Compile package/ file

F11                                                                   Build main project

Shift-F11                                                           Clean & build main project

Ctrl-Q                                                                Set request parameters

Ctrl-Shift-U                                                        Create Unit test

Ctrl-F6/Alt-F6                                                     Run Unit test on file/project

F6/Shift-F6 Run main project/file

Opening and Toggling between Views

Ctrl-Tab (Ctrl-`)                                                   Switch between open documents by order used

Shift-Escape                                                     Maximize window (toggle)

Ctrl-F4/Ctrl-W                                                    Close selected window

Ctrl-Shift-F4                                                      Close all windows

Shift-F10                                                           Open contextual menu

Ctrl-PgUp /PgDown                                           Switch between open documents by order of tabs

Ctrl-Alt-PgUp /PgDown                                      Toggle between editor types

Alt-Mouse Wheel Up / Down                              Zoom text in / out

Debugging

Ctrl-F5                                                              Start debugging main project

Ctrl-Shift-F5                                                      Start debugging current file

Ctrl-Shift-F6                                                      Start debugging test for file

Shift-F5/F5                                                        Stop/Continue debugging session

F4                                                                    Run to cursor location in file

F7/F8                                                                Step into/over

Ctrl-F7                                                              Step out

Ctrl-Alt-Up                                                         Go to called method

Ctrl-Alt-Down                                                     Go to calling method

Ctrl-F9                                                              Evaluate expression

Ctrl-F8                                                              Toggle breakpoint

Ctrl-Shift-F8                                                      New breakpoint

Ctrl-Shift-F7                                                      New watch

 

When typing in the Source Editor, generate the text in the right-column below by typing the abbreviation that is listed in the left-column and then pressing Tab.

Java Editor Code Templates

En                                                                                           Enumeration

Ex                                                                                           Exception

Ob                                                                                           Object

Psf                                                                                          public static final

Psfb                                                                                        public static final boolean

Psfi                                                                                         public static final int

Psfs                                                                                        public static final String

St                                                                                            String

ab                                                                                           abstract

as                                                                                            assert true;

bcom                                                                                      /**/

bo                                                                                           boolean

br                                                                                            break;

ca                                                                                            catch (

 

 

Highlights of NetBeans IDE 7.2 Keyboard Shortcuts & Code Templates

cl                                                                                             class

cn                                                                                            continue

db                                                                                           double

df                                                                                            default:

dowhile                                                                                  do {

} while (condition);

eq                                                                                           equals

ex                                                                                            extends

fa                                                                                            false

fcom                                                                                       // <editor-fold></editor-fold>

fi                                                                                              final

fl                                                                                              float

forc                                                                                         for (Iterator it = collection.iterator();

it.hasNext();) {

                                                                                                Object elem = (Object) it.next();

}

fore                                                                                         for (Object elem : iterable) {

}

fori                                                                                          for (int i = 0; i < arr.length; i++) {}

forl                                                                                          for (int i = 0; i < lst.size(); i++) {

Object object = lst.get(i); }

forst                                                                                        for (StringTokenizer st = new StringTokenizer(“”);

st.hasMoreTokens();) }

forv                                                                                         for (int i = 0; i < vct.size(); i++) {

                                                                                                Object object = vct.elementAt(i);}

fy                                                                                             finally{ |}

ie                                                                                             interface

ifelse                                                                                      if (condition){}else {

}

iff                                                                                            if (exp) {}

im                                                                                           implements

inst                                                                                          if (exp instanceof Object) {

                                                                                                Object obj = (Object) exp;

iof                                                                                           instanceof

ir                                                                                              import

le                                                                                             length

na                                                                                           native

newo                                                                                      Object name = new Object(args);

pe                                                                                           protected

pr                                                                                            private

psf                                                                                          private static final

psfb                                                                                        private static final boolean

psfi                                                                                         private static final int

psfs                                                                                        private static final String

pst                                                                                           printStackTrace();

psvm                                                                                      public static void main(String[] args){

}

pu                                                                                           public

re                                                                                            return

runn                                                                                        Runnable runnable = new Runnable() {

public void run() {}};

serr                                                                                         System.err.println (“|”);

sh                                                                                            short

sout                                                                                        System.out.println (“|”);

soutv                                                                                      System.out.println(“Object = ” + Object);

st                                                                                             static

su                                                                                            super

sw                                                                                           switch (var) { case val: break;

default: throw new AssertionError();}

sy                                                                                            synchronized

tds                                                                                           Thread.dumpStack();

th                                                                                             throws

tr                                                                                              transient

trycatch                                                                                  try {}

catch (Exception e) {}

tw                                                                                            throw

twn                                                                                          throw new

vo                                                                                            volatile

wh                                                                                           while (

whileit                                                                                    while (it.hasNext()) {

                                                                                                Object elem = (Object) it.next();}

whilen                                                                                    while (en.hasMoreElements()) {

                                                                                                Object elem = (Object) en.nextElement();}

whilexp                                                                                  while (exp) {}

JSP Editor Code Templates

ag                                                                                           application.getAttribute(“|”)

ap                                                                                           application.putAttribute(“|”,)

ar                                                                                            application.removeAttribute(“|”)

cfgi                                                                                         config.getInitParameter(“|”)

jspf                                                                                         <jsp:forward page=”|”/>

jspg                                                                                        <jsp:getProperty name=”|”

property=”” />

jspi                                                                                          <jsp:include page=”|”/>

jspp                                                                                        <jsp:plugin type=”|” code=””

codebase=””></jsp:plugin>

jsps                                                                                         <jsp:setProperty name=”|” property=””/>

jspu                                                                                        <jsp:useBean id=”I” type=””/>

oup out.print(“|”)

oupl out.println(“|”)

pcg                                                                                         pageContext.getAttribute(“|”)

pcgn                                                                                       pageContext.getAttributeNamesInScope(“|”)

pcgs                                                                                       pageContext.getAttributesScope(“|”)

pcr                                                                                          pageContext.removeAttribute(“|”)

pcs                                                                                          pageContext.setAttribute(“|”,)

pg                                                                                           <%@page |%>

pga                                                                                         <%@page autoFlush=”false”%>

pgb                                                                                         <%@page buffer=”|kb”%>

pgc                                                                                         <%@page contentType=”|”%>

pgerr                                                                                      <%@page errorPage=”|”%>

pgex                                                                                       <%@page extends=”|”%>

pgie                                                                                        <%@page isErrorPage=”true”%>

pgim                                                                                       <%@page import=”|”%>

pgin                                                                                        <%@page info=”|”%>

pgit                                                                                         <%@page isThreadSafe=”false”%>

pgl                                                                                          <%@page language=”java”%>

pgs                                                                                         <%@page session=”false”%>

rg                                                                                            request.getParameter(“|”)

sg                                                                                            session.getAttribute(“|”)

sp                                                                                            session.setAttribute(“|”, )

sr                                                                                             session.removeAttribute(“|”)

tglb                                                                                         <%@taglib uri=”|”%>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s