0% found this document useful (0 votes)
243 views

Copa Notes

Uploaded by

Poonam Lathwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
243 views

Copa Notes

Uploaded by

Poonam Lathwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 330

Trade Theory for

Computer Operator and


Programming Assistant
(as per July 2022 DGT syllabus)

Dr.V.Nagaradjane
Email: [email protected]
COPA 2 Dr.V.Nagaradjane
Dedicated to the fire of knowl-
edge which destroys the filth of ig-
norance.

COPA i Dr.V.Nagaradjane
Preface
This book covers the syllabus prescribed by the Directorate General
of Training (DGT) for the trade of Computer Operator and Program-
ming Assistant (COPA) vide its July 2022 revision. DGT is the apex
body for industrial training in India and functions under the Ministry
of Skill Development and Entrepreneurship (MSDE).
This syllabus has significant new additions to its content, in the
form of Python programming language and introductory level Java,
either of whih can be chosen as optional subject.
Python is an easy to use scripting language, which can be used
for developing desktop applications and web pages with server side
scripting. Main advantage of Python is that there is a huge wealth of
libraries available for many complex programming tasks. The knowl-
edge of Python introduced in this syllabus will help the students to
acquire more specialization in the language as and when required.
The optional portion of Java programming language is a strong
point of the syllabus. The portions provided in the syllabus cover
basic concepts of Java and help to program using core Java. The
concepts of Object Oriented Programming System introduced in this
book will help the students to learn any modern programming lan-
guage in the future. Students will it easy to learnin advanced level
Java programming with the help of the foundation provided herein.
The flow of the book follows the flow of the syllabus starting from
harware level and moving to productivity features like MS Office and
Open Office. HTML and Javascript were available in the syllabus for
a long time and continue to remain as its component. Javascript is
helpful for client side scripting. Nowadays, HTML/ Javascript have
become the tools for developing apps for Android and iOS devices.
May the students find this book useful for their preparation to
appear in their exams. In case of any suggestions, kindly write to:
[email protected].

COPA ii Dr.V.Nagaradjane
Contents

1 Basics of computer 1
1.1 Safe working practices . . . . . . . . . . . . . . . . 1
1.2 Safety Rules . . . . . . . . . . . . . . . . . . . . . 2
1.3 Job opportunities . . . . . . . . . . . . . . . . . . . 2
1.4 Safety symbols . . . . . . . . . . . . . . . . . . . . 4
1.5 Types of fire and extiguishers . . . . . . . . . . . . 4
1.6 Types of fire extinguisher . . . . . . . . . . . . . . 5
1.7 Components of computer . . . . . . . . . . . . . . 5
1.8 Concept of hardware and software . . . . . . . . . . 6
1.9 Computer hardware . . . . . . . . . . . . . . . . . 6
1.9.1 Central Processing Unit . . . . . . . . . . . 7
1.9.2 Input unit . . . . . . . . . . . . . . . . . . 18
1.9.3 Output unit . . . . . . . . . . . . . . . . . 19
1.10 Common terms related to computer hardware . . . . 22
1.11 Introduction to Windows Operating System . . . . . 26
1.12 Introduction to operating system . . . . . . . . . . 26
1.12.1 Popular Operating Systems in use . . . . . . 27
1.12.2 Main Features of Windows O.S. . . . . . . . 32
1.12.3 Shortcut keys in Windows . . . . . . . . . . 34
1.13 Booting process of computer . . . . . . . . . . . . 36
1.14 BIOS settings and their modification . . . . . . . . 37
1.15 Basic Hardware and software issues and their solutions 41
1.16 Usage of application software and antivirus . . . . . 42
1.17 Introduction to DOS . . . . . . . . . . . . . . . . . 43
1.17.1 Internal DOS commands . . . . . . . . . . . 45
1.17.2 External DOS commands . . . . . . . . . . 46
1.17.3 Output rediction in MS DOS . . . . . . . . 48
1.17.4 Special characters in MS DOS . . . . . . . . 48

iii
1.18 Open Source Software . . . . . . . . . . . . . . . . 48
1.19 Features of Linux OS . . . . . . . . . . . . . . . . 49
1.20 Basic Linux commands . . . . . . . . . . . . . . . . 50
1.20.1 Linux Shells . . . . . . . . . . . . . . . . . 50
1.20.2 Basic Linux shell commands . . . . . . . . . 55
1.20.3 Special characters in Linux shell . . . . . . . 58

2 Word Processing 59
2.1 Introduction to the various applications in office . . 59
2.2 Features of MS Word . . . . . . . . . . . . . . . . 59
2.3 Office button in MS Word . . . . . . . . . . . . . . 61
2.4 Toolbars in MS Word . . . . . . . . . . . . . . . . 62
2.4.1 Home menu in MS Word . . . . . . . . . . 63
2.4.2 Insert menu in MS Word . . . . . . . . . . . 64
2.4.3 Page Layout menu in MS Word . . . . . . . 65
2.4.4 References menu in MS Word . . . . . . . . 66
2.4.5 Mailings menu in MS Word . . . . . . . . . 68
2.4.6 Review menu in MS Word . . . . . . . . . . 69
2.4.7 View menu in MS Word . . . . . . . . . . . 70
2.5 Creating, saving and formatting documents using M.S.
Word . . . . . . . . . . . . . . . . . . . . . . . . . 71
2.6 Inserting objects in MS Word . . . . . . . . . . . . 73
2.7 Inserting macros in MS Word . . . . . . . . . . . . 74
2.8 Performing mail merge in MS Word . . . . . . . . . 75
2.9 Creating and using templates in MS Word . . . . . 76
2.10 Page setup and printing documents using Word . . . 76

3 MS Excel 79
3.1 Introduction to Excel features and Data Types . . . 79
3.1.1 Introduction to features of Excel . . . . . . 79
3.2 Data types in Excel . . . . . . . . . . . . . . . . . 81
3.3 Cell referencing . . . . . . . . . . . . . . . . . . . . 81
3.4 Use of functions of various categories . . . . . . . . 83
3.4.1 Date functions . . . . . . . . . . . . . . . . 84
3.4.2 Engineering functions . . . . . . . . . . . . 87
3.4.3 Cell functions . . . . . . . . . . . . . . . . 88
3.4.4 Cell functions . . . . . . . . . . . . . . . . 89
3.4.5 Logical functions . . . . . . . . . . . . . . . 89

COPA iv Dr.V.Nagaradjane
3.4.6 Math functions . . . . . . . . . . . . . . . . 90
3.4.7 Statistical functions . . . . . . . . . . . . . 95
3.4.8 Text functions . . . . . . . . . . . . . . . . 97
3.5 Sorting in MS Excel . . . . . . . . . . . . . . . . . 98
3.6 Filtering of data in MS Excel . . . . . . . . . . . . 99
3.7 Validation of data in MS Excel . . . . . . . . . . . 99
3.8 Analyzing data using charts in MS Excel . . . . . . 100
3.9 Data tables in MS Excel . . . . . . . . . . . . . . . 100
3.10 Pivot table in MS Excel . . . . . . . . . . . . . . . 101
3.11 Goal seek in MS Excel . . . . . . . . . . . . . . . . 101
3.12 Scenarios in MS Excel . . . . . . . . . . . . . . . . 102

4 Image Editing, OpenOffice and PowerPoint 103


4.1 Introduction to digital images . . . . . . . . . . . . 103
4.1.1 Types of image . . . . . . . . . . . . . . . . 103
4.1.2 Basics of digital images . . . . . . . . . . . 104
4.1.3 Image editing . . . . . . . . . . . . . . . . 104
4.2 Basic adjustments to an image . . . . . . . . . . . 105
4.2.1 Tools available in Adobe Photoshop . . . . . 105
4.2.2 Tools available in Adobe Photoshop . . . . . 106
4.3 Simple tasks in image editing . . . . . . . . . . . . 107
4.4 Introduction to Open Office . . . . . . . . . . . . . 108
4.5 Introduction to Power Point . . . . . . . . . . . . . 110
4.5.1 Introduction to Power Point . . . . . . . . . 110
4.5.2 Menu structure of Power Point . . . . . . . 110
4.6 Creating Slide Shows . . . . . . . . . . . . . . . . . 113
4.7 Fine tuning a presentation . . . . . . . . . . . . . . 114
4.8 Good presentation techniques . . . . . . . . . . . . 115

5 Database Management System (DBMS) 117


5.1 Data, information and databases . . . . . . . . . . 117
5.1.1 Data . . . . . . . . . . . . . . . . . . . . . 117
5.1.2 Information . . . . . . . . . . . . . . . . . . 118
5.1.3 Database . . . . . . . . . . . . . . . . . . . 118
5.2 Concept of DBMS and RDBMS . . . . . . . . . . . 119
5.3 Data Models . . . . . . . . . . . . . . . . . . . . . 121
5.4 Popular Database Engines . . . . . . . . . . . . . . 121
5.5 Codd’s Rules for RDBMS . . . . . . . . . . . . . . 123

COPA v Dr.V.Nagaradjane
5.6 Key terms related to RDBMS . . . . . . . . . . . . 124
5.7 Data Base Administrator (DBA) . . . . . . . . . . . 125
5.8 Data Base user . . . . . . . . . . . . . . . . . . . . 126
5.9 Schema . . . . . . . . . . . . . . . . . . . . . . . . 127
5.10 Rules for designing good tables . . . . . . . . . . . 127
5.11 Normalization of tables . . . . . . . . . . . . . . . 128
5.12 Integrity rules and constraints in a table . . . . . . . 129
5.13 Relationships in tables . . . . . . . . . . . . . . . . 129
5.14 Data types in MySQL . . . . . . . . . . . . . . . . 129
5.14.1 String datatypes . . . . . . . . . . . . . . . 129
5.14.2 Numeric datatypes . . . . . . . . . . . . . . 131
5.14.3 Date and Time datatypes . . . . . . . . . . 131
5.15 Queries and their uses . . . . . . . . . . . . . . . . 132
5.16 Enforcing Primary key and foreign key . . . . . . . . 134
5.17 Adding Indices . . . . . . . . . . . . . . . . . . . . 135
5.18 Concepts of Transactions . . . . . . . . . . . . . . 135
5.19 ACID Property of Transaction . . . . . . . . . . . . 136
5.20 Constraints . . . . . . . . . . . . . . . . . . . . . . 136
5.21 Joining of tables . . . . . . . . . . . . . . . . . . . 137
5.22 Sub Queries . . . . . . . . . . . . . . . . . . . . . 138
5.23 Aggregate functions in MySQL . . . . . . . . . . . 139

6 Communicating in the connected world 143


6.1 Computer Networks . . . . . . . . . . . . . . . . . 143
6.2 How do computer networks function? . . . . . . . . 145
6.2.1 Client Server computing . . . . . . . . . . . 145
6.2.2 Peer to peer networking . . . . . . . . . . . 146
6.2.3 Proxy server, Firewall and Proxy Firewall . . 147
6.3 Network Topologies . . . . . . . . . . . . . . . . . 147
6.4 Network types . . . . . . . . . . . . . . . . . . . . 148
6.5 Networking hardware . . . . . . . . . . . . . . . . . 149
6.6 Networking cables . . . . . . . . . . . . . . . . . . 149
6.7 Wireless communication . . . . . . . . . . . . . . . 151
6.8 Ethernet networks . . . . . . . . . . . . . . . . . . 151
6.8.1 OSI 7 layer model . . . . . . . . . . . . . . 152
6.8.2 Network protocols . . . . . . . . . . . . . . 152
6.8.3 Logical and physical addresses . . . . . . . . 153
6.8.4 Dynamic Host Configuration Protocol (DHCP) 154

COPA vi Dr.V.Nagaradjane
6.9 Internet . . . . . . . . . . . . . . . . . . . . . . . . 154
6.10 Introduction to WWW . . . . . . . . . . . . . . . . 155
6.11 Web browser . . . . . . . . . . . . . . . . . . . . . 155
6.12 Internet server and search engine . . . . . . . . . . 156
6.13 Domain Name System (DNS) . . . . . . . . . . . . 156
6.14 Email . . . . . . . . . . . . . . . . . . . . . . . . . 157
6.15 Video chat tool . . . . . . . . . . . . . . . . . . . . 158
6.16 Voice Over IP (VOIP) . . . . . . . . . . . . . . . . 158
6.17 Social media networking . . . . . . . . . . . . . . . 159

7 Design of web pages 161


7.1 Static and dynamic web pages . . . . . . . . . . . . 161
7.1.1 Static web pages . . . . . . . . . . . . . . . 161
7.1.2 Dynamic web pages . . . . . . . . . . . . . 161
7.2 HTML tags . . . . . . . . . . . . . . . . . . . . . . 162
7.3 Special characters in HTML . . . . . . . . . . . . . 164
7.4 Creating HTML pages . . . . . . . . . . . . . . . . 164
7.4.1 Creating HTML pages . . . . . . . . . . . . 164
7.4.2 Static information page . . . . . . . . . . . 165
7.4.3 Creating ordered and unordered lists . . . . 166
7.4.4 Creating table . . . . . . . . . . . . . . . . 167
7.5 Cascading Style Sheet (CSS) . . . . . . . . . . . . 168
7.5.1 Red color theme . . . . . . . . . . . . . . . 169
7.5.2 Green color theme . . . . . . . . . . . . . . 170
7.6 CSS Property elements . . . . . . . . . . . . . . . 171
7.7 Creating HTML forms . . . . . . . . . . . . . . . . 172
7.7.1 HTML form for greeting . . . . . . . . . . . 172
7.7.2 HTML form for addition . . . . . . . . . . . 173
7.7.3 HTML form for subtraction . . . . . . . . . 174
7.7.4 HTML form for multiplication . . . . . . . . 175
7.7.5 HTML form for subtraction . . . . . . . . . 176
7.7.6 HTML form to calculate age . . . . . . . . 176
7.7.7 HTML form to calculate power of a number 177
7.7.8 PHP script to calculate power of a number . 178

8 Javascript 179
8.1 Algorithms . . . . . . . . . . . . . . . . . . . . . . 179
8.2 Flowcharts . . . . . . . . . . . . . . . . . . . . . . 180

COPA vii Dr.V.Nagaradjane


8.3 Web servers . . . . . . . . . . . . . . . . . . . . . 180
8.3.1 Introduction to web servers . . . . . . . . . 180
8.3.2 Features of web server . . . . . . . . . . . . 181
8.4 Programming Languages . . . . . . . . . . . . . . . 181
8.4.1 Compiler based languages . . . . . . . . . . 181
8.4.2 Interpreter based programming languages . . 182
8.5 Javascript . . . . . . . . . . . . . . . . . . . . . . 182
8.5.1 Comments in Javascript . . . . . . . . . . . 183
8.5.2 Application of Javascript for web . . . . . . 184
8.5.3 Data types in Javascript . . . . . . . . . . . 184
8.5.4 Variables and constants in Javascript . . . . 185
8.5.5 Conversion between data types . . . . . . . 185
8.5.6 Arithmetic Operators in Javascript . . . . . 186
8.5.7 Assignment Operators in Javascript . . . . . 186
8.5.8 Comparison operators in Javascript . . . . . 186
8.5.9 Logical operators in Javascript . . . . . . . . 188
8.5.10 Special operators in Javascript . . . . . . . . 188
8.5.11 String operators in Javascript . . . . . . . . 189
8.5.12 Arrays in Javascript . . . . . . . . . . . . . 189
8.5.13 Associative arrays or Hash maps . . . . . . . 190
8.5.14 Control statements in Javascript . . . . . . 191
8.5.15 If ... else condition . . . . . . . . . . . . . . 191
8.5.16 Switch condition . . . . . . . . . . . . . . . 193
8.5.17 The ternary operator (?:) . . . . . . . . . . 195
8.5.18 Loops in Javascript . . . . . . . . . . . . . 196
8.5.19 For loop in Javascript . . . . . . . . . . . . 197
8.5.20 f or − in loop in Javascript . . . . . . . . . 198
8.5.21 While loop in Javascript . . . . . . . . . . . 199
8.5.22 The do ... while loop in Javascript . . . . . 201
8.5.23 Functions in Javascript . . . . . . . . . . . 202
8.5.24 OOPS in Javascript . . . . . . . . . . . . . 203
8.5.25 Built in JavaScript functions overview . . . . 205
8.5.26 Built-in functions in RegExp data type . . . 210
8.5.27 Browser Object Model (BOM) . . . . . . . 214

9 Advanced Excel Concepts 217


9.1 Introduction to Excel features and Data Types . . . 217
9.1.1 Introduction to features of Excel . . . . . . 217

COPA viii Dr.V.Nagaradjane


9.2 Lookup functions . . . . . . . . . . . . . . . . . . . 218
9.3 Cell protection . . . . . . . . . . . . . . . . . . . . 218
9.4 Sorting in MS Excel . . . . . . . . . . . . . . . . . 219
9.5 Cell referencing . . . . . . . . . . . . . . . . . . . . 219
9.6 Filtering of data in MS Excel . . . . . . . . . . . . 220
9.7 Validation of data in MS Excel . . . . . . . . . . . 220
9.8 Analyzing data using charts in MS Excel . . . . . . 221
9.9 Data tables in MS Excel . . . . . . . . . . . . . . . 221
9.10 Pivot table in MS Excel . . . . . . . . . . . . . . . 222
9.11 Goal seek in MS Excel . . . . . . . . . . . . . . . . 222
9.12 Scenarios in MS Excel . . . . . . . . . . . . . . . . 223
9.13 Advanced graphs in MS Excel . . . . . . . . . . . . 223
9.14 Advanced graphs in MS Excel . . . . . . . . . . . . 224
9.15 Power query in MS Excel . . . . . . . . . . . . . . 225

10 E-Commerce 227
10.1 Definition of E-Commerce . . . . . . . . . . . . . . 227
10.1.1 Types of e-commerce . . . . . . . . . . . . 227
10.2 Scope of e-commerce platform . . . . . . . . . . . 228
10.3 Benefits of e-commerce . . . . . . . . . . . . . . . 228
10.4 Disadvantages of e-commerce . . . . . . . . . . . . 229
10.5 De-Commerce vs. traditional commerce . . . . . . . 229
10.6 Capabilities for e-commerce . . . . . . . . . . . . . 229
10.7 Technology issues . . . . . . . . . . . . . . . . . . 229
10.8 Types of E-Commerce web sites . . . . . . . . . . . 231
10.9 Building business on the net . . . . . . . . . . . . . 231
10.10Online catelogue . . . . . . . . . . . . . . . . . . . 232
10.11Shopping cart . . . . . . . . . . . . . . . . . . . . 232
10.12Checkout pages . . . . . . . . . . . . . . . . . . . 232
10.13Payment for e-commerce transaction . . . . . . . . 232
10.14Security issues for online payment . . . . . . . . . . 233
10.15Payment gateway . . . . . . . . . . . . . . . . . . 234

11 Cyber security 235


11.1 Cyber security . . . . . . . . . . . . . . . . . . . . 235
11.2 Information security . . . . . . . . . . . . . . . . . 235
11.3 Threats to information security . . . . . . . . . . . 236
11.4 Vulnerability . . . . . . . . . . . . . . . . . . . . . 236

COPA ix Dr.V.Nagaradjane
11.5 Risk management . . . . . . . . . . . . . . . . . . 237
11.6 Introduction to Directory Services . . . . . . . . . . 237
11.7 Access control . . . . . . . . . . . . . . . . . . . . 238
11.8 Software development security . . . . . . . . . . . . 238
11.9 Privacy protection . . . . . . . . . . . . . . . . . . 239
11.10Information security audit . . . . . . . . . . . . . . 239
11.11Introduction to I.T. Act . . . . . . . . . . . . . . . 240
11.12Penalties for cybercrimes . . . . . . . . . . . . . . . 240

12 Cloud Computing and Application Development 243


12.1 Cloud computing . . . . . . . . . . . . . . . . . . . 243
12.2 Categories of cloud services . . . . . . . . . . . . . 243
12.3 Resources available on cloud . . . . . . . . . . . . . 244
12.4 Application Development Lifecycle . . . . . . . . . . 244
12.5 Application Development Life Cycle (ADLC) . . . . 245

13 Python Programming (Optional 1) 247


13.1 Introduction to Python . . . . . . . . . . . . . . . . 247
13.2 History of Python . . . . . . . . . . . . . . . . . . 248
13.3 Features of Python . . . . . . . . . . . . . . . . . . 248
13.4 Setting up path for Python . . . . . . . . . . . . . 249
13.5 Basic Syntax . . . . . . . . . . . . . . . . . . . . . 249
13.6 Comments in Python . . . . . . . . . . . . . . . . 250
13.7 Variables . . . . . . . . . . . . . . . . . . . . . . . 250
13.8 Data Types in Python . . . . . . . . . . . . . . . . 251
13.9 Casting data to other types . . . . . . . . . . . . . 252
13.10Operators in Python . . . . . . . . . . . . . . . . . 252
13.10.1 Arithmetic operators in Python . . . . . . . 252
13.10.2 Assignment operators in Python . . . . . . . 252
13.10.3 Comparison operators in Python . . . . . . . 252
13.10.4 Logical operators in Python . . . . . . . . . 256
13.10.5 Identity operators in Python . . . . . . . . . 256
13.10.6 List Membership operators in Python . . . . 256
13.10.7 Bitwise operators in Python . . . . . . . . . 256
13.11Conditional Statements . . . . . . . . . . . . . . . 258
13.12Looping in Python . . . . . . . . . . . . . . . . . . 258
13.13Functions in Python . . . . . . . . . . . . . . . . . 259
13.14File handling in Python . . . . . . . . . . . . . . . 260

COPA x Dr.V.Nagaradjane
13.15Strings in Python . . . . . . . . . . . . . . . . . . 260
13.16Lists in Python . . . . . . . . . . . . . . . . . . . . 261
13.17Tuples in Python . . . . . . . . . . . . . . . . . . . 261
13.18Dictionaries in Python . . . . . . . . . . . . . . . . 262
13.19Arrays in Python . . . . . . . . . . . . . . . . . . . 262
13.20Iterators in Python . . . . . . . . . . . . . . . . . . 263
13.21Datetime module in Python . . . . . . . . . . . . . 263
13.22Math module in Python . . . . . . . . . . . . . . . 263
13.23Input and Output in Python . . . . . . . . . . . . . 264

14 Java Programming (Optional 2) 265


14.1 Object Oriented Programming with Core Java . . . 266
14.1.1 Concepts involved in OOPS . . . . . . . . . 266
14.1.2 Concepts involved in OOPS . . . . . . . . . 267
14.2 Features of Java programs . . . . . . . . . . . . . . 267
14.2.1 Classpath . . . . . . . . . . . . . . . . . . . 268
14.3 Java Program Development . . . . . . . . . . . . . 268
14.3.1 Welcome program . . . . . . . . . . . . . . 269
14.4 Keywords/ Reserved words in Java . . . . . . . . . 270
14.5 Comments in Java . . . . . . . . . . . . . . . . . . 270
14.6 Data types in Java . . . . . . . . . . . . . . . . . . 271
14.7 Variable declaration in Java . . . . . . . . . . . . . 271
14.8 Operators in Java . . . . . . . . . . . . . . . . . . 272
14.8.1 Arithmetic operators in Java . . . . . . . . . 272
14.8.2 Assignment operators in Java . . . . . . . . 272
14.8.3 Comparison operators in Java . . . . . . . . 272
14.8.4 Logical operators in Java . . . . . . . . . . 273
14.8.5 Bitwise operators in Java . . . . . . . . . . 273
14.8.6 String operators in Java . . . . . . . . . . . 273
14.9 Standard Input - output streams . . . . . . . . . . . 273
14.10Conditions in Java . . . . . . . . . . . . . . . . . . 278
14.10.1 If condition . . . . . . . . . . . . . . . . . . 278
14.10.2 If ... else condition . . . . . . . . . . . . . . 279
14.10.3 If ... else if ... else condition . . . . . . . . . 280
14.10.4 Switch ... case ... default condition . . . . . 280
14.10.5 Ternary operator . . . . . . . . . . . . . . . 282
14.11Loops in Java . . . . . . . . . . . . . . . . . . . . 283
14.11.1 While loop . . . . . . . . . . . . . . . . . . 284

COPA xi Dr.V.Nagaradjane
14.11.2 Do - while loop . . . . . . . . . . . . . . . 285
14.11.3 For loop . . . . . . . . . . . . . . . . . . . 286
14.12Number and Character class . . . . . . . . . . . . . 287
14.13String class . . . . . . . . . . . . . . . . . . . . . . 288
14.14Arrays in Java . . . . . . . . . . . . . . . . . . . . 288
14.15Working with objects, methods and properties . . . 290
14.15.1 Class, constructor, properties and methods . 291
14.16Inheritance . . . . . . . . . . . . . . . . . . . . . . 293
14.16.1 Book class . . . . . . . . . . . . . . . . . . 293
14.17Abstract class in Java . . . . . . . . . . . . . . . . 294
14.17.1 FinishedBook - abstract class . . . . . . . . 295
14.17.2 BoundBook extends FinishedBook class . . . 295
14.18Interfaces in Java . . . . . . . . . . . . . . . . . . 296
14.18.1 Student Interface . . . . . . . . . . . . . . 297
14.19Polymorphism in Java . . . . . . . . . . . . . . . . 299
14.19.1 Polymorphism - Rectangle and Oval classes . 299
14.20Packages in Java . . . . . . . . . . . . . . . . . . . 300
14.20.1 Package org.copa . . . . . . . . . . . . . . 301
14.20.2 Accessing the package org.copa . . . . . . . 302

COPA xii Dr.V.Nagaradjane


List of Tables

1.1 Hardware & software . . . . . . . . . . . . . . . . . 7


1.2 Memory sizes . . . . . . . . . . . . . . . . . . . . . 14
1.3 Storage capacities for computer media (secondary stor-
age) . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.4 Monitor resolutions . . . . . . . . . . . . . . . . . 21

2.1 Tools in MS Office . . . . . . . . . . . . . . . . . . 60

4.1 File formats for OpenOffice documents . . . . . . . 109

7.1 Special characters in HTML . . . . . . . . . . . . . 164

8.1 Arithmetic operators in Javascript . . . . . . . . . . 187


8.2 Assignment operators in Javascript . . . . . . . . . 187
8.3 Comparison operators in Javascript . . . . . . . . . 188
8.4 Logical operators in Javascript . . . . . . . . . . . . 188
8.5 Special operators in Javascript . . . . . . . . . . . . 189
8.6 String operators in Javascript . . . . . . . . . . . . 190

10.1 Difference between E-Commerce and traditional com-


merce . . . . . . . . . . . . . . . . . . . . . . . . . 230

11.1 Cyber crimes and punishments . . . . . . . . . . . . 241


11.2 Cyber crimes and punishments . . . . . . . . . . . . 242

13.1 Arithmetic operators in Python . . . . . . . . . . . 253


13.2 Assignment operators in Python . . . . . . . . . . . 254
13.3 Comparison operators in Python . . . . . . . . . . . 255
13.4 Logical operators in Python . . . . . . . . . . . . . 256
13.5 Identity operators in Python . . . . . . . . . . . . . 256

xiii
13.6 List Membership operators in Python . . . . . . . . 257
13.7 Bitwise operators in Python . . . . . . . . . . . . . 257

14.1 Keywords in Java . . . . . . . . . . . . . . . . . . 270


14.2 Keywords in Java . . . . . . . . . . . . . . . . . . 272
14.3 Arithmetic operators in Java . . . . . . . . . . . . . 273
14.4 Assignment operators in Java . . . . . . . . . . . . 274
14.5 Comparison operators in Java . . . . . . . . . . . . 275
14.6 Logical operators in Java . . . . . . . . . . . . . . 276
14.7 Bitwise operators in Java . . . . . . . . . . . . . . 276
14.8 String operators in Java . . . . . . . . . . . . . . . 277

COPA xiv Dr.V.Nagaradjane


List of Figures

1.1 Safe working practices[1] . . . . . . . . . . . . . . . 2


1.2 Rules to be followed in computer lab[2] . . . . . . . 3
1.3 Safety symbols)[?] . . . . . . . . . . . . . . . . . . 4
1.4 Fire extinguishers)[18] . . . . . . . . . . . . . . . . 5
1.5 Components of computer[4] . . . . . . . . . . . . . 6
1.6 Early processors . . . . . . . . . . . . . . . . . . . 9
1.7 Processors . . . . . . . . . . . . . . . . . . . . . . 10
1.8 Common types of RAM . . . . . . . . . . . . . . . 10
1.9 Motherboard[59] . . . . . . . . . . . . . . . . . . . 12
1.10 Storage devices . . . . . . . . . . . . . . . . . . . . 15
1.11 Switch Mode Power Supply (SMPS) . . . . . . . . 16
1.12 Ports in CPU . . . . . . . . . . . . . . . . . . . . . 17
1.13 Keyboard [31] . . . . . . . . . . . . . . . . . . . . 18
1.14 Mouse [32] . . . . . . . . . . . . . . . . . . . . . . 18
1.15 Scanner, tablet & light pen . . . . . . . . . . . . . 19
1.16 Types of monitor . . . . . . . . . . . . . . . . . . . 20
1.17 Impact printers . . . . . . . . . . . . . . . . . . . . 23
1.18 Non-impact printers . . . . . . . . . . . . . . . . . 24
1.19 Windows 11 [5] . . . . . . . . . . . . . . . . . . . 28
1.20 Windows 10 . . . . . . . . . . . . . . . . . . . . . 29
1.21 Mac OS and iOS . . . . . . . . . . . . . . . . . . . 29
1.22 GNOME and KDE on Linux . . . . . . . . . . . . . 30
1.23 Mobile versions of Linux . . . . . . . . . . . . . . . 30
1.24 Common Desktop Environment (CDE) on UNIX . . 31
1.25 Message to access BIOS settings . . . . . . . . . . 38
1.26 BIOS - Main settings . . . . . . . . . . . . . . . . 39
1.27 BIOS - Advanced settings . . . . . . . . . . . . . . 39
1.28 BIOS - Boot settings . . . . . . . . . . . . . . . . . 40

xv
1.29 BIOS - Security settings . . . . . . . . . . . . . . . 40
1.30 Message for booting from CD . . . . . . . . . . . . 41
1.31 Application list in GNOME . . . . . . . . . . . . . 50
1.32 Firefox browser . . . . . . . . . . . . . . . . . . . . 51
1.33 Settings app . . . . . . . . . . . . . . . . . . . . . 51
1.34 LibreOffice Writer . . . . . . . . . . . . . . . . . . 52
1.35 LibreOffice Calc . . . . . . . . . . . . . . . . . . . 52
1.36 GNU Image Manipulation Program (GIMP) . . . . . 53
1.37 Files app . . . . . . . . . . . . . . . . . . . . . . . 53

2.1 Office menu in MS Word . . . . . . . . . . . . . . 62


2.2 Home menu in MS Word . . . . . . . . . . . . . . 63
2.3 Insert menu in MS Word . . . . . . . . . . . . . . . 64
2.4 Page Layout menu in MS Word . . . . . . . . . . . 66
2.5 References menu in MS Word . . . . . . . . . . . . 67
2.6 Mailings menu in MS Word . . . . . . . . . . . . . 68
2.7 Review menu in MS Word . . . . . . . . . . . . . . 69
2.8 View menu in MS Word . . . . . . . . . . . . . . . 71

5.1 Data Base Management System (DBMS)[6] . . . . 119


5.2 RDBMS[7] . . . . . . . . . . . . . . . . . . . . . . 120
5.3 Data Models[8] . . . . . . . . . . . . . . . . . . . . 121
5.4 Data Base Administrator’s Roles[9] . . . . . . . . . 125
5.5 Table Schema[10] . . . . . . . . . . . . . . . . . . 127
5.6 Types of JOINs in MySQL[11] . . . . . . . . . . . . 138
5.7 Resuls of JOIN Operations in MySQL . . . . . . . . 139
5.8 Sub-query and its result . . . . . . . . . . . . . . . 140
5.9 Inserting data into result table . . . . . . . . . . . . 141
5.10 Aggregate functions in MySQL . . . . . . . . . . . 142

6.1 Address bit configuration: Class A network [73] . . . 144


6.2 Address bit configuration: Class B network [73] . . . 145
6.3 Address bit configuration: Class C network [73] . . . 145
6.4 Network topologies [74] . . . . . . . . . . . . . . . 147
6.5 Networking hardware [75] . . . . . . . . . . . . . . 150
6.6 Unshielded and Shielded twisted pair [76] . . . . . . 150
6.7 Coaxial cable [77] . . . . . . . . . . . . . . . . . . 151
6.8 Coaxial cable [78] . . . . . . . . . . . . . . . . . . 151
6.9 OSI 7 layer model [79] . . . . . . . . . . . . . . . . 152

COPA xvi Dr.V.Nagaradjane


7.1 Intro page in HTML . . . . . . . . . . . . . . . . . 166
7.2 List page in HTML . . . . . . . . . . . . . . . . . . 167
7.3 Table page in HTML . . . . . . . . . . . . . . . . . 168

8.1 Document Object Model[82] . . . . . . . . . . . . . 212


8.2 Properties of Document Object Model[83] . . . . . 212
8.3 Properties of Browser Object Model[83] . . . . . . . 214

9.1 Advanced charts in MS Excel [14] . . . . . . . . . . 224


9.2 Menu for importing external data in MS Excel [15] . 225

12.1 Application Development Life Cycle[81] . . . . . . . 245

13.1 Giodo Van Rossum, Creator of Python[13] . . . . . 248


13.2 Executing Python Code . . . . . . . . . . . . . . . 250
13.3 Casting data to other types . . . . . . . . . . . . . 253

14.1 Compilation and running of Java program . . . . . . 270


14.2 Use of System.out, System.in and java.util.Scanner
classes . . . . . . . . . . . . . . . . . . . . . . . . 278
14.3 Execution of switch-case-default program . . . . . . 282
14.4 Execution of ternary operator program . . . . . . . 283
14.5 Execution of while loop program . . . . . . . . . . . 284
14.6 Execution of do - while loop program . . . . . . . . 286
14.7 Execution of for loop program . . . . . . . . . . . . 287
14.8 Mark program using array . . . . . . . . . . . . . . 290
14.9 Paper class . . . . . . . . . . . . . . . . . . . . . . 293
14.10Book class . . . . . . . . . . . . . . . . . . . . . . 295
14.11Execution of BoundBook class . . . . . . . . . . . . 296
14.12Execution of classes implementing Student interface 299
14.13Polymorphism in Java . . . . . . . . . . . . . . . . 301
14.14Packages in Java . . . . . . . . . . . . . . . . . . . 303

COPA xvii Dr.V.Nagaradjane


COPA xviii Dr.V.Nagaradjane
Chapter 1

Basics of computer

Syllabus
Safe working practices, Scope of the COPA trade, Safety rules
and safety signs, Types and working of fire extinguishers, In-
troduction to Computer components

1.1 Safe working practices


1) Do not touch power connections or loose power cables without
permission.

2) Do not eat in the lab space.

3) Keep your water bottles away from computer components like


CPU, monitor, keyboard, mouse, printer, etc.

4) Report any hardware issues immediately to the lab in-charge.

5) Never open surf the Internet in the absence of your faculty/


supervisor.

6) Do not play games on computer.

7) Properly shutdown the computer after completing your works.

8) Do not charge any mobile devices.

1
Figure 1.1: Safe working practices[1]

9) Keep the lab space clean.


10) Report any abnormal conditions immediately.

1.2 Safety Rules


Figs. 1.1 & 1.2 depict the essential rules to be followed in a computer
lab.

1.3 Job opportunities


1) Data entry job in any commercial organization.
2) One may setup Common Services Centre or browsing centre.
3) Recruitment in State Government and Central Government
agencies for Data Entry Operator job.
4) One year apprenticeship in any Government or Private organi-
zation.
5) Programming assistant job in software firms.
6) Point of Sale (PoS) Operator job in malls and other commercial
establishments.

COPA 2 Dr.V.Nagaradjane
Figure 1.2: Rules to be followed in computer lab[2]

COPA 3 Dr.V.Nagaradjane
Figure 1.3: Safety symbols)[?]

1.4 Safety symbols


Symbols of safety for computer lab are depicted in safety rules graphic
presented in Fig. 1.3.

1.5 Types of fire and extiguishers


• Type A fire: Type A fire is caused by buring of wood, cloth
or other carbon based materials. Water, foam, powder or wet
chemical extinguishers are suitable for type A fire.

• Type B fire: Type B fire is caused by inflammable mineral oils


like petrol, paraffin, diesel. Foam, powder or CO2 extinguishers
are suitable for type B fire.

• Type C fire: Type C fire is caused by inflammable gases like


butane, propane or methane. Powder extinguishers are suitable
for type C fire.

• Type D fire: Type D fire is caused by burning metals like alu-


minium, lithium or magnesium. Powder and CO2 extinguishers
are suitable for type D fire.

COPA 4 Dr.V.Nagaradjane
Figure 1.4: Fire extinguishers)[18]

• Electric fire: Electic fire (Not type E) is caused by circuit


malfunctions, sparks or electro-magnetic induction. Powder
and CO2 extinguishers are suitable for electric fire.

• Type F fire: Type F fire is caused by edible oils and fat. Wet
chemical extinguishers are suitable for type F fire.

1.6 Types of fire extinguisher


Types of fire and the applicable types of extingusher are shown in
Fig. 1.4. Fire extiguishers are to be operated by pressing the lever
and directing the hose against the fire.

1.7 Components of computer


1) Central Processing Unit (CPU) is the main component of comptuer.

2) CPU contains motherboard, RAM, Hard Disk, CD/DVD drive,


etc.

3) Motherboard contains a special RAM called CMOS (Compli-


mentary Metal Oxyde Semiconductor) for storing date, time
and other settings.

COPA 5 Dr.V.Nagaradjane
Figure 1.5: Components of computer[4]

4) CMOS is kept in power-on condition using CR20232 battery.


5) Monitor is the display device. It is otherwise called Visual Dis-
play Unit (VDU).
6) Keyboard and mouse are the most common input devices.
7) Processor cycles are governed by control unit.
8) Calculations and comparisons are carried out at Arithmetic and
Login Unit (ALU).

1.8 Concept of hardware and software


Hardware and software are the body and mind of the computer. The
physical hardware runs according to the directions of the invisible
software. The main differences between hardware and software are
presented in Table 1.1.

1.9 Computer hardware


• The parts of computer which can be seen and touched are
called hardware. Generally, computer hardware consists of the

COPA 6 Dr.V.Nagaradjane
Table 1.1: Hardware & software
Sl. No. Hardware Software
1 Physically accessible Physically inaccessible
Cannot be touched,
Can be touched, when
2 whether power on or power
power is off
off
Causes other components
to consume power to make
3 Consumes lot of power
them work. It does not con-
sume any power.
Does not occupy visible
4 Occupies space
space
Its existence is inferred
5 Directly verifiable through the working of
hardware

following 3 units:

1. Input unit: Input unit helps to send commands and data


to the Central Processing Unit (CPU) and fuels the pro-
cessor of the computer. Keyboard, mouse, scanner, light
pen, etc. are some of the common input units.
2. Output unit: The peripherals like Visual Display Unit
(VDU)/Monitor, Printer, Plotter, etc. are some of the
most common output units.
3. Central Processing Unit (CPU) The Central Process-
ing Unit (CPU) processes input data and produces results,
which are out output data.

1.9.1 Central Processing Unit


• The processing centre of computer where mathematical and
logical operations are carried out by the processor is called
Central Processing Unit. The Central Processing Unit has the
following internal components:

1. Microprocessor.

COPA 7 Dr.V.Nagaradjane
2. Main Memory or Primary Storage or Random Access Mem-
ory.
3. Mother board.
4. Secondary Storage or Auxiliary Storage (Hard disk, optical
(CD/DVD) drive, floppy drive (obsolete).)
5. Switch Mode Power Supply (SMPS).
6. Connectors for storage and power controls.
7. Ports for connecting other devices.

Microprocessor
• Microprocessor is the chip that performs arithmetic and logical
operations based on given input data and instructions and sends
out the results of such processing operation.

• Microprocessor contains huge number of electronic devices like


transistors, capacitors, resistors and inductors embedded in
neatly etched circuitry.

• Microprocessor is the brain of computer since all other parts of


computer simply coordinate with this one chip.

• Processor can complete one operation per clock cycle. The


number of clock cycles per second is called the speed of the
processor, measured in kHz (1 kHz = thousand cycles per sec-
ond) or FLOPS (FLoating Point OPerations per Second).

• Registers in microprocessor hold the data required for process-


ing.

• Control unit of the microprocessor directs the work to be carried


out by other parts of a computer. It coordinates with the
memory registers and Arithmetic and Logic Unit to complete
processing.

• Arithmetic and Logic Unit (ALU) is the part of microproces-


sor circuitry which does the number crunching and comparison
works.

COPA 8 Dr.V.Nagaradjane
(a) 8086 Processor[49] (b) 486 Processor[50]

Figure 1.6: Early processors

• Parallel processing in microprocessors is made possible through


multiple processor cores cast in a single chip.

• Multi-core processors gain higher speed if proper multi-processing


algorithms are combined with multi-core processors.

• Small memory called cache memory is etched on board the


micro-processor.

Main Memory or Primary Storage or Random Access Memory


• Main memory is the storage reserved for the data and instruc-
tions moving to and from the processor.

• Main memory is very fast.

• Main memory does not retain any data. It looses data when a
program exits or when the computer is rebooted. Hence, it is
called Volatile storage - the storage that evaporates.

• Main memory is otherwise called primary storage, volatile stor-


age or the more common name of Random Access Memory
(RAM).

• Different types of RAM are:

1. SRAM: Static Random Access Memory


2. DRAM: Dynamic Random Access Memory

COPA 9 Dr.V.Nagaradjane
(a) Pentium 4 (b) Core 2 Duo (c) Core i3
Processor[51] Processor[52] Processor[53]

(d) Core i5 (e) Core i7 (f) Athlon Micro-


Processor[54] Processor[55] Devices (AMD)
Processor[56]

Figure 1.7: Processors

(a) SDRAM[57] (b) DDRSDRAM[58]

Figure 1.8: Common types of RAM

COPA 10 Dr.V.Nagaradjane
3. FPM DRAM: Fast Page Mode Dynamic Random Access
Memory
4. EDO DRAM: Extended Data Out Dynamic Random Ac-
cess Memory
5. SDRAM: Synchronous Dynamic Random Access Mem-
ory
6. DDR SDRAM: Double Data Rate Synchronous Dynamic
Random Access Memory
7. RDRAM: Rambus Random Access Memory
8. VRAM: Video Random Access Memory
9. MPDRAM: Multi-Port Dynamic Random Access Mem-
ory
10. SGRAM: Synchronous Graphics Random Access Mem-
ory

Mother board
• The board containing the electronic components needed for
supporting the micro-processor (µP ), RAM and other compo-
nents is called the mother board.

• Mother board has slots for connecting secondary storage units


like hard disk, CD drive, DVD drive, floppy disk, etc.

• Motherboard contains the Complimentary Metal Oxide Semi-


conductor - CMOS, which keeps configuration data needed
at boot time. It is a RAM, but kept constantly powered on by
a special battery called CMOS battery.

• Motherboard supports Basic Input Output System (BIOS),


which helps booting of the computer (power up process).

• The motherboard supports Communication & Network Riser


- (CNR), Accelerated Graphics Port (AGP), Parallel Ad-
vanced Technology Attachment (PATA) or Integrated
Drive Electronics (IDE), Serial Advanced Technology
Attachment (SATA), Northbridge chipset (for datatrans-
fer to and from the processor), Southbridge chipset

COPA 11 Dr.V.Nagaradjane
Figure 1.9: Motherboard[59]

(data transfer to and from peripherals/secondary stor-


age units).

Secondary Storage or Auxiliary Storage


• Secondary storage or auxiliary storage is very slow compared to
the Random Access Memory, but it provides permanent storage
for data.

• Data stored in secondary storage or auxiliary memory will be


available even after the computer reboots.

• Hard disk, CD/ DVD drive, floppy drive, etc. are some of the
secondary storage units.

• Hard disk uses a magnetic plate mounted on motorized spindle


to store and retrieve data.

COPA 12 Dr.V.Nagaradjane
• Compact Disk (CD) or Digital Versatile Disk (DVD) drive uses
LASER beam of low strength for reading and high strength for
writing data.

• Floppy disk is a magnetic film coated plastic plate which can


store very small amount of data. Floppy disk is easily damaged
and is no longer used in computers.

• Chip based storages like SD (Secure Digital) Card, Micro-


SDCARD, PCMCIA (Personal Computer Memory Card Inter-
national Association), pen drive, external hard disk, external
CD/DVD writer etc. are some of the portable data storage
devices.

Read Only Memory


• Chip level storage, like the information stored in BIOS, is called
Read Only Memory.

• Read only memory is classified as follows:

1. PROM - Programmable Read Only Memory: Pro-


grammable Read Only Memory. It may be reprogrammed
using PROM programmer, but only once.
2. EPROM - Erasable Programmable Read Only Mem-
ory: Contents of EPROM may be erased using Ultra Vio-
let (UV) rays and reprogrammed using RPROM program-
mer.
3. EEPROM - Electrically Erasable Programmable Read
Only Memory: Contents of EEPROM may be erased in
the circuit where it is located and the same may be re-
programmed. BIOS chip belongs to EEPROM category.

Common storage sizes are presented in Table 1.2.

COPA 13 Dr.V.Nagaradjane
Table 1.2: Memory sizes
Sl. No. Storage name Storage size Remarks
1 Bit 1 bit 0 or 1
2 Nibble 4 bits
3 Byte 8 bits
4 kilo Byte (kB) 1024 bytes 210 bytes
5 Mega Byte (MB) 1024 kilo bytes 220 bytes
6 Giga Byte (GB) 1024 mega bytes 230 bytes
7 Tera Byte (TB) 1024 Giga bytes 240 bytes
8 Peta Byte (PB) 1024 Tera bytes 250 bytes
9 Exa Byte (EB) 1024 Peta bytes 260 bytes

Table 1.3: Storage capacities for computer media (secondary storage)


Sl. No. Media Storage capacity
1 CD 700MB
2 DVD 4.7GB
3 SD/ Mini-SD/ Micro-SD card 16GB to 512GB
4 Pen drive 16GB to 512GB
5 Hard disk 512GB to 2TB
6 Solid State Drive (SSD) 128GB to 2TB

COPA 14 Dr.V.Nagaradjane
(a) Hard drive[60] (b) CD/DVD (c) Floppy (d) Pen drive[63]
drive[61] drive[62]

(e) Solid State (f) Solid State (g) SD, Mini SD and Micro-SD
Drive (SSD) Drive (SSD) cards[64]
SATA[16] NVMe M.2[16]

Figure 1.10: Storage devices

Secondary Storage Devices


• Hard Disk Drive (HDD): Hard Disk Drive (Fig.1.9.1) has got
a magnetic plate mounted on a spindle operated by a motor
accompanied by a reading head.

• Compact Disk (CD): Compact Disk is written and read using


laser beam light (hence called optical drive). Storage capacity
is 700MB.

• Digital Versatile Disk (DVD): Digital Versatile Disk (Fig.1.9.1)


is similar to DVD but has 4.7GB of storage space (compared
to 0.7GB of CD).

• Floppy Disk Drive (FDD): FDD (Fig.1.9.1) had a plastic


sheet having magnetic coating. It had 1.44MB of storage
space. It is no longer used.

• Pen Drive: Pen Drive (Fig.??) has USB interface and stores
data in solid state memory locations. Typical pen drive has
16GB to 512GB of storage.

COPA 15 Dr.V.Nagaradjane
Figure 1.11: Switch Mode Power Supply (SMPS)

• Secure Digital Card (SD Card): SD card (Fig.??) stores


data in memory gates. It has storage space in the range of
16GB to 512GB.

• Solid State Drive (SSD): SSD is a hybrid between gate based


storage and hard disk. SSD is available with SATA (like old
HDDs, Fig.1.9.1) and Non-Volative Memory express (NVMe)
M.2 (Fig.1.9.1) interface.

Switch Mode Power Supply (SMPS)


• Switch Mode Power Supply (SMPS) takes 240V input and con-
verts it to varying levels of output to suit the requirements of
different components of the CPU.

• SMPS is very efficient in power conversion and minimizes wastage


of electricity.

• SMPS produces radio frequency interference, which affects


communication signals in the radio frequency (mobile phone,
radio receiver, etc.)

CPU ports
• Ports are located at the rear panel of CPU.

• Ports help connection of various peripherals (like keyboard,


mouse, printer, scanner, camera, speaker, microphone, audio-

COPA 16 Dr.V.Nagaradjane
Figure 1.12: Ports in CPU

input, monitor, serial modem, broadband line, etc.) to the


computer.

• Some of the most common ports are: (i) PS/2 (Personal Sys-
tem 2) ports for keyboard and mouse; (ii) RS-232 (Recom-
mended Standard 232)/ Serial port for mouse, modem and
other serial devices; (iii) VGA (Video Graphics Array) port for
connecting monitor or projector; (iv) Ethernet / RJ-45 (Regis-
tered Jack 45) for broadband connection; (v) USB (Universal
Serial Bus) port for connecting printer, fax, pen drive, external
hard disk, external DVD writer, web camera, etc.; (vi) LPT
(Line Printer Terminal) port for connecting old style dot ma-
trix/ line printers; (vii) 3.5mm audio jack for speaker output/
mic input; (viii) Game port - port for connecting joystick.

COPA 17 Dr.V.Nagaradjane
Figure 1.13: Keyboard [31]

Figure 1.14: Mouse [32]

1.9.2 Input unit


1) Keyboard: Keyboard is otherwise called console input unit.
Common layout of keyboard supports English(US), English(UK)
and local languages like Hindi, Tamil, etc.

2) Mouse - Mouse has LASER based or roller based tracking


mechanism to measure change of position. The movement of
the mouse causes movement of pointer on the VDU. Mouse
has 3 buttons: (a) the left button, (b) the right button and (c)
the centre button which doubles as mouse roller for scrolling.

COPA 18 Dr.V.Nagaradjane
(a) Scanner[33] (b) Tablet[34] (c) Light pen[35]

Figure 1.15: Scanner, tablet & light pen

3) Scanner - It helps to convert content available on paper to


digital image using a moving scan system.

4) Tablet - It converts whatever is written with fingers or a stylus


to characters and images on screen.

5) Light pen - The device has a light sensitive tip which converts
traces the features of display on CRT monitor and converts it
to a new digital image.

1.9.3 Output unit


1) Monitor (otherwise called Console Output Unit or Vi-
sual Display Unit (VDU))

1. Cathode Ray Tube (CRT) monitors were used in the early


days of computer.
2. Plasma (Ionized gas) monitors were also used with com-
puters. But, they are now used for large panel televisions
instead of computers. It is not economical to manufacture
plasma monitors less than 32” in size.
3. Liquid Crystal Display (LCD), Light Emitting Diode (LED)
and Thin Film Transistor (TFT) monitors are commonly

COPA 19 Dr.V.Nagaradjane
(a) CRT[36] (b) LCD[38]

(c) TFT[37] (d) LED[39]

Figure 1.16: Types of monitor

used. LCD may be a bit dull compared to LED and TFT


monitors.
4. Plasma, LCD, LED and TFT monitors consume lower
power compared to the CRT monitors, occupy less space
and present vivid range of colours.
5. The maximum permissible resolution for LCD and LED
monitors is numerically limited but have sufficient resolu-
tion (PPI - Pixels Per Inch) to produce vivid images.

1) Resolution of monitor refers to the number of pixels (Picture


Elements, dots) which can be placed on the display area.
2) Aspect ratio is ratio between the number of pixels in the hori-
zontal direction to the number of pixels in the vertical direction.

COPA 20 Dr.V.Nagaradjane
W

Table 1.4: Monitor resolutions


Sl. Display Pixel
No. Definition resoultion
1 Standard Definition (480p) 640x480
2 High Definition (720p) 1280x720
3 Full High Definition (1080p) 1980x1080
4 2k resolution 2048x1080
5 4k resolution 3840x2160

3) The CRT monitors had aspect ratio of 4:3. Resolutions of


400x300 and 800x600 fall under the aspect ratio of 4:3.
4) Modern LCD, LED and TFT monitors have aspect ratios of
16:9, 16:10, etc. Modern monitors are called wide screen dis-
plays due to the higher width to height ratio. Resolution of
1920x1080 is the typical resolution for aspect ratio of 16:9 and
1280x800 is the typical resolution for aspect ratio of 16:10.
5) Monitor resolution may also be measured using Pixels Per Inch
(PPI), which is the number of pixels in one inch distance of
the monitor.
6) In monitor resolution, the term High Definition (HD) de-
notes the closely spaced pixels to produce clear display of im-
ages.
7) Based on rendering technique, displays are classified into 2
types:
(i) Progressive display: Sequential rendering of all lines from
top to bottom.
(ii) Interlaced display: Alternate lines (odd & even) are ren-
dered in 2 passes.

2) Printer: Printer produces paper copies called hard copies. Fol-


lowing printers are available:
1. Impact type printers: Impact type printers hit the paper
using characters and shapes to produce an imprint on the

COPA 21 Dr.V.Nagaradjane
paper. Dot matrix printer, line printer, chain printer, golf
ball printer, daisy wheel printer, etc. are examples of
impact printers.
2. Non-impact type printers: Non-impact type printers
do not physically hit the shapes and characters on the
paper. Some of the most common types of non-impact
printer are:
(i) Inkjet printer: Inkjet printer uses ink cartridges and
print head. The head spits ink in desired pattern to
produced characters and shapes.
(ii) LASER printer: Laser printer uses heat generated
by LASER beam to create shapes/ characters and
make the toner powder to stick to the paper
(iii) Thermal printer: Thermal printer creates desired
shapes and characters using heating filament on a
special paper coated with BisPhenol A (BPA). It is
used in ATM machines, ticketing machines, point of
sale terminals, etc.
(iv) Plotter: Plotter is a large printer (usually non-impact
type) used to produce large size drawings on paper.

1.10 Common terms related to computer


hardware
1) CPU: Central Processing Unit

2) PS2: Personal System 2

3) USB: Universal Serial Bus

4) RS-232 (Serial) port: Recommended Standard 232

5) LPT (Parallel) port: Line Print Terminal

6) VGA: Video Graphics Array

COPA 22 Dr.V.Nagaradjane
(a) DOT matrix printer[40] (b) Line printer[41]

(c) Chain printer[42]

(d) Golf ball printer[43] (e) Daisy wheel printer[43]

Figure 1.17: Impact printers

COPA 23 Dr.V.Nagaradjane
(a) Inkjet printer[45] (b) LASER printer[46]

(c) Thermal printer[47] (d) Plotter[48]

Figure 1.18: Non-impact printers

COPA 24 Dr.V.Nagaradjane
7) RJ-45: Registered Jack 45. Other names: Ethernet port or
LAN Port. LAN stands for Local Area Network. Used for
broadband connection.

8) RJ-11: Registered Jack 11. Used for connecting telephone


line or networking through telephone line.

9) DVI: Digital Visual Interface.

10) HDMI: High Definition Media Interface.

11) SMPS: Switch Mode Power Supply.

12) HDD: Hard Disk Drive.

13) FDD: Floppy Disk Drive.

14) SATA: Serial Advanced Technology Attachment.

15) PATA: Parallel Advanced Technology Attachment. Otherwise


called Parallel port or IDE port.

16) IDE: Integrated Device Electronics. This is an alternate name


for PATA.

17) RAM: Random Access Memory. Otherwise called Primary


storage or main memory or volatile memory.

18) CMOS: Complimentary Metal Oxide Semi-conductor.

19) BIOS: Basic Input Output System.

20) CNR: Communication and Network Riser.

21) IEEE 1394: Institute of Electrical and Electronics Engineers


1394. Otherwise called Firewire port.

22) ATA: Advanced Technology Attachment.

23) ATX: Advanced Technology eXtension.

24) DDR: Double Data Rate.

COPA 25 Dr.V.Nagaradjane
1.11 Introduction to Windows Operating
System
• Computer software decides how the hardware works.
• Software is the reason why computers can produce output
based on given input.
• Software can be divided into 2 essential categories:
1. System software: The software needed for by the com-
puter to support other software and hardware components
is called the system software. The Basic Input Output
System (BIOS), the Operating System (Windows, Unix,
Linux, Mac OS, etc.) and device drivers are the major
system software. System software does not directly carry
out any productive work (like document editing). It helps
other software packages to work and produce desired out-
put through available hardware.
2. Application software: Application software helps in pro-
ductive working of computer like creating documents,
spreadsheets, playing music/video, managing databases,
etc.. It does not worry about booting the computer or
controlling the hardware (these works are relegated to
the system software).

1.12 Introduction to operating system


1) Operating system coordinates with BIOS in identifying hard-
ware available at the time of booting.
2) Operating system initializes, operates and controls all periph-
eral units through appropriate drivers.
3) Operating system coordinates application programs and allows
time sharing or parallelism. Parallel processing helps several
applications to run concurrently through sharing of the pro-
cessor time. Users feel as if all the applications are running
continuously in the background and foreground.

COPA 26 Dr.V.Nagaradjane
4) Operating system allots, manages and frees memory needed
for other processes.

5) Operating system makes secondary storage devices to load and


save data.
6) Operating system manages network connections and shares
available connection between programs needing network ac-
cess.
7) Operating system manages hard disk fragmentations and tries
to arrange storage tracks in continuous chunks.
8) The core of the operating system, handling hardware, file sys-
tem and networking is called the kernel of the operating system.
9) The part of the operating system which interacts with the user
is called shell of the operating system. Shell can provide com-
mand line interface or Graphical User Interface (GUI).

1.12.1 Popular Operating Systems in use


• Following are the most popular operating systems on comput-
ers:
1. Microsoft Windows
2. Apple Mac OS
3. Linux
4. UNIX
5. Free BSD, Darwin, BeOS, Solaris, IBM AIX, etc.

Microsoft Windows
• Microsoft Disk Operating System (MSDOS) released in 1981.
Development of MS DOS was stopped in the year 2000.
• MS DOS based Windows 1.0 was released by Microsoft in 1985.
After Windows 3.1, subsequent releases were named Windows
95, Windows 98, Windows Me. The MSDOS based Windows
were discontinued.

COPA 27 Dr.V.Nagaradjane
Figure 1.19: Windows 11 [5]

• Microsoft released a stable, multi-tasking, multi-processor op-


erating system named Windows NT in 1993. It was succeeded
by Windows 2000, Windows XP, Windows Vista, Windows 7,
Windows 8, Windows 10 and Windows 11.

Mac OS
• Apple computers released the first version of GUI based Mac
OS in the year 1984.

Linux
• Linux was developed by Linus Torvalds in the year 1991.

• Linux is distributed under the GNU General Public License


(GNU GPL), which permits free access to source code, but
mandates redistribution of software under the same license.

• Linux operating system was inspired by Unix operating system.

• Linux provides a stable, scalable, highly productive kernel.

COPA 28 Dr.V.Nagaradjane
(a) Windows 10[?] (b) Win-
dows 10
Mobile[69]

Figure 1.20: Windows 10

(a) Mac OS[67] (b) iOS

Figure 1.21: Mac OS and iOS

COPA 29 Dr.V.Nagaradjane
(a) GNOME on Linux[67]

(b) KDE on Linux[?]

Figure 1.22: GNOME and KDE on Linux

(a) Android (b) Firefox OS[71] (c) Tizen[72]

Figure 1.23: Mobile versions of Linux

COPA 30 Dr.V.Nagaradjane
Figure 1.24: Common Desktop Environment (CDE) on UNIX

UNIX
• UNIX was one of the first operating systems to support multi-
tasking and multiple user logins.

• UNIX was developed at AT&T Bell Labs in the year 1970 by


Ken Thompson, Dennis Ritchie, M. D. McIlroy and J. F. Os-
sanna and others.

• UNIX still remains the gold standard for any operating system.

• The UNIX operating system was standardized by POSIX (Portable


Operating System Interface), which was superceded by SUS
(Single Unix Standard).

• By market share, Microsoft Windows is the most common op-


erating system used in personal computers.

• Windows 10 and Windows 11 are the most common versions


of Windows at present.

COPA 31 Dr.V.Nagaradjane
• Windows 3.1, Windows 95, Windows 98, Windows Me, Win-
dows NT, Windows 2000, Windows 2003, Windows XP and
Windows 7 and Windows 8 are some of the obsolete versions
of Windows operating system.

• Apple computers installs Mac OS X in its computers. This


operating system presents a Graphical User Interface (GUI)
and good security. Mac OS Big Sur is the latest version of
Mac.

• Free operating system named Linux is available for variety of


computers from desktops to servers. Linux kernel has been
repacked with a variety of features in the names of Debian,
Ubuntu, Red Hat, Fedora, SUSE, etc. are some of the popular
versions of Linux.

• Many more operating systems like BeOS, Free BSD, Darwin,


etc. are also used on computers.

1.12.2 Main Features of Windows O.S.


The Desktop
1) Windows is based on a graphical user environment called Desk-
top.

2) The desktop contains a collection of icons, named desktop


icons or shortcut icons.

3) Windows provides a taskbar. The Taskbar contains start menu,


quick launch icons and the system tray.

4) The start button opens a list of applications which can be


run by clicking on their names or icons. Usually, start button
appears at the left most end of task bar.

5) Quick launch icons are provided near the start button. They
offer shortcuts to frequently used programs.

6) System tray provides status of several background tasks, data


and time, volume control (optional) and network connectivity

COPA 32 Dr.V.Nagaradjane
icon. The system tray is a quintessential control panel for
background programs.

7) Clicking any icon in the desktop area or quick launch bar opens
the corresponding application.

8) The list of processes currently running in the foreground is


displayed at the centre portion of the taskbar.

1) Windows provides a directory named user (also called Docu-


ments and Settings) in the root folder of C: drive.

2) The user folder contains sub-folders representing the name of


each user who logs in. In addition to individual sub-folders, a
sub-folder named Public is available, the contents of which are
shared with all users.

3) The sub-folder named after the individual user is called the


Home folder. E.g., a person having login name krish gets a
home folder called C : \users\krish.

4) Within the home directory, folder named Desktop stores all


items seen in the desktop, Documents saves all files created
by the user, Downloads saves all files downloaded from the
Internet, Pictures stores all image files, Videos saves all video
files, folder named Music saves all music files.

• Windows Explorer may be opened from the start menu or by


pressing Windows button + E.

• To rename a file, right click on the file (or select the file and
press F2). The name file becomes editable.

• To copy a file, right click and choose copy (or press Ctrl +
C). Press Ctrl + V at the new destination where a copy of the
original file is needed.

• To cut a file (make a copy file and remove the original file),
right click and choose cut (or press Ctrl + X). Press Ctrl +
V at the new destination where a copy of the original file is
needed. After copying, the original file will be deleted.

COPA 33 Dr.V.Nagaradjane
• To open a document, spreadsheet, music file, video file or any
other file having a known support application (like MS Word,
Excel, Windows Media Play/VLC), simply open the file by dou-
ble clicking (or single click if enabled).

• To create desktop shortcut to a file, right click on the file,


choose Send to − > Desktop (create shortcut).

• To burn a file to CD/DVD, right click the file, choose Send


to− >X: <CD/DVD Drive name>. The file writing dialog will
appear when a blank CD/DVD is inserted. Follow on screen
instructions to complete the process.

• To compress a file, right click, choose Send to − > Com-


pressed/Zipped archive. The file will be compressed. If a third
party zipping program like WinZip or WinRAR is installed, sep-
arate entries will be available for zipping.

• To unzip a compresed archive, simply double click the archive.


Otherwise, right click the archive and choose appropriate op-
tion for unzipping.

• Large files can be compressed into smaller size with the help
of zipping. WinRAR provides support for splitting a file into
chunks (which can be combined at a new location) of specified
size (to fit a CD/DVD).

1.12.3 Shortcut keys in Windows


• F1 - Windows help.

• F2 - Rename.

• F3 - Find all files.

• F5 - Refresh current window.

• F6 - Move among panes in Windows Explorer.

• Windows + L - Lock computer.

• Windows + M - Show desktop.

COPA 34 Dr.V.Nagaradjane
• Windows + D - Show desktop.

• Windows + R - Run a command.

• Windows + P - Display sharing (with projector, secondary


monitor, etc.).

• Windows + V - start clipboard.

• Windows + K - Audio/ video sharing.

• Windows + I - Windows settings.

• Windows + A - Alerts/ notifications.

• Windows + S - Open cortana.

• Windows + F - Windows feedback.

• Windows + E - Open Windows Explorer.

• Alt + F4 - Close current program/shutdown Windows.

• Alt + Tab - Cycle through currently running processes.

• Alt + Down arrow - Pop down list.

• Alt + Space - Window’s system menu.

• Alt + - - System menu for child window.

• Alt + Enter -properties of the selected object.

• Alt + Left arrow - Previous folder in Windows Explorer.

• Shift + Delete - Delete permanently.

• Shift + F10 - Context menu; equivalent to right click.

• SHIFT - Disable autorun for newly inserted media.

• Ctrl + F4 - Closes the current child window.

• Ctrl + X - Cut a file.

COPA 35 Dr.V.Nagaradjane
• Ctrl + C - Copy a file.

• Ctrl + V - Paste a file.

• Ctrl + Esc - Start menu.

• Ctrl + Shift + Esc - Task Manager.

1.13 Booting process of computer


• Booting is the process of harware waking up and getting ready
to load the operating system (Windows, Linux, Mac OS X,
etc.).

• When the computer boots, the BIOS (Basic Input Output Sys-
tem) activates a series of hardware checkes called Power On
Self Test (POST).

• The BIOS reads essential settings like date, time and boot
device order, as customized by the user, from the CMOS.

• BIOS initializes all devices (disc drives, video cards, sound


cards, network cards, floppy drives, USB ports and hard drives)
connected to the computer.

• BIOS later works with the processor to transfer data to and


from those devices.

• The programs needed for BIOS routines are stores in a BIOS


chip.

• On successful completion of the POST routines, the boot loader


loads the operating system from specified boot device (hard
disk, DVD ROM, CD ROM, etc.).

• The boot loaded initially loads from a chip and is called Pri-
mary Boot Loader. The primary boot loader then calls a more
elaborate boot loader program called Secondary Boot Loader.

COPA 36 Dr.V.Nagaradjane
• The secondary boot loader is normally stored in Master Boot
Record (MBR). GNU GRUB, BOOTMGR, NTLDR, UEFI (Uni-
fied Extensible Firmware Interface) or ESP (EFI system parti-
tion).)
• The secondary boot loader, loads the operating system. When
the operating system finishes loading, booting is complete and
the computer is ready for usage.
• The computer beeps when the POST routines are successfully
completed. It beeps and error message if there is some failure
of POST.

• In case the POST fails, codified beeps are issued to denote


the type of error encounted during POST. The beep codes and
messages are as follows:
1. Steady, short beeps: Power supply may be bad
2. Long continuous beep tone: Memory failure
3. Steady, long beeps: Power supply bad
4. No beep: No power supply or beeper damaged.
5. One long, two short beeps: Video card failure

1.14 BIOS settings and their modifica-


tion
• BIOS is the Basic Input Output System in computer.
• Settings needed for BIOS are stored in CMOS (a RAM chip).
• CMOS is kept continuously power on using a special battery
called CMOS battery (model No.CR2032).
• When CMOS battery fails or is removed, all settings stored in
CMOS are lost.
• BIOS settings may be accessed by pressing DEL, F2, ESC, or
any other key (depending on the manufacturer) immediately
after switching the power supply on.

COPA 37 Dr.V.Nagaradjane
Figure 1.25: Message to access BIOS settings

• The BIOS settings may be classified under the following heads:

1. Main: Settings related to date, time, drive options, mem-


ory details, etc.

2. Advanced: Configuration of processor, on board features


of the motherboard, configuration of USB, etc. can be
accessed through Advanced option.

3. Power: Power options relate to the options to deal with


power off and subsequent restart, suspension of disk drive
after particular duration, etc.

4. Boot: The options relating to UEFI, order of the boot


devices and options to change boot order, etc. are dis-
played in boot settings.

5. Security: The options related to setting of user and ad-


ministrator passwords is available from Security menu.

6. Exit: Options for saving the settings before exit, load


optimal defaults before exit, load previous settings that
worked, discard all changes and exit the CMOS settings,
etc. are displayed under this menu.

COPA 38 Dr.V.Nagaradjane
Figure 1.26: BIOS - Main settings

Figure 1.27: BIOS - Advanced settings

COPA 39 Dr.V.Nagaradjane
Figure 1.28: BIOS - Boot settings

Figure 1.29: BIOS - Security settings

COPA 40 Dr.V.Nagaradjane
Figure 1.30: Message for booting from CD

1.15 Basic Hardware and software issues


and their solutions
1) Brute solution to many problems: Reboot the computer.
It solves several problems without going through the details.
So, restart is the first solution to fix problems in a running
computer.
2) Computer is slow: Remove Internet connection. Run disk
cleanup from control panel. Open task manager (run taskmgr,
press Ctrl + Shift + Esc, or press Ctrl + Alt + Delete and
choose task manager), right click unwanted programs and choose
End Process.
3) Computer misbehaves: Remove all peripherals. Connect
just monitor, keyboard and mouse. Boot PC to know whether
problems recurs. Add all other peripheral units one by one.
Identify whether the problem occurs due to any particular pe-
ripheral.
4) PC does not boot: Reconnect/ replace power cables. Check
whether SMPS is running (SMPS switch turned on and fan
running in the rear panel). Check whether motherboard LED
is lit up.
5) Long beeps & boot halted: Remove RAM chip. Clean the
RAM canal and the ram chip. Reinsert the chip.

COPA 41 Dr.V.Nagaradjane
6) Insert boot media error: Open BIOS settings. Arrange boot
devices in right order. Reboot. If problem persists, see whether
the required media is listed in the BIOS. Boot from alternate
media (like CD, DVD or pen drive) to check whether the PC
can boot at all.
7) Boot halted due to wrong settings: Press Del or F2 or
enlisted key to access BIOS. Set correct date and time.
8) PC does not switch on: Check power cables. Check SMPS.
9) BIOS settings are lost after each poweroff: Replace CMOS
battery (CR2032).
10) Printers do not work: Open control panel. Go to services.
Click on Print Spooler service. If it is not running (most prob-
able), start the service.
11) PC Reboots while working: Try another RAM. If problem
persists, try another SMPS. Check all IDE/ SATA cables. Rein-
sert all power cables.
12) Internet connection is slow: See whether Windows is auto-
matically downloading updates. Pause the updates and check
connection speed (Automatic updates may be disabled using
control panel).
13) Cannot install new program: Right click on setup file and
choose Run as administrator. If it does not solve the problem,
choose compatible installer (32 bit or 64 bit) for the operating
system.
14) Paper jam error: Switch off printer. Remove top cover. Re-
move jammed paper. Power on the printer and check whether
it works.

1.16 Usage of application software and


antivirus
• Application software packages help in making productive use
of computers.

COPA 42 Dr.V.Nagaradjane
• Microsoft Office is one of the most popular appication software
packages.

• MS Office contains Word for document editing, Excel for spread-


sheets, PowerPoint for making presentations.

• MS Paint helps in preparation of drawings and editing of im-


ages.

• Third party applications may be installed for image editing


(Photoshop, GIMP, Corel Draw, etc.), video editing (Adobe
Premier, Openshot, etc.) or any other task.

• For browsing the web, Microsoft Edge (Based on Chrome) is


available. Third party browsers like Firefox, Google Chrome
and Opera are also available.

• Antivirus prevents malicious software from infecting the com-


puter.

• Antivirus packages like McAffee, Norton, Kaspersky, K7, Bit-


defender, Panda, AVG, etc. are available for annual payment
for renewal.

• Some free antivirus packages like Avast, Avira, AVG (free ver-
sion), Malwarebytes, etc. are also available.

• Generally, installation of antivirus slows down the performance


of computer.

• Antivirus prevents viruses spreading through pen drives, DVDs


and the Internet/ email.

1.17 Introduction to DOS


• MS DOS was a small operating system released by Microsoft
Corporation in the year 1981 to run on IBM Personal Computer.

• After releasing version 8.0 in September 2000, development


work on MS DOS ceased.

COPA 43 Dr.V.Nagaradjane
• MS DOS applications had either .COM extension or .EXE ex-
tension.

• MS DOS supports two types of commands:

(i) Internal DOS commands - the commands which were


part of the DOS os and loaded to memory, whether called
for or not. These commands are also called Memory
Resident DOS Commands.

(ii) External DOS commands - the commands which were


kept in disk and loaded only when invoked from the com-
mand prompt.

• A collection of DOS commands may be typed inside a file


(typically beginning with @echo off) having .BAT extension
(called a batch file). The batch file can be invoked as a new
command.

COPA 44 Dr.V.Nagaradjane
1.17.1 Internal DOS commands

1 CLS Clear screen.


2 DIR Show list of files and directories.
3 VER Show version number of MS DOS.
4 VOL Show volume label for a disk drive.
5 DATE Show or set current date.
6 TIME Show or set current time
7 COPY Create copy of a file.
8 TYPE Display contents of a file
Copy the typed content to
a file name provided in as
9 COPY CON argument. Copying stops
when Ctrl + Z (end of file
indicator) is pressed.
Rename the file (first argu-
10 REN ment - old name; second ar-
gument - new name).
11 DEL or ERASE Delete a file.
12 MD or MKDIR Create new directory.
13 CD or CHDIR Change to antother directory.
14 RD or RMDIR Remove given directory.
Takes on or off argument to decide
15 ECHO whether commands file batch file
are displayed or not.
16 EXIT Closes command prompt.
Displays list of directories in which
17 PATH a command is looked for. Sets new
path if necessary.
Hold on processing until Enter key
18 PAUSE
is pressed.
Set new command prompt instead
19 PROMPT
of C : \ >
20 REM Remarks.
Set new values environment vari-
21 SET
able.

COPA 45 Dr.V.Nagaradjane
1.17.2 External DOS commands

Adds given directories to


1 APPEND the end of PATH environ-
ment variable.
Change given drive name to
2 ASSIGN
a new drive letter.
Change attributes (a-
3 ATTRIB archive, h-hidden, r-read
only, s-system file).
Backup specified files to given des-
4 BACKUP
tination.
Check the disk for errors and rec-
5 CHKDSK
tify errors.
MS DOS operating system pro-
6 COMMAND.COM
gram.
Compare two files. Report first
7 COMP
mismatch.
Debug given program. One
8 DEBUG can examine values store in
variables.
Compare 2 disks with each
9 DISKCOMP
other.
Copy contents of one disk
10 DISKCOPY
to another.
11 DOSKEY Store command history.
A visual shell for exploring
12 DOSSHEL
files and directories.
13 EDIT MS DOS Editor.
14 EDLIN Edit single line.
15 EXPAND Decompress files.
16 FC Compare 2 files.
17 FDISK Create disk partitions.
18 FORMAT Format specified partition.
Display help about an MS
19 HELP
DOS command.
20 LABEL Display disk label.
21 VOL Display volume details.
22 MEM Display memory usage details.

COPA 46 Dr.V.Nagaradjane
Create backup file named MIR-
ROR.FIL at root directory to re-
23 MIRROR
store lost information, if any, at a
later date.
Show given information in small
chunks for easy reading. Press-
ing a key moves forward. Press-
24 MORE
ing < space > shows next page,
< enter > shows next line, =
shows line number, Q quits.
Create a new file having contents
25 MOVE of the old file, but delete the old
file.
26 PRINT Send given file to the printer.
Check and correct errors in the file
27 SCANDISK system of given drive. Works sim-
ilar to CHKDSK command.
Sort given input lines in alphabetic
28 SORT order. /R option sorts in reverse
order (Z to A or 9 to 0).
Make given disk bootable. It
29 SYS
should be issued from C: drive.
Display files and directories in tree
30 TREE
structure.
31 UNDELETE Restore recently deleted file.
Extended copy mode for copy-
32 XCOPY ing directories, subdirectories and
files.

COPA 47 Dr.V.Nagaradjane
1.17.3 Output rediction in MS DOS
Write the output of the left
side program to the file pro-
vided on the right side. If
1 > the file does not exist, it
is created. If the file al-
ready exists, its contents
are deleted.
Write the ouput of the pro-
gram on the left side to the
file indicated on the right.
2 >> If the file does not exist, it
is created. If it exists, new
content is appended to the
end of file.
Pipe symbol. Pass the out-
put of the program on the
3 |
left to that on the right of
the pipe.

1.17.4 Special characters in MS DOS


Match any number of char-
1 *
acters.
2 ? Match any one character.

1.18 Open Source Software


• Open source software denotes software for which the original
source code is available (not necessarily free of cost).

• Open source software helps capable users to correct bugs or


add new features to the software.

• Open source model of software development enabled develop-


ers across the world to contribute to the improvement of a
software.

• Open source model opposes the closed source monopoly of


large corporates.

COPA 48 Dr.V.Nagaradjane
(a) Richard Stallman (b) Linus Torvalds

• Advent of open source software paved the way for creation of


valuable software like Linux operating system, Mozilla Firefox
browser, Open Office software package, GIMP image editor,
QCAD drafting & design software, Blender 3D modelling and
animation software, etc.

• Some of the software licenses which adopt open source licens-


ing system are: Apache License, BSD license, GNU General
Public License, GNU Lesser General Public License, MIT Li-
cense, Eclipse Public License and Mozilla Public License.

• Richard Stallman created the GNU (GNU Not Unix) project.

• Linus Torwalds released the Linux operating system in 1991.


Source code for Linux was distributed under the GNU General
Public License.

1.19 Features of Linux OS


• Linux operating system provides software packages for almost
all common tasks.

• LibreOffice provides swriter for document editing, scalc for


spreadsheets, impress for editing presentations.

• GIMP is one of the most powerful packages for image editing.

• Blender is free 3D modelling and animation package.

COPA 49 Dr.V.Nagaradjane
Figure 1.31: Application list in GNOME

• Video editors like Openshot help in multimedia related works.

• Settings app is provided for controlling the work environment


and hardware features.

• Linux provides several compilers and IDEs for programming.

• The shell environment (Terminal) provided by Linux is an ex-


cellent tool for working in command line.

• File app, disks app and startup disk creator are suitable man-
aging files.

1.20 Basic Linux commands


1.20.1 Linux Shells
• Linux operating system contains 2 essential components, (i)the
kernel which controls the computer peripherals, (ii)the shell,
which transmits commands issued by the user to the kernel for
processing.

• Linux commands may also be typed inside a text file and used
as a new command. Such text file is called shell script.

COPA 50 Dr.V.Nagaradjane
Figure 1.32: Firefox browser

Figure 1.33: Settings app

COPA 51 Dr.V.Nagaradjane
Figure 1.34: LibreOffice Writer

Figure 1.35: LibreOffice Calc

COPA 52 Dr.V.Nagaradjane
Figure 1.36: GNU Image Manipulation Program (GIMP)

Figure 1.37: Files app

COPA 53 Dr.V.Nagaradjane
• Several shells are available for interaction with the Linux kernel.
Some of the most common shells are: (i)sh - Bourne Again
Shell or bash, #/bin/sh at the beginning of shell script denotes
bash script. (ii)csh - C shell. It supports conditions and loops
features similar to C programming language. (iii)ksh - Korn
Shell. Korn shell was released as an improvement to the Bourne
shell by AT&T Bell Labs.

COPA 54 Dr.V.Nagaradjane
1.20.2 Basic Linux shell commands

1 ls List files and folders.


2 mkdir Make directory.
3 rmdir Remove directory.
4 cp Copy given file to new name.
5 mv Move given file to new name.
6 cd Change directory.
7 cd .. Change to parent directory.
8 cd ˜ Change to home directory.
9 cd / Change to root directory.
10 mount Mount a file system/ drive.
11 umount Unmount a file system/ drive.
12 eject Eject a drive.
13 shutdown -r < time > Restart after given interval.
14 shutdown -h < time > Halt after given interval.
15 sleep Stop execution for given duration.
16 sort Sort given input.
17 ln Create a link to the original file.
18 tar Tape archive. Create an archive.
19 zip (or) gzip Zip a file.
20 unzip (or) gunzip Decompres given file.
21 ls -l List of files with all parameters.
22 more Display screenfulls of output.
23 less Display screenfulls of output.
Search for a file having given name
from given directory. find . -name
temp.txt -exec ls -l {} \; search
24 find for a file named temp.txt from the
current directory (.). Execute the
command ls -l on the resulting file
({} ).
Display given text in banner for-
25 banner
mat.

COPA 55 Dr.V.Nagaradjane
26 rm Remove a file.
27 cat display contents of a file on screen.
28 cat - > Store keyboard input to a new file.
Append keyboard input to given
29 cat - >>
file.
Display and set current date and
30 date
time.
Display time taken for processing
31 time
a program.
32 ed Single line editor.
33 cc Run C-language compiler.
34 vi Open VI text editor.
35 emacs Open emacs text editor.
36 gedit Open gedit text editor.
37 useradd Create new user.
38 userdel Deletes given user name.
39 passwd Changes password.
40 su Increase previleges to super user.
41 sudo Run given command as super user.
42 cal Display calendar.
43 calc/ bc Calculator.
44 cron Run given programs as per schedule.
45 awk Interpreted language and a filter.
46 sed Stream editor and filter.
47 which Find full path of given command.
48 file Display file type of the argument.

COPA 56 Dr.V.Nagaradjane
Substotute given character in
49 tr
place of unwanted one.
50 chown Change ownership of file.
Change file access mode for owner,
51 chmod group and world. 1-read, 2 - write,.
4 - execute.
52 groupadd Create a new group.
53 groupdel Delete a group.
54 grep Catch lines with given text.
Test file for read, write or execute
55 test
permissions.
If condition is true, then part is ex-
56 if ecuted. else and elif are supported.
fi is the end of if.
57 while Run the loop if given condition is true.
58 for Run given loop with stated arguments.
59 tree Display tree structure of files system.
60 c++ Run C + + language compiler.
Place the variable, value pair in the
61 export
shell environment.
62 clear Clear contents of the screen.
63 ps Display list of running processes.
Kill/ terminate process with given
64 kill
process ID.

COPA 57 Dr.V.Nagaradjane
1.20.3 Special characters in Linux shell
1 # What follows ’#’ character is comment.
2 * The wild card. Matches any number of letters.
3 ? Match any single character.
Send output to a new file. Delete
4 >
contents if file already exists.
5 >> Append the output of program to given file.
Send output of the left side pro-
6 | gram to the input of the right side
program.
7 $? Exit code of previous process. 0 denotes success.
8 & Run process to the left of & in the background.
9 - Denotes standard input (keyboard).
10 ˜ Home directory.
11 [[ ]] Test condition.
12 ! Negation of condition.
Run right side program only if the
13 &&
left side program succeeds.
Run right side program only if the
14 ||
left side program fails.

COPA 58 Dr.V.Nagaradjane
Chapter 2

Word Processing

Syllabus
Introduction to the various applications in office. Introduction
to Word features, office button, toolbars. Creating, saving and
formatting and printing documents using Word. Working with
inserting objects, macro, mail merge, templates and other tools
in Word. Page setup and printing documents using Word.

2.1 Introduction to the various applica-


tions in office
• Microsoft office has a collection of tools for carrying out var-
ious productive jobs like preparation of document, accouting,
mailing, presentation, database management, preparation of
banners, visiting cards, etc.

• The packages in Microsoft office and their purposes are as fol-


lows:

2.2 Features of MS Word


• MS Word may be used for preparation of letters, memos, books,
reports, theses, brochures and visiting cards.

59
Table 2.1: Tools in MS Office
Sl. Name Description
No. of tool /purpose
Helps preparation of docu-
1 Word
ments.
Preparation of spread-
2 Excel
sheets.
Preparation of presenta-
3 Powerpoint
tions.
Creation and maintenance
4 Access
of databases.
Tool for creating page
based publications. Useful
5 Publisher
for creation of reports, ban-
ners, ID cards, etc.
The program for creating
6 Onenote
and sharing notes.
Email client. It fetches
7 Outlook emails from several servers.
It can also send emails.

• MS Word supports the paradigm of ”WYSWYG” - which stands


for What You See, What You Get. It means the hard copy will
be similar to what is seen on screen.

• MS Word provides template documents for creating several


types of publications. You may choose a template, fill required
details to get a professional looking publication.

• MS Office supports a large number of images called clip arts.

• MS Word can take list from Excel or Access and create mail
merged document addressed to several persons individually.

• MS Word checks spelling (red underline below spelling errors)


and Grammar (green underline below grammatic mistakes).

• MS Word can handle tables, images and lists.

• MS Word supports water marks behind main text of the doc-


ument, as in the case of certificates.

COPA 60 Dr.V.Nagaradjane
2.3 Office button in MS Word
• The circular button located at top left corner of MS Word
window is the office button. In recent versions, office button
has been renamed to File ((Alt + F)).

• Office button contains the following menu items (Fig.2.3):

1) Save: Saves file (Ctrl + S or Alt + F + S).


– Save As: Saves another copy of the file with new name
(Alt + F + A).
2) Open: Open a file (Ctrl + O or Alt + F + O).
3) Close: Close current file (Alt + F + C).
4) Info: Show permissions, author name, version details,
pages, lines, words, duration of editing, etc. pertaining
to current file (Alt + F + I).
5) Recent: Show recently opened files (Alt + F + R).
6) New: Create a new document (Ctrl + N or Alt + F +
N). Templates may be chosen to provide a skeleton for
the document.
7) Print: Print the current document (Ctrl + P or Alt +
F + P). Printer, paper size, finishing details, etc. can be
controlled.

8) Save & Send: Save current document and send it


through email, save it on the web, share it to the blog,
(Alt + F + D).
9) Help: Help regarding MS Word (Alt + F + H or F1).
10) Options: Options help to control several features of
MS Word (Alt + F + T). Choosing Advanced − > Print
and removing the tick mark in front of ”Scale content
for A4 or 8.5’x11’ paper sizes is important after installing
windows. Otherwise all pages will be scaled to letter size
paper instead of A4 size paper. General, display, proof-
ing, save, language, advanced, etc. are common headings
displayed under Options.

COPA 61 Dr.V.Nagaradjane
Figure 2.1: Office menu in MS Word

11) Exit: Close all documents and exit MS Word (Alt + F


+ X).

2.4 Toolbars in MS Word


• Toolbars in MS Word are organized under the following menus:

1. Home (Alt + H)
2. Insert (Alt + N)
3. Page Layout (Alt + P)
4. References (Alt + S)
5. Mailing (Alt + M)
6. Review (Alt + R)
7. View (Alt + W)

• On pressing each menu, the toolbar related to that menu ap-


pears.

COPA 62 Dr.V.Nagaradjane
Figure 2.2: Home menu in MS Word

• The toolbar is organized into suitable groups with a heading


shown at the bottom of the toolbar.

• Pressing the square shaped button at the bottom of each item


in the toolbar opens a detailed menu related to that toolbar.

2.4.1 Home menu in MS Word


• Fig.2.4.1 shows the items contained in Home menu of MS
Word.

• Home menu contains many of the most essential items required


for formatting a document (Fig.2.4.1), as detailed below:

1. Clipboard (Alt + H + FO) - cut (Ctrl + X) or (Alt + H


+ X), copy (Ctrl + C) or (Alt + H + C), paste (Ctrl +
V) or (Alt + H + V) & format painter (Alt + H + FP).
2. Font style (Alt + H + FN) - bold (Ctrl + B) or (Alt
+ H + 1), italic (Ctrl + I) or Alt + H + 2), underline
(Ctrl + U) or (Alt + H + 3), strikethrough (Alt + H +
4), subscript (Ctrl + Plus) or (Alt + H + 5), superscript
(Ctrl + Shift + Plus) or (Alt + H + 6), font name (Alt
+ H + FF), font size (Alt + H + FS), fill colour (Alt +
H + I), font colour (Alt + H + FC).

COPA 63 Dr.V.Nagaradjane
Figure 2.3: Insert menu in MS Word

3. Paragraph formating (Alt + H + PG) - bullets (Alt + H


+ U) & numbering (Alt + H + N), multilevel list (Alt +
H + M), paragraph alignment (left (Ctrl + L) or Alt + H
+ AL), right (Ctrl + R) or (Alt + H + AR), centre (Ctrl
+ E) or Alt + H + AC) & justified (Ctrl + J) or (Alt +
H + AJ)), line spacing (Alt + H + K), borders (Alt + H
+ B), fill color (Alt + H + H), decrease indent (Alt + H
+ AO), increase indent (Alt + H + AI).
4. Styles (Alt + H + FY) - title, heading1, heading2, normal
(Alt + H + L) & change style (Alt + H + G).
5. Search - find (Ctrl + F) or (Alt + H + FD), replace (Ctrl
+ H) or (Alt + H + R), select (Alt + H + SL) & select
all (Ctrl + A) or (Alt + H + SL + A) options.

2.4.2 Insert menu in MS Word


• Fig.2.4.2 shows the items contained in Insert menu of MS
Word.

COPA 64 Dr.V.Nagaradjane
• Insert menu (Alt + N) contains items insertion of items like
pages, tables and images, as detailed below (Fig.2.4.2):

1. Page insertion - cover page (Alt + N + V), blank page


(Alt + N + NP) & page break (Alt + N + B).
2. Table insertion (Alt + N + T) - simple table, table by
rows and columns (Alt + N + T + I), draw table (Alt +
N + D), convert text to table (Alt + N + T + V), Excel
spreadsheet (Alt + N + T + X) & quick table (Alt + N
+ T + T).
3. Illustrations - pictures (Alt + N + P), clip art (Alt + N +
F), shapes (Alt + N + SH) [line, rectangle, circle, arrows,
flow chart, etc.]), chart (Alt + N + C), smart art (Alt +
N + M), screenshot (Alt + N + SC)).
4. Links - hyperlink (Alt + N + I), bookmark (Alt + N +
K), cross reference (Alt + N + RF).
5. Header & Footer - header (Alt + N + H), footer (Alt +
N + O), page number (Alt + N + NU).
6. Text - text box (Alt + N + X), quick parts (Alt + N +
Q), word art (Alt + N + I), drop cap (Alt + N + RC),
signature (Alt + N + G), date & time (Alt + N + D),
object (Alt + N + J).
7. Symbols - equations (Alt + N + EorAlt + N + E + I),
greek symbols and special symbols (Alt + N + UorAlt +
N + U + M).

2.4.3 Page Layout menu in MS Word


• Fig.2.4.3 shows the items contained in Page Layout menu in
MS Word.

• Page Layout (Alt + P) menu (Fig.2.4.3) contains several op-


tions related to page size and layout, as detailed below:

1. Theme - Theme (Alt + P + TH), Colors (Alt + P +


TC), Fonts (Alt + P + TF), effects (Alt + P + TE).

COPA 65 Dr.V.Nagaradjane
Figure 2.4: Page Layout menu in MS Word

2. Page Setup (Alt + P + SP) - margins (Alt + P + M),


orientation (Alt + P + O), size (Alt + P + SZ), columns
(Alt + P + J) or (Alt + P + J + C)), break (Alt + P +
B), line number (Alt + P + LN) & hyphenation (Alt +
P + H).
3. Page background - water mark (Alt + P + PW), page
color (Alt + P + PC) & page border (Alt + P + PB).
4. Paragraph (Alt + P + PG) - indent left (Alt + P + IL),
indent right (Alt + P + IR) & spacing before (Alt + P
+ SB) and space after (Alt + P + SA).
5. Arrange object - position (Alt + P + PO), text wrap (Alt
+ P + TW), bring forward (Alt + P + AF), selection pane
(Alt + P + AE), select para (Alt + P + AP), align (Alt
+ P + AA), group (Alt + P + G) & rotate (Alt + P +
AY)).

2.4.4 References menu in MS Word


• Fig.2.4.4 shows the items contained in References menu in MS

COPA 66 Dr.V.Nagaradjane
Figure 2.5: References menu in MS Word

Word.

• References (Alt + S) menu (Fig.2.4.4) contains several options


related to cross referencing of tables, images and citations, as
detailed below:

1. Table of Contents - table of contents (Alt + S + T), add


text (Alt + S + A), update table (Alt + S + U).
2. Foot notes (Alt + S + Q) - insert footnote (Alt + S +
F), insert endnote (Alt + S + E), next footnote (Alt +
S + O) & show notes (Alt + S + H)
3. Citaion & Bibliography - insert citation (Alt + S + C),
manage sources (Alt + S + M), style (Alt + S + L),
bibliography (Alt + S + B).
4. Captions - insert caption (Alt + S + P), insert table of
figures (Alt + S + G), update table (Alt + S + V), cross
reference (Alt + S + RF).
5. Index - mark entry (Alt + S + N), insert index (Alt + S
+ X), update index (Alt + S + D).

COPA 67 Dr.V.Nagaradjane
Figure 2.6: Mailings menu in MS Word

6. Table of authorities - mark citation (Alt + S + I), insert


table of authorities (Alt + S + RT), update table (Alt +
S + RU).

2.4.5 Mailings menu in MS Word


• Fig.2.4.5 shows the items contained in Mailings menu in MS
Word.

• Mailings (Alt + M) menu (Fig.??) is the source of the famous


mail merge function in MS Word. Mail merge functions may be
visualized as a high level fill in the blanks, which can produce
individualized messages from a general template. It has the
following options:

1. Create - envolopes (Alt + M + E), labels (Alt + M +


L).
2. Start Mail Merge - start mail merge (Alt + M + S), select
recepient (Alt + M + R) - type new list (Alt + M + R
+ N), use existing list (Alt + M + R + E), select from

COPA 68 Dr.V.Nagaradjane
Figure 2.7: Review menu in MS Word

outlook contacts (Alt + M + R + O) & edit recepient


list (Alt + M + D).
3. Write & Insert Fields - highlight merge fields (Alt + M +
H), address book (Alt + M + A), greeting line (Alt + M
+ G), insert merge field (Alt + M + I), rules (Alt + M
+ U), match fields (Alt + M + T), update labels (Alt +
M + B).
4. Preview Results - preview results (Alt + M + P), first
record (Alt + M + Q), previous record (Alt + M + M),
record number (Alt + M + W), next record(Alt + M +
X), last record (Alt + M + V).
5. Finish & Merge - finish & merge (Alt + M + F), merge
to new document, merge & print.

2.4.6 Review menu in MS Word


• Fig.2.4.6 shows the items contained in Review menu in MS
Word.

COPA 69 Dr.V.Nagaradjane
• Review (Alt + R) menu (Fig.2.4.6) helps to check spelling,
grammer and document statistics. It contains the following
options:

1. Proofing - spelling & grammer (Alt + R + S), research


(Alt + R + R), thesaurus (Alt + R + E), word count
(Alt + R + W).
2. Languages - translate (Alt + R + L), language (Alt + R
+ U).
3. Comments - new comment (Alt + R + C), delete (Alt +
R + D), previous record (Alt + R + V), next (Alt + R
+ N).
4. Tracking - track changes (Alt + R + G), final: show
markup (Alt + R + TD), show markup (Alt + R + TM),
reviewing pane (Alt + R + TP).
5. Changes - accept (Alt + R + A), reject (Alt + R + J),
previous (Alt + R + F), next (Alt + R + H).
6. Compare - compare (Alt + R + M).
7. Protect - block authors (Alt + R + PB), restrict editing
(Alt + R + PE).

2.4.7 View menu in MS Word


• Fig.2.4.7 shows the items contained in View menu in MS Word.

• View (Alt + W) menu (Fig.2.4.7) helps to customize the ap-


pearance of document:

1. Document Views - page layout (Alt + W + P), full screen


reading (Alt + W + F), web layout (Alt + W + L), outline
(Alt + W + U), draft (Alt + W + E).
2. Show - ruler (Alt + W + R), gridlines (Alt + W + G),
navigation pane (Alt + W + K).
3. Zoom - zoom (Alt + W + Q), 100 (Alt + W + J), two
pages (Alt + W + 1), (Alt + W + 2), page width (Alt
+ W + I).

COPA 70 Dr.V.Nagaradjane
Figure 2.8: View menu in MS Word

4. Window - new window (Alt + W + n), arrange all (Alt


+ W + A), split (Alt + W + S), view side by side (Alt
+ W + B), synchronous scrolling (Alt + W + YS), reset
window position (Alt + W + T), switch windows (Alt +
W + W).
5. Macros - Macros (Alt + W + M)

2.5 Creating, saving and formatting doc-


uments using M.S. Word
• When MS Word is opened without any argument, it displays a
blank document.

• MS Word provides the following online templates (available


only over an Internet connection) for creating new document:
(i)agenda, (ii)award certificate, (iii)business cards, (iv)resumes,
(v)budget, (vi)flier, (vii) brocher, (viii) visiting cards, (ix) cal-
endars, (x) reports/ books, etc.

COPA 71 Dr.V.Nagaradjane
• After opening a document, it is necessary to set paper size,
paper orientation (landscape or portrait) and margins on all
four sides, before entering text. These settings can be accessed
from Page Layout − > Page Setup (Alt + P + SP) menu.
• Line spacing should be set through Page Layout − > Paragraph
(Alt + P + PG) menu.

• Text alignment can be set to center (Ctrl + E), left (Ctrl +


L), right (Ctrl + R) or justified (Ctrl + J).
• Font face/name (Alt + H + FF), font size (Alt + H + FS),
font colour (Alt + H + FC) and background colour (Alt + H
+ I) may be set to appropriate values for given document.
• Tables, figures and equations may be assigned caption using
References-¿Insert caption (Alt + S + P). This will help MS
Word to create list of tables, list of figures and list of equations
automatically.
• To insert book title, chapter title, heading1, heading2, normal
text, sue appropriate icons available under Home − > Styles
menu (Alt + H + L). Using this menu will help in the insertion
of automatic table of contents.

• While typing references, use References − > Insert Citation


(Alt + S + C). This will help in the insertion of automatic
bibliography.
• To mark the words to be automatically indexed, use References
− > Mark Entry (Alt + S + N). This will help in automatic
insertion of index of words at the end of a document.
• Use Insert menu to insert table, picture, shapes, flow charts,
headers, footers, page numbers, word art, drop cap, equation
or symbol.
• To save a document, use File − > Save (Ctrl + S or Alt +
F + S).
• To save the document in a new name, use File − > Save As
menu (Alt + F + A).

COPA 72 Dr.V.Nagaradjane
2.6 Inserting objects in MS Word
• The most common objects used in MS Word are: (i)table,
(ii)picture, (iii)geometric shapes, (iv)clip arts, (v)equations,
(vi)lists.

• Table can be inserted from Insert − > Table menu (Alt + N


+ T) in MS Word. Table caption is placed above the table.
Use References− >Insert Caption (Alt + S + N) to insert
table caption.

• Pictures can be inserted from Insert − > Picture (Alt + N +


P) in MS Word. Picture caption is placed below the picture.
Use References − > Insert Caption (Alt + S + N) to insert
table caption.

• Geometric shapes like line, circle, rectangle, text box, clip art,
word art, flow chart symbols, etc. can be inserted from Insert
menu.

• Equation may be inserted using Insert − > Equation (Alt +


N + E) menu. Equation numbers should be inserted using
References − > Insert Caption menu (Alt + S + P), to help
automatic generation of the list of equations.

• To insert predefined art works, choose Insert − > Clip Art (Alt
+ N + F) menu. This permits several simple artworks to be
inserted in a document.

• Word art provides attractive size and shape for text headings.
To insert word art, click Insert − > Word Art (Alt + N +
RC) menu.

• To insert a drop cap (First letter having height of several lines),


use Insert − >Drop Cap (Alt + N + RC) menu.

• Inserting a list is very simple in MS Word. Type a number or


letter enclosed in parantheses [like (1)] or succeded by a right
paranthesis [like 1)]. This will induce MS Word to create a new
list. Use the options available under Home − > Paragraph to
customize the number format, letter format or bullet used for

COPA 73 Dr.V.Nagaradjane
the list. Although MS Word automatically inserts successive
numbers for list, specific values may be set by right clicking the
unwanted number and choosing Numbering − > Set Number-
ing Value and typing required number in the number field.

2.7 Inserting macros in MS Word


• Macros help to create custom commands in MS Word, which
will help us complete repeated works with ease. Imagine macro
as a pet dog, which can take care of repeated works, once the
initial training is complete.
• Macros may be assigned keystrokes or buttons.
• Initially, word does not show macros menu. Choose File − >
Word Options (Alt + F + T) menu, click Trust Center in
the left side pane, click Trust Center Settings and click Enable
all macros (not recommended, potentially dangerous code can
run).
• To record a new macro (e.g. to type Government ITI for
Women, Pondicherry, whenever Alt + W is pressed), open View
menu, click Macros, choose Record Macro (Alt + W + M +
R).
• Choose whether you create a button (left) or a keyboard short-
cut.
• Choose whether the macro should be available to all documents
or the present document only.
• Type a description of what the macro does and and press OK.
This starts the recording of macro. Mouse is disabled during
macro recording. Hence, use keyboard to control the docu-
ment.
• Simply carry out the work and allow the macro to learn what
you do.
• When your work is complete, choose View − > Macro − >
Stop Recording (Alt + W + M + R).

COPA 74 Dr.V.Nagaradjane
• Now, you can press the macro button placed at the title bar or
type required keystroke to invoke the macro and get your work
done.

2.8 Performing mail merge in MS Word


• Mail merge helps to make general purpose document targetting
several persons to look as if the document was prepared for
each individual separately, giving a feeling of trust and affinity.
• Prepare a document with blank spaces where individualized
items like name, address, gender, age, etc. are to appear.
• Prepare a list of using MS Excel or MS Access, with suitable
column names. The list could even be prepared using notepad,
sufficient that rows are separated by newline and columns are
separated by TAB.
• After completing the document, open Mailings − > Select Re-
cepients − > Use Existing List (Alt + M + R + E). Choose
the MS Excel, MS Access or notepad text document containing
the personal details. For MS Excel or MS Access name list, se-
lect work book name or table name (as appropriate) containing
the list.
• Now, choose Mailings − > Insert Merge Field (Alt + M + I)
and choose the appropriate column name to be filled in each
blank space.
• Choose Mailings − > Preview Results (Alt + M + P) to view
the mail merged results.
• Mail merge results for each record may be viewed by accessing
Mailing − > Preview Results tool bar and changing the record
number.
• A new word document containing all mail merge results can be
created using Mailings − > Edit Individual Documents (Alt +
F + E). This document may be saved under a different name.
Record range may be chosen for finishing the mail merge to
new document.

COPA 75 Dr.V.Nagaradjane
• The mail merge results may be printed using Mailings − >
Print Documents (Alt + F + P). Record range may be chosen
for finishing the mail merge to printer.

• The mail merge results may be sent through email to email


ID’s specified in the document (if included) using Mailings − >
Send E-mail Messages (Alt + F + S). For this option to work,
each row should have the email ID of the recepient.

2.9 Creating and using templates in MS


Word
• Template in MS Word may be visualized as a standard mould
using which several objects may be cast.

• After creating a document which is so well formatted that it is


fit to serve as the standard for other documents, choose File
− > Save As. In the save as dialog, click the triangular button
to the right of Save as type and choose Word Template.

• A word template has .dotx extension, instead of the usual ex-


tension of .docx for normal word documents.

• When a Word template is opened, edited changes can be saved


in a new word document with .docx extension.

• Templates are published magazines and journals to help the


authors typeset their content according to the style specified
in the template and suitable for their magazine or journal.

2.10 Page setup and printing documents


using Word
• The first work on creating a document is page setup and the
last work is to print or email that document.

• Page setup can be accessed using Page Layout − > Page


Setup (Alt + P + SP) menu.

COPA 76 Dr.V.Nagaradjane
• Page setup brings a dialog containing 3 panels, viz., Margins,
Paper & Layout.

• Margins panel in page setup dialog helps to specify left margin,


right margin, top margin and bottom margin. In addition to
the margins, gutter margin (for binding) and gutter position
(left or top) may also be specified.

• Margins panel in page setup dialog permits choosing paper ori-


entation (portrait [width is less than height] or landscape[width
is larger than height]), margin arrangement for multiple pages,
preview of margin setup and applicability of the new page setup.

• Paper panel in page setup dialog permits selection of paper size


(A4, letter, legal, etc.) and paper source.

• Layout panel of page setup dialog helps to choose whether


section starts on new page, header and footer placement and
vertical alignment of text and objects on page.

• Printing a document is possible by choosing File − > Print


(Ctrl + P) in the menu.

• The name of printer (which has already been installed), number


of copies, page ranges to be printed, type of printing to be
adopted for multiple copies (collated - divide by set, uncollated
- take given number of copies in each page before proceeding
to print the next page)

• Print dialog also permits access to printer properties, which


may control print resolution, colour mode (in case of colour
printer), finishing of pages, quality of print, etc.

• The print dialog also permits scaling of pages to suit available


paper size.

• Pressing the print button sends the document to the printer


and produces hard copy of the document.

COPA 77 Dr.V.Nagaradjane
COPA 78 Dr.V.Nagaradjane
Chapter 3

MS Excel

Syllabus
Introduction to Excel features and Data Types. Cell referenc-
ing. Use of functions of various categories, linking Sheets. In-
troduction to various functions in all categories of Excel. Con-
cepts of Sorting, Filtering and Validating Data. Analyzing data
using charts, data tables, pivot tables, goal seek and scenarios.
Introduction to Reporting.

3.1 Introduction to Excel features and Data


Types
3.1.1 Introduction to features of Excel
• Excel works on the basis of cells, one cell being the intersection
of a column and a row.

• Columns (vertically aligned dividers) have the alphabet names


(A,B,C, ... Z, AA, AB, ..., AZ, BA...).

• Rows have numeric identifier (1, 2, 3, ...).

• Cells are addressed by combination of column name - row num-


ber, e.g. A1 for the first cell, B6 for the cell at second column,
sixth row.

79
• Excel has a large collection of functions (entered in a cell after
typing = sign), which are helpful in data analysis and compu-
tations.

• Excel can sort and arrange data in easily readable format.

• Excel can draw charts (like pie, bar, column, scatter, etc.) to
help visualize data entered in cells.

• The latest version of Excel can have maximum of 10,48,576


rows and 16,384 columns. The maximum number of rows and
columns may vary from version to version.

• MS Excel can work with other applications like MS Word and


MS Access.

• MS Excel can be used for storage and manipulation of small


amount of data which may not qualify to occupy a database.

• MS Excel supports recording repeated actions and calling the


same action sequences with the help of macros.

• MS Excel supports full fledged programming using Visual Basic


for Applications (VBA).

• Each excel file is called a Workbook. Each workbook can have


several sheets.

• By default, sheets in MS Excel are Sheet1, Sheet2, etc. The


sheets can be renamed or copied by right clicking on sheet
name.

• MS Excel files have default extension of .xlsx.

• Macro enabled excel files have the extension of .xlsm.

• A cell in MS Excel can reference data in teh same sheet, other


sheet in the same workbook or a sheet in another workbook.

COPA 80 Dr.V.Nagaradjane
3.2 Data types in Excel
• Following types of data are available in MS Excel:

1) General - Can be number, text, date, time or any other type.

2) Number - number permits control of decimal places and group-


ing of digits.

3) Currency - Currency format permits control of decimal places,


digit grouping and prefixing of currency symbol.

4) Accounting - Permits control of number of digits and prefixing


of currency symbol.

5) Date - Permits selection of date format from several available


formats. The default date format used in India is DD/MM/YYYY.

6) Time - Permits selection time format.

7) Percentage - Displays a fraction (between 0 and 1) as a per-


centage. Decimal places of the percentage can be controlled.

8) Fraction - Permits display of decimal fraction into common


fraction or vulgar fraction.

9) Scientific - Displays numbers in exponential notation.

10) Text - Displays given data as text.

11) Special - Special type is useful for tracking list and database
values.

12) Custom - Number format may be customized using # (space


or digit. 0 - zero or digit). Any text enclosed in double quotes
is displayed as without any changes.

3.3 Cell referencing


• When the name of cell (like B5) is referenced in a formula, it
can be done in 3 different ways, as detailed below:

COPA 81 Dr.V.Nagaradjane
1. Relative referencing - dynamic row & column change mode
2. Semi-relative referencing - fynamic row & static column
mode or static row and dynamic column mode
3. Absolute referencing - static row & static column mode
• Relative referencing: In this mode, copying the formula to a
new cell (e.g., add 4 to columns & 3 to rows) causes the cell
reference to change relative to the new column (by adding the
same 4 to columns & 3 to rows to the reference made in the
formula).
• Semi-relative referencing: In this mode, either the row or col-
umn references are static, denoted by a $ symbol preceding the
row number or column name.
• Absolute referencing: In this mode, both column name and row
number are static and are preceded by a $ symbol. When the
formula is copied from one cell to another, the cell references
do not change.
a) Relative referencing: The formula = D3 + E3 is entered in
cell F3. On copying the formula to cell K4, the copied formula
becomes = I4 + J4, which references cells in relation to the
cell containing the formula.
b) Semi-relative referencing: The formula = $D3 + $E3 is en-
tered in cell F3. On copying the formula to cell K4, the copied
formula becomes = $D4 + $E4, which references rows in rela-
tion to the cell containing the formula, but freezes any changes
to the column name.
c) Semi-Relative referencing: The formula = D$3 + E$3 is en-
tered in cell F3. On copying the formula to cell K4, the copied
formula becomes = I3+J3, which references columns in rela-
tion to the cell containing the formula, but freezes any changes
to the row number.
d) Absolute referencing: The formula = $D$3 + $E$3 is entered
in cell F3. On copying the formula to cell K4, the copied
formula becomes = $D$3 + $E$3. Absolute system freezes all
cell references.

COPA 82 Dr.V.Nagaradjane
3.4 Use of functions of various categories
• Cube functions: These functions look up and analyze data
from a multi-dimensional database stored in a spreadsheet.

• Database functions: These functions help to access databases


from Excel.

• Date and Time functions: These functions display and ma-


nipulate date and time values.

• Engineering functions: Converts number from one base to


another, supports complex numbers, helps bit shifting and pro-
vides Bessel function.

• Financial functions: These functions support financial ac-


counting in Excel.

• Information functions: These functions support determina-


tion of the properties of data (whether blank, number, text,
etc.) contained in a cell.

• Logical functions: These are comparison functions which


help carry out Boolean logic on data.

• Lookup and reference functions: These functions help to


fund cell references using search, lookup, etc.

• Math & Trigonometry functions: These function help to


manipulate numbers and determine trigonometric values.

• Statistical functions: These functions help to calculate sta-


tistical quantities like average, mode, median, standard devia-
tion, etc.

• Text functions: These functions help to search, concatenate


and manipulate text strings.

COPA 83 Dr.V.Nagaradjane
3.4.1 Date functions

Takes the arguments YYYY, MM,


1 DATE
DD as input and returns a date.
Calculates difference between
given dates in years or months or
2 DATEDIF days. Takes the start date, end
date and the unit (”Y” for years,
”M” for months and ”D” for days.
Parses a text string and calculates
3 DATEVALUE
date.
4 DAY Returns day of month.
Returns the number of days be-
5 DAYS
tween two dates.
Calculates the number of days be-
6 DAYS360 tween two dates based on a 360-
day year
Returns the date which occurs par-
ticular number of months before or
7 EDATE after the given date. Takes date as
first argument, number of months
as the second argument.

COPA 84 Dr.V.Nagaradjane
Returns the date last day of month
given a start date and number of
8 EOMONTH months. Takes date as first argu-
ment, number of months as the
second argument.
Converts a serial number to an
9 HOUR
hour.
Returns the number of the ISO
10 ISOWEEKNUM week number of the year for a
given date.
Converts a serial number to a
11 MINUTE
minute.
Converts a serial number to a
12 MONTH
month
Returns the number of whole
13 NETWORKDAYS
workdays between two dates.
Returns the number of whole
workdays between two dates using
14 NETWORKDAYS.INTL
parameters to indicate which and
how many days are weekend days.
Returns the serial number of the
15 NOW
current date and time.
Converts a serial number to a sec-
16 SECOND
ond.
Returns the serial number of a par-
17 TIME
ticular time.

COPA 85 Dr.V.Nagaradjane
Converts a time in the form of text
18 TIMEVALUE
to a serial number.
Returns the serial number of to-
19 TODAY
day’s date.
Converts a serial number to a day
20 WEEKDAY
of the week.
Converts a serial number to a
21 WEEKNUM number representing where the
week falls numerically with a year.
Returns the serial number of the
22 WORKDAY date before or after a specified
number of workdays.
Returns the serial number of the
date before or after a specified
WORKDAY.
23 number of workdays using param-
INTL
eters to indicate which and how
many days are weekend days.
24 YEAR Converts a serial number to a year.
Returns the year fraction repre-
25 YEARFRAC senting the number of whole days
between start date and end date.

COPA 86 Dr.V.Nagaradjane
3.4.2 Engineering functions

Converts binary number to deci-


1 BIN2DEC
mal number.
Converts binary number to hex-
2 BIN2HEX
adecimal number.
Converts binary number to Octal
3 BIN2OCT
number.
Returns bitwise and for given num-
4 BITAND
bers.
5 BITLSHIFT Bitwise left shift.
6 BITOR Bitwise OR for given numbers.
7 BITRSHIFT Bitwise right shift of number.
8 BITXOR Bitwise XOR of given numbers.
Converts given value from one sys-
9 CONVERT tem of units to another (e.g. ”m”
to ”ft”).
Converts decimal number to bi-
10 DEC2BIN
nary number.
Converts decimal number to hex-
11 DEC2HEX
adecimal number.
Converts decimal number to Octal
12 DEC2OCT
number.
Tests whether given values are
13 DELTA
equal.
Converts hexadecimal number to
14 HEX2BIN
binary number.

COPA 87 Dr.V.Nagaradjane
Converts hexadecimal number to
15 HEX2DEC
decimal number.
Converts hexadecimal number to
16 HEX2OCT
octal number.
Creates a complex number from
17 COMPLEX
real and imaginary parts.
Displays the absolute value of
18 IMABS
complex function.
Returns imaginary part of complex
19 IMAGINARY
number.
Returns real part of complex num-
20 IMREAL
ber.
Returns conjugate of a complex
21 IMREAL
number.
Converts octal number to binary
22 OCT2BIN
number.
Converts octal number to decimal
23 OCT2DEC
number.
Converts octal number to hex-
24 OCT2HEX
adecimal number.

3.4.3 Cell functions

Returns a numeric identifier corre-


1 ERROR.TYPE
sponding to an error type.
returns information about the cur-
2 INFO
rent operating environment.
3 ISBLANK Returns true if a cell is blank.
Returns true if the cell contains an
4 ISERR
error (other than #NA).
5 ISEVEN Returns true if the number is even.
Returns true if the cell contains an
6 ISODD
odd number.
Returns true if the cell contains a
7 ISFORMULA
formula.

COPA 88 Dr.V.Nagaradjane
3.4.4 Cell functions

Returns true if the cell contains a


8 ISLOGICAL logical (true of false) value.
9 ISNA Returns true if there is #NA error.
Returns true if the cell contains
10 ISNONTEXT
anything other than text.
Returns true if the cell contains a
11 ISNUMBER
number.
Returns true if the cell contains a
12 ISREF
reference to another cell.
Returns true if the cell contains
13 ISTEXT
text.
14 N Converts given input to a number.
Returns a number corresponding
15 NA
to the #NA error type.
Returns a number corresponding
16 TYPE
to the data type of the cell.

3.4.5 Logical functions

Returns true only if all given con-


1 AND
ditions are true.
Returns true if at least one of the
2 OR
given conditions is true.
3 FALSE Returns FALSE logical value.
4 TRUE Returns TRUE logical value.
Contains 3 parts separated by
comma. In case the condition
given at first part is true, the sec-
5 IF
ond part is executed. Otherwise,
the condition given at the third
part is executed.

COPA 89 Dr.V.Nagaradjane
3.4.6 Math functions

Returns the absolute (positive)


1 value of the function, whether the
ABS
input number is positive or nega-
tive.
Inverse of sine value. Returns an-
2 ASIN gle in radian for given input value
(Input should be between 0 and 1).
Inverse of cosine value. Returns
angle in radian for given input
3 ACOS value (Input should be between 0
and 1).
Inverse of tangent value. Returns
4 ATAN angle in radian for given input
value.
Inverse of cot value. Returns an-
5 ACOT gle in radian for given input value
(Input should be between 0 and 1).
Inverse of tangent value from
given X and Y coordinates. Re-
6 ATAN2
turns angle in radian for given in-
put value.
Returns aggregate value like sum,
7 AGGREGATE
count, etc. from a database.

COPA 90 Dr.V.Nagaradjane
Converts Roman numberal to Ara-
8 ARABIC
bic numeral.
9 ASINH Returns inverse of hyperbolic sin.
Returns inverse of hyperbolic tan-
10 ATANH
gent.
Returns an integer just above the
11 CEILING given fractional number. e.g.
=CEIL(2.1) returns 3.
Returns an integer just below the
12 FLOOR given fractional number. e.g.
=FLOOR(2.99) returns 2.
Rounds a number to given number
of digits. e.g. =ROUND(2.99,1)
returns 3.0, =ROUND(2.629,2)
13 ROUND
returns 2.63, =ROUND(2.5,0) re-
turns 3.0, =ROUND(23154.25,-2)
returns 23200.
Rounds a number to given number
of digits. But it simply truncates
the trailing digits, without con-
sidering whether the truncated
digit is below 5 or not. e.g.
14 ROUNDDOWN =ROUNDDOWN(2.99,1) returns
2.9, =ROUNDDOWN(2.629,2)
returns 2.62, =ROUND-
DOWN(2.5,0) returns 2.0,
=ROUNDDOWN(23154.25,-2)
returns 23100..

COPA 91 Dr.V.Nagaradjane
Rounds a number to given num-
ber of digits. But it simply adds
one to the last digit, without
considering whether the truncated
digit is below 5 or not. e.g.
15 ROUNDUP
=ROUNDUP(2.99,1) returns 3.0,
=ROUNDUP(2.622,2) returns
2.63, =ROUNDUP(2.1,0) returns
3.0, =ROUNDUP(23124.25,-2)
returns 23200.
Returns number of possible com-
16 COMBIN binations for given number of ob-
jects n Cr .
Returns degree value of angle for
17 DEGREES
given angular value in radian.
Returns the nearest even number
18 EVEN
just above the given number.
Returns the nearest odd number
19 ODD
just above the given number.
Returns exponential value of a
20 EXP
given number.

COPA 92 Dr.V.Nagaradjane
21 FACT Returns factorial of given number.
22 FACTDOUBLE Returns factorial of given number.
Returns greatest common divisor
23 GCD
of the number.
Returns integer value just below
24 INT
the given real number.
Returns least common multiple of
25 LCM
given numbers.
Returns natural logarithm of given
26 LN
number.
Returns common logarithm of
27 LOG
given number.
Returns logarithm of given number
28 LOG10
to the base 10.
Returns determinant of given ma-
29 MDETERM
trix.
30 MINVERSE Returns inverse of given matrix.
Multipication result of given ma-
31 MMUL
trices.
Returns modulo reminder of divi-
32 MOD
sion.
Returns nearest value rounded to
33 MROUND
the given multiple.
34 PI Returns the value of PI (3.1415...).
Returns the the given power of a
35 POWER
number.

COPA 93 Dr.V.Nagaradjane
36 QUOTIENT Returns quotient of division.
Returns radians for given degree
37 RADIANS
angle.
38 RAND Returns a random number.
Returns a random number be-
39 RANDBETWEEN
tween given input numbers.
Returns Roman numeral for given
40 ROMAN
Arabic number.
41 SIGN Returns sign ± + or -.
Returns square root of the given
42 SQRT number (only positive numbers are
permitted in argument).
Returns subtotal of given num-
43 SUBTOTAL
bers.
44 SUM Returns sum of given numbers.
Returns sum of given numbers if
45 SUMIF
given condition is fulfilled.
Returns sum of squares of given
46 SUMSQ
numbers.
Truncates given number to integer
47 TRUNC
value.

COPA 94 Dr.V.Nagaradjane
3.4.7 Statistical functions

Returns average of abso-


1 AVEDEV lute/unsigned deviation of data
from the mean.
2 AVERAGE Returns average of given numbers.
Returns average of given numbers,
3 AVERAGEA
text and logical values.
Returns average of given numbers
4 AVERAGEIFS
which meet criteria specified.
Returns coefficient of correlation
5 CORREL
between given data sets.
Returns count of items in specified
6 COUNT
range.
Counts the number of items in
7 COUNTIF specified range, only if that item
meets specified criterion.
Counts the number of items in
specified range, only if that item
8 COUNTIFS
meets several criteria specified af-
ter the first argument.
Counts the number of arguments
9 COUNTA
provided to the function.
Counts the number of blank cells
10 COUNTBLANK
in specified range.

COPA 95 Dr.V.Nagaradjane
Returns sum of squares of devia-
11 DEVSQ
tions.
Returns the most probable next
12 FORECAST value in a set of dependent and in-
dependent variables.
Returns geometric mean of given
13 GEOMEAN
values.
Returns exponential forecast for a
14 GROWTH new X value based on given Y and
X values.
Returns rank based large value in
15 LARGE
a data set.
16 MAX Returns highest numeric value.
Returns highest value from the
17 MAXA given numbers, text or logical val-
ues.
Returns the median (the data that
18 MEDIAN occurs at the middle) of given set
of data.
Returns the least value of given
19 MIN
numbers.

Returns the least value of given


20 MINA
numbers, text and logical values.
Returns permutation for given
21 PERMUT
number of objects.
Returns rank for a given value in
22 RANK
comparison to a list of values.
Returns smallest number having
23 SMALL
given rank value.
Returns standard deviation of
24 STDEV
given list of numbers.

COPA 96 Dr.V.Nagaradjane
3.4.8 Text functions

Returns character having the given


code number under ASCII (Ameri-
1 CHAR
can Standard Code for Information
Interchange) system.
Returns numeric code of given
2 CODE
character.
3 CONCATENATECombines multiple string values.
Returns given number in currency
4 DOLLAR
format based on current locale.
5 EXACT Compares given text values.
Returns the index/ location count
6 FIND of the occurrence of first string
within the second (larger) string.
Formats a number with fixed num-
7 FORMAT
ber of decimal places.
Returns leftmost character from a
8 LEFT
string.
Returns rightmost character from
9 RIGHT
a string.
10 LEN Returns length of a string.
Converts given string to lowercase
11 LOWER
letters.
Converts given string to uppercase
12 UPPER
letters.
Capitalizes the first letter of each
13 PROPER
word in given string.
Takes a string for first argument.
Takes start location for replace-
ment, number of characters to be
14 REPLACE replaced as second and third ar-
guments. The given range is re-
placed using the string given in the
fourth argument.
Repeat the text given in first argu-
15 REPT ment for number of times specified
in second argument.
Returns the index/location of oc-
16 SEARCH currence of first text within second
text (case insensitive).

COPA 97 Dr.V.Nagaradjane
Takes target string, search string
and replacement string as argu-
17 SUBSTITUTE ments. Replaces second string
with the third string in the first
string.
Returns text value. Does not re-
18 T turn anything for number and log-
ical values.
Formats the number given in the
19 TEXT first argument according to format
specified in the second argument.
Removes spaces from the begin-
20 TRIM
ning and end of given string.
21 VALUE Converts text to number.

3.5 Sorting in MS Excel


• To sort data, select all the cells containing the data to be
sorted.

• Avoid the most common mistakes of selecting the just the sin-
gle column containing the values to be sorted and omitting
some columns which you might consider unnecessary of inclu-
sion. Such an error may result in separation of data from its
proper row members.

• Click Data − > Sort. In the dialog that opens, keep or remove
the tick mark against the field ”My data contains headers”.

• The sort options contain 3 columns. First, select the column


using which data needs to be sorted. In case the data con-
tains headers, the header name is displayed. Otherwise, column
name in alphabets (A,B,C,...) is displayed.

• In the second criterion, choose either values, cell color or cell


icon.

• In the third criterion, choose smallest to largest or largest to


smallest for number. Choose A to Z or Z to A for text data.

• Press sort button to sort the data.

COPA 98 Dr.V.Nagaradjane
3.6 Filtering of data in MS Excel
• For filtering data, the first row should contain headers.

• Select all the data including headers.

• Choose Data − > Filter. A triangular filter marker appears to


the right of each column in the first row of data.

• Clicking the triangular marker of any column permits sorting


in ascending or descending order, sorting by color, search for
specific values, applying several filter conditions for numbers
(like equals, does not equal, greater than, less than, less than
or equal to, between, top 10, above average, below average,
custom filter) and text (like equals, does not equal, begins with,
ends with, contains, does not contain,custom filter).

• Filter helps to select data based on convenient criterion.

3.7 Validation of data in MS Excel


• Select the cells (or column or row) in which data validation is
required.

• Choose Data − > Data Validation from the menu. Select Data
Validation.

• The data validation dialog appears.

• Select the data type from Allow criterion.

• Select the data criterion (between, not between, equal to, not
equal to, greater than, less than, greater than or equal to, less
than or equal to).

• Enter the values for validation.

• If you wish to display an error message for wrong input, click


Input Message tab and enter the title and content of error
message.

COPA 99 Dr.V.Nagaradjane
• Press OK to apply the condition.

• To indicate error in data by circle, choose Data − > Data


Validation − > Circle invalid data.

3.8 Analyzing data using charts in MS


Excel
• MS Excel supports column, line, pie, area, scatter and other
chart types like stock, surface, doughnut, bubble and radar.

• To display a chart like column, line, pie or bar, type X-Axis title
in the one column and Y-Axis title in the next column.

• Enter X-Axis values and Y-Axis values in the selected columns.

• Select the data (including title).

• Choose Insert menu. Click the type of chart like column, line,
pie, bar or scatter.

• The chart is inserted by Excel.

• Edit display parameters if necessary.

3.9 Data tables in MS Excel


• Using data table, Excel can be made to calculate the results
for a row, a column or an array.

• If you wish to create a column based data table, fill the input
values on the left. Calculate the result for the first row.

• Select the entire table, choose Data − > What If Analysis − >
Data Table.

• Choose first column in the input box (leave the row value
blank).

• Excel will fill up the remaining blank cells.

COPA 100 Dr.V.Nagaradjane


• Similarly, you can create a row based data table. You need
to create a row based input, calculate the result in the first
column of the next row. Choose first cell of the row in row
input (leave the column value blank) during creation of data
table.

• If you wish to create a matrix using data table, enter input


values in 2 cells, calculate the result value in a new cell.
• Create a row of inputs to the right of the result cell.
• Create a column of inputs below the result cell.
• Select the new matrix. Leave the row and column input cells
unselected.
• Choose What Data − > If Analysis − > Data Table.
• In the input box, select the cells for row and column input.
• When OK button is pressed, Excel fills all the cells of the matrix
based on your formula.

3.10 Pivot table in MS Excel


• Pivot table (and pivot chart) provide a means for summarizing
data presented in a table.
• Choose the table based on which pivot table needs to be cre-
ated.
• Choose Insert − > Pivot − > Pivot Table.
• MS Excel inserts a summary table in a new worksheet.

3.11 Goal seek in MS Excel


• Suppose you have a formula in a cell.
• If you wish to know the input for which the formula will yield
a desired result, goal seek will help you.

COPA 101 Dr.V.Nagaradjane


• Click the cell containing the formula. Choose Data − > What
If Analysis − > Goal Seek.

• In the first cell of the dialog, enter desired result.

• In the second cell, enter the address of the cell containing wrong
input, which needs to be adjusted to produce the desired new
result.

• Press seek button and see the suggested new input value.

• Press OK to accept the modified input and cancel to discard


the changes.

3.12 Scenarios in MS Excel


• Scenario helps to save different sets of input values and com-
pare the results of different scenario later on.

• To create a scenario, create a set of input values and calculate


the result.

• Choose Data − > What If Analysis − > Scenario. Enter a


title.

• Choose cells for which different sets of input values are to be


tested. Use control to select more than one cell.

• Save the scenario with an optional comment.

• Repeat the same steps to create more such scenarios. Save


different input values for each scenario.

• You can choose any of the scenario at a later time to see the
results.

COPA 102 Dr.V.Nagaradjane


Chapter 4

Image Editing, OpenOffice


and PowerPoint

Syllabus
Image editing, Introduction to the properties and editing of
images. Introduction to Open Office. Introduction to Power-
Point and its advantages. Creating Slide Shows. Fine tuning
the presentation and good presentation techniques.

4.1 Introduction to digital images


4.1.1 Types of image
• Images belong to the following 2 categories:

1. Raster image: Raster images have pixel as their ba-


sic unit. The most common types of raster image are
JPEG (Joint Photographics Experts Group), PNG (Pic-
ture Natural Group), TIFF (Tagged Image File Format),
GIF (Graphics Interchange Format), PNG (Portable Net-
work Graphics), etc.
2. Vector image: Vector images store details of geomet-
rical shapes and the parameters needed to redraw those
shapes. The most common formats used to store vector

103
images are SVG (Scalable Vector Graphics), CGM (Com-
puter Graphics
Metafile), etc.

4.1.2 Basics of digital images


• Digital images comprise of pixels arranged in rectangular grids.

• Each pixel is a dot in an image.

• In monitor display, the colour of each pixel is determined based


on RGB (Red-Green-Blue) system, HSL (Hue- Saturation- Light-
ness) system or HSV (Hue Saturation Value) system.

• For printing, CMYK (Cyan- Magenta- Yellow- blacK) colour


system is adopted.

• The transparency value of a pixel is represented by Alpha value


(usually 0 to 255).

• The spacing of pixels per inch on an image display is measured


using PPI (Pixels Per Inch).

• The spacing of pixels per inch on an image display is measured


using PPI (Pixels Per Inch).

4.1.3 Image editing


• Digital images are generated through digital photography, dig-
ital image editing software, scanning of painted images, etc.

• Image editing is necessitated due to:

(i) Photograph having low exposure.


(ii) Photos which require touchup.
(iii) Merging or splitting of digital images.
(iv) Resizing or scaling of digital images.
(v) Adjusting brightness of digital images.
(vi) Adjusting contrast of digital images.

COPA 104 Dr.V.Nagaradjane


(vii) Creating printable albums and layouts.

• Software packages like GIMP, Adobe Photoshop, CorelDraw,


etc. help in editing digital images.

4.2 Basic adjustments to an image


• Brightness and contrast values of an image may be ad-
justed using Image − > Adjustments − > Brightness/ Con-
trast menu. Brightness and contrast sliders may be used to
make changes to the image.

• Brightness, contrast and threshold values of an image may


be adjusted using Image − > Adjustments − > Levels menu.
The histogram values may be adjusted to make changes to the
image.

• Brightness and contrast values of an image may be adjusted


using Image − > Adjustments − > Curves menu. The straight
line on the histogram values may be adjusted up or down to
make changes to the image.

4.2.1 Tools available in Adobe Photoshop


• Rectangular Marquee Tool (M) in Adobe Photoshop per-
mits selection of rectangular/ elliptical areas. It also permits
single or single column marquee selection.

• Lasso Tool (L) in Adobe Photoshop permits selection of ir-


regular areas (like face from an image, hand from an image,
etc). Lasso tool provides Polygonal lasso and magnetic lasso
options. Whereas Lasso selection is made between a click and
release of mouse button, polygonal lasso permits placing sev-
eral points along a selection path. Magnetic lasso tool places
suitable points along the path of selection when the mouse is
simply dragged through a boundary.

• Quick selection tool (W) in Adobe Photoshop creates a


polygonal selection using the selection points. It provides Magic

COPA 105 Dr.V.Nagaradjane


wand option, which is very popular to select areas having a spe-
cific colour similarity.

• Crop tool (C) in Adobe Photoshop retains selected area and


discards unwanted portions.

4.2.2 Tools available in Adobe Photoshop


• Eye dropper tool (I) in Adobe Photoshop selects colour from
specific point.

• Spot healing brush tool (J) in Adobe Photoshop take sample


from one image (or area) and blend it with another image. Spot
healing tools can be configured to work as Healing brush tool,
Patch tool, Content-aware move tool or Red eye tool.

• Brush tool (B) in Adobe Photoshop helps to draw using se-


lected colour. Brush tool can be configured to work like Pencil
tool, Color replacement tool or Mixer brush tool.

• Clone stamp tool (S) in Adobe Photoshop takes a sample


from one area (Alt + Mouse click) and applies the same in a
new place (Mouse click). This tool has the option for Pattern
stamp tool.

• History brush tool (S) in Adobe Photoshop stores previous


sample and mixes the same with the newly painted layer.

• Eraser tool (E) in Adobe Photoshop removes contents of the


current layer and exposes the background layer. It has the
options for Background eraser tool and Magic eraser tool.

• Gradient tool (G) in Adobe Photoshop fills selected area with


a colour gradient, which gradually changes from one colour to
another. It has the option for Bucket fill tool.

• Blur tool in Adobe Photoshop reduces the visibility/ clarity of


selected portion of an image. It has the options for Sharpen
tool and Smudge tool.

COPA 106 Dr.V.Nagaradjane


• Dodge tool (O) in Adobe Photoshop reduces the sharpness of
an image. It has the option of Burn tool to increase sharpness
and Sponge tool to saturate or de-saturate colours.

• Pen tool (O) in Adobe Photoshop helps to draw a shape and


convert the shape to selection, path or vector mask or define
a custom shape by right clicking the closed shape.

• Horizontal type tool (T) in Adobe Photoshop helps to type


text elements. It has options for vertical type, horizontal type
mask and vertical type mask.

• Path selection tool (A) in Adobe Photoshop selects elements


bounded by a path. It has option for direct selection tool.

• Rectangle tool (U) in Adobe Photoshop draws a rectangle.


It has options for rounded rectangle, ellipse, polygon and line.

• Hand tool (H) in Adobe Photoshop drags a drawing (PAN).


It has option for Rotate tool.

• Zoom tool (Z) in Adobe Photoshop enlarges or shrinks the


visible area of image on the screen. It does not affect the size
of the original image.

4.3 Simple tasks in image editing


• Create maxi size photos: Choose File − > New (Ctrl + N).
Set the width to 12 inches and 8 inches and resolution to 200
pixels per inch. If Ruler is not visible, press Ctrl + R (View
− > Rulers). Drag the left line and top line of ruler to mid
width and mid height respectively. Drag and drop 4 photos
on 4 parts of the image. Adjust the size and other effects of
photos as you desire.

• Create Passport size photo layout: Choose File − > New


(Ctrl + N). Set the width to 12 inches and 8 inches and reso-
lution to 200 pixels per inch. Open the photo which should be
set to passport size. Use polygonal lasso (or any other tool)
to select the required portion of image. Select All (Ctrl + A)

COPA 107 Dr.V.Nagaradjane


and Copy (Ctrl + C) the photo. Create new image, paste the
photo. Choose Image − > Image Size and enter 3cm x 5cm
size (for passport size photo). Press Ctrl + A, Ctrl + C to
copy. Choose Original blank image (12in x 8in). Paste mul-
tiple times, drag the photo and arrange the photos without
wastage of space.

• Create a photo album: Choose File − > New (Ctrl + N).


Set width=16inch and height=10 inch (width and height may
change based on requirements). Set resolution to 300 dots per
inch. Drag the required photo and place it on the page. Resize
the photo and place it in a convenient position. Drag more
photos and organize them. Use blur tool or smudge tool or
sponge tool to blend the overlapping portions. Save the file.
Export it to JPG format. Create many such pages (one page
per file).

• Create a banner: Choose File − > New (Ctrl + N). Set


width=72 inch and height=48 inch (width and height may
change based on requirements). Set resolution to 300 dots
per inch. Draw a rectangle and choose suitable fill color for
background. Place text objects are required locations. Copy
and paste (or drag and drop) images. Resize the images to
required size. Save the document and export it to JPG type.

• Create a video using photos: Choose File − > New (Ctrl +


N). At the bottom of Adobe Photoshop window, video timeline
appears. Click the triangular button next to video frame icon
and choose Add media. Select all the photos to be used in
the video. Increase or decrease the duration for each photo
(default 5 seconds) by dragging the boundary of the photo.
Audio track can be added using the audio icon. Choose File
− > Export − > Render video. Enter file name and press
Render button. The video is exported to MP4 format.

4.4 Introduction to Open Office


• OpenOffice.org was an open source and free software released

COPA 108 Dr.V.Nagaradjane


Table 4.1: File formats for OpenOffice documents
No. File extension Purpose
1 .odt ODF Text.
2 .ott ODF Template Text.
3 .odm ODF Master Document.
4 .ods ODF Spreadsheet.
5 .ots ODF Spreadsheet Template.
6 .odg ODF Drawing.
7 .otg ODF Template Drawing.
8 .odp ODF Presentation.
9 .otp ODF Template Presentation.
10 .odf ODF Formula.
11 .odb ODF Database.

in the year 2000, as the successor to the proprietary office suite


called Star Office.

• OpenOffice contains a word processor (Writer), spreadsheet


(Calc), Presentation creator (Impress), drawing editor (Draw),
formula editor (Math) and a database tool (Base).

• File − > New menu in OpenOffice permits creation of all types


of document supported by OpenOffice.

• OpenOffice displays File, Edit, View, Insert, Format, Tools,


Window and Help menus by default. Some extra menus might
appear to suit the needs of specific programs.

• OpenOffice features similar to those offered by MS Office.

• OpenOffice can open and edit most of the MS Office docu-


ments.

• The native file formats of OpenOffice.org are presented in Table


4.1.

COPA 109 Dr.V.Nagaradjane


4.5 Introduction to Power Point
4.5.1 Introduction to Power Point
• Microsoft Powerpoint, (command name powerpnt), is a tool
for creating presentations.

• Powerpoint is included as a part of Microsoft Office.

• Powerpoint files have extension of .pptx. Files created using


Powerpoint in earlier versions of MS Office (up to 2003) had
extension of .ppt.

• Powerpoint helps to create slide by slide presentations.

• Powerpoint is helpful for making classroom presentations, busi-


ness proposals and progress reports.

4.5.2 Menu structure of Power Point


• Powerpoint has the following menu structure:

(i) File/ office:

1. Save (Alt + F + S, Ctrl + S)


2. Save As (Alt + F + A)
3. Open (Alt + F + O, Ctrl + O)
4. Close (Alt + F + C)
5. Info (Alt + F + I)
6. Recent (Alt + F + R)
7. New (Alt + F + N, Ctrl + N)
8. Print (Alt + F + P, Ctrl + P)
9. Save & Send (Alt + F + D)
10. Help (Alt + F + H)
11. Options (Alt + F + T)
12. Exit (Alt + F + X).

COPA 110 Dr.V.Nagaradjane


(ii) Home:

(a) Clipboard (Alt + H + FO), Paste (Alt + H + V, Ctrl


+ V), Cut (Alt + H + X, Ctrl + X), Copy (Alt + H +
C, Ctrl + C), Format Painter (Alt + H + FP).
(b) Slides, Insert (Alt + H + I, Ctrl + M), Layout (Alt + H
+ L), Reset (Alt + H + Q), Selection (Alt + H + T).
(c) Font (Alt + H + FN), Font Face (ALt + H + FF),
Font Size (Alt + H + FS), Font Grow (Alt + H + FG),
Font Decrease (Alt + H + FK), Bold (Alt + H + 1, Ctrl
+ B), Italic (Alt + H + I, Ctrl + I), Underline (Alt + H +
U, Ctrl + U), Text Shadow (Alt + H + 5), Strikethrough
(Alt + H + 4), Character spacing (Alt + H + 6), Change
case (Alt + H + 7, Shift + F3), Font Color (Alt + H +
FC).
(d) Paragraph (Alt + H + PG), Bullets (Alt + H + U),
Numbering (Alt + H + N), Decrease list level (Alt + H
+ AO), Increase list level (Alt + H + AI), Align left (Alt
+ H + AL, Ctrl + L), Align Right (Alt + H + AR, Ctrl
+ R), Justify (Alt + H + AJ, Ctrl + J), Columns (Alt
+ H + J), Line Spacing (Alt + H + K), Text direction
(Alt + H + AX), Align text (Alt + H + AT), Convert to
Smart Art Graphic (Alt + H + M).

(e) Drawing (Alt + H + O), Shapes (Alt + H + SH),


Arrange (Alt + H + G), Shape Quick Styles (Alt + H +
SS), Shape Fill (Alt + H + SF), Shape Outline (Alt + H
+ SO), Shape Effects (Alt + H + SE).
(f) Editing, Find (Alt + F + FD, Ctrl + F), Replace (Alt
+ H + R, Ctrl + H), Select (Alt + H + SL), Select All
(Ctrl + A).

(iii) Insert:

(a) Table (Alt + N + T).


(b) Images, Picture (Alt + N + P), Clip Art (Alt + N + F),
Screenshot (Alt + N + SC), Photo (Alt + N + A).

COPA 111 Dr.V.Nagaradjane


(c) Illustrations, Picture (Alt + N + SH), Smart Art (Alt
+ N + M), Chart (Alt + N + C).
(d) Links, Hyperlink (Alt + N + U), Action (Alt + N + K).
(e) Text, Text Box (Alt + N + X), Header & Footer (Alt +
N + H), Word Art (Alt + N + W), Date & Time (Alt +
N + D), Slide Number (Alt + N + SN), Object (Alt +
N + J).
(f) Symbols, Equation (Alt + N + E), Symbol (Alt + N +
U)

(iv) Design:

(a) Page Setup, Page Setup (Alt + G + S), Slide Orienta-


tion (Alt + G + O).
(b) Themes, Colours (Alt + G + TC), Fonts (Alt + G +
TF), Effects (Alt + G + TE), More (Alt + G + H).
(c) Background (Alt + G + G), Background Styles (Alt
+ G + B), Slide Background (Alt + G + M)

(v) Transitions

(a) Preview Preview (Alt + K + P, F5)


(b) Transition, More (Alt + K + T), Effect Options (Alt +
K + O).
(c) Timing, Sound (Alt + K + U), Duration (Alt + K + E),
Apply to all (Alt + K + L), On mouse click (Alt + K +
M), After (Alt + K + F).

(vi) Animations

(a) Preview, Preview (Alt + A + P), Animations (Alt + A


+ M), Shapes (Alt + A + S), Effect Options (Alt + A
+ O).
(b) Advance Animation, Add Animation (Alt + A + AA),
Animation Pane (Alt + A + C), Trigger (Alt + A + AT),
Animation Painter (Alt + A + AP).

COPA 112 Dr.V.Nagaradjane


(c) Timing, Start (Alt + A + T), Duration (Alt + A +
DU), Delay (Alt + A + DE), Move Earlier (Alt + A +
E), Move Later (Alt + A + L).

(vii) Slide Show


(a) Start Slide Show From Beginning (Alt + S + B, F5),
From Current (Alt + S + C, Shift + F5), Broadcast Slide
Show (Alt + S + D), Slide show (Alt + A + M).
(b) Setup Setup Slide Show (Alt + S + S), Hide Slide (Alt
+ S + H), Rehearse Timings (Alt + S + T), Record Slide
Show (Alt + S + N), Play Narrations (Alt + S + P), Use
Timings (Alt + S + U), Show Media Controls (Alt + S
+ W).
(c) Monitors Resolution (Alt + S + R), Show On (Alt + S
+ O), Use Presenter View (Alt + S + V).
(viii) Review
(a) Proofing, Spelling (Alt + R + S), Research (Alt + R +
R), Thesaurus (Alt + R + E).
(b) Language, Translate (Alt + R + 2), Language (Alt + R
+ U).
(c) Comments, Show Markup (Alt + R + M), View Com-
ment (Alt + R + C), Edit Comment (Alt + R + T),
Delete (Alt + R + D), Edit Comment (Alt + R + T),
Previous (Alt + R + V), Next (Alt + R + N).
(d) Compare, Compare (Alt + R + G), Accept (Alt + R +
A), Reject (Alt + R + T), Previous (Alt + R + F), Next
(Alt + R + H), Preview Pane (Alt + R + I), End Review
(Alt + R + W).

4.6 Creating Slide Shows


• Slide show can be created by choosing File − > New from
menu or by pressing Ctrl + N/ Alt + F + N.
• Presentation starts with a single slide.

COPA 113 Dr.V.Nagaradjane


• Choose suitable design for the presentation from Design menu.
Different slide colours and designs are available.

• Choose Headers and Footers from Insert − > Text − > Header
& Footer (Alt + N + H). Set appropriate values for header and
footer.

• First slide requires name of presentation, author name and


other details related to the presentation.

• Insert new slide by choosing Home − > Slides − > Insert or


pressing Ctrl + M/ Alt + H + I.

• The new slide has a caption. Fill appropriate caption.

• Text can be typed in the contents area. If table or image is


required, moving the mouse on the contents permits changing
the display area to table or image.

• Content layout in a slide can be changed by from design menu.

• Slide transition effects may be controlled using Transitions − >


Transition menu.

• Animation for slide transition may be applied from Animations


− > Preview − > Animations or Animations − > Preview
− > Shapes or Animations − > Preview − > Effect Options.

• Slide show can be started from current slide (Shift + F5) or


from the beginning (F5). To stop presentation, press Esc key.

• Mistakes in spelling are underlined in red colour. Spelling mis-


takes can be corrected by choosing Review − > Proofing − >
Spelling from menu or by pressing Alt + R + S.

4.7 Fine tuning a presentation


• Presentation may be made to change slides at specified interval
automatically using Animations − > Timing − > Duration.

COPA 114 Dr.V.Nagaradjane


• Specified tone may be permitted to play at the time of each
slide transition using Transitions − > Timing − > Sound.

• Audio may be recorded for each slide using Slide Show − >
Setup − > Record Narration (Alt + S + N). This audio plays
when the slide is presented. Recording may be verified using
Slide Show − > Setup − > Play Narration (Alt + S + P).

• Search may be carried out using Home − > Editing − > Find
(Ctrl + F/ Alt + H + FD).

• Replace may be carried out using Home − > Editing − >


Replace (Ctrl + H/ Alt + H + R).

4.8 Good presentation techniques


• Choose contrasting background and foreground colours (light
background and dark foreground OR dark background and light
foreground).

• Choose mild animations for slide transition. Fast and repeating


animations create irritation to the audience.

• Transition effects may be applied uniformly to all slides. Differ-


ent transition effect for each slide might distract the attention
of the audience.

• Text in each slide should be large enough for the audience to


read without strain.

• In case of automated slide transition in presentation, the du-


ration should be sufficient for even the slowest reader to read/
observe the slide.

COPA 115 Dr.V.Nagaradjane


COPA 116 Dr.V.Nagaradjane
Chapter 5

Database Management
System (DBMS)

Syllabus
Concept of DBMS, RDBMS, Data Models, Concept of DBA,
Database Users, Database Schema, Designing Database using
Normalization Rules, Various data types Data integrity, DDL,
DML and DCL statements, Enforcing Primary key and foreign
key, Adding Indices, Concepts of Transactions, ACID Property
of Transaction, Constraints, Joining of tables, Sub Queries,
Functions used in query like sum, average, max, min, count
etc.

5.1 Data, information and databases


5.1.1 Data
• Information collected for storage, reference and analysis pur-
pose is called data.

• Data may be in the form of digital text or numbers.

• Data may be stored in paper format or in electronic storage.

• Datum is the singular form for the word data.

117
• Data related to financial transactions is used for accounting.

• Survey is a systematic method for data collection.

• Specialized software for storage, analysis and retrieval of data


is called Database Management System (DBMS).

5.1.2 Information
• Details collected about an particular object is called informa-
tion.

• While data can be a collection of unrelated details, information


has some common theme.

• Information is always used in singular form.

• Storage and transmission of information is the main use of


communication technology in the modern era.

• Digital information may be stored in hard drive, optical drive,


SD card, pen drive, cloud storage or data centre.

5.1.3 Database
• The system for storage and retrieval of data in digital format
is called database.

• Database can be stored in a single computer or in multiple


computers.

• Database makes the storage and retrieval of data easy for the
client.

• Databases are of the following types:

1. Navigational or Hierarchical database - 1960-1970


2. Relational Database - Edgar Codd - 1970 - SQL (Struc-
tured Query Language)
3. Object Oriented Database Management System (OODBMS)
- 1990

COPA 118 Dr.V.Nagaradjane


Figure 5.1: Data Base Management System (DBMS)[6]

4. NoSQL - 2000 - Fast, unstructured, inconsistent - Mostly


used by Social Media platforms.
5. NewSQL - 2000 - Combination of NoSQL engine with
SQL interface.

5.2 Concept of DBMS and RDBMS


• Data Base Management System (DBMS) was invented for stor-
ing and retrieving information in tables.

• Each table has columns (which are given names) and rows,
which represented information.

• All data in DBMS was usually packed in a single table.

• Since a single table had to store all information, in any given


row, may columns remained without value.

• DBMS like DBase, Foxpro, etc. made data management easier.

• DBMS were inherently inefficient in storing data. The rela-


tional system superceded the DBMS.

• Relational Data Base Management System (RDBMS) was an


evlution of DBMS.

COPA 119 Dr.V.Nagaradjane


Figure 5.2: RDBMS[7]

• The RDBMS system was proposed by Edgar Codd of IBM in


the year 1970.

• Edgar Codd stipulated 13 rules, numbered from Rule 0 to Rule


12, which are to be enforced by any RDBMS.

• The concept of set theory and relations were applied to database


tables and the same was called RDBMS.

• RDBMS supports many tables, each table related to the other


using some key column.

• RDBMS allows inner join, outer join and sub-query when se-
lecting data.

• RDBMS madates that all data operations should be carried out


through Structured Query Language (SQL).

COPA 120 Dr.V.Nagaradjane


Figure 5.3: Data Models[8]

5.3 Data Models


1 RDBMS: Relational Data Base System (RDBMS) is used in
most of the commercial software applications. RDBMS is reli-
able, fast and flexible. The security model of RDBMS is also
makes it suitable for enterprise software applications.
2 Entity Relationship Model: Entities, also called objects, are
created. Relations between entities are defined. This entity
relationship model was proposed by Peter Chen in 1976. An
entity named ’student’ may have relationship sets named ’stu-
dent roll number’, ’student name’, ’student dob’, etc.
3 Object Relational Model: Entity Relational model was ex-
tended with the name of Object Relational Model using Object
oriented concepts of methods, encapsulation, inheritance, etc.
4 Semi-structured model: Semi-structured data model does
not enfoce particular column structure for information. Each
item has got different structure. Structure is defined as and
when needed using XML (eXtensible Markup Language).

5.4 Popular Database Engines


1 Oracle: Oracle is one of the most popular database software.
Oracle is fully compliant with all the rules applicable for Rela-

COPA 121 Dr.V.Nagaradjane


tional Database Management System (RDBMS). Oracle is the
platform preferred by many professional organizations.

2 Microsoft SQL Server: Microsoft SQL Server is fast grow-


ing platform for database management. It provides fast perfor-
mance and is available for Windows, Linux and Mac operating
systems. It provides easy integration with MS Excel and other
software packages.

3 IBM DB2: IBM DB2 is a high performance database en-


gine providing back end services for many business organiza-
tions and insurance companies. IBM was the leader in the field
of Relational Database Management, since Edgar Codd, was
an employee of IBM and DB2 was one of the first relational
database systems.

4 Teradata: Teradata supports large scale databases and pro-


vides fast data analytics to help in business decision making.

5 MySQL: MySQL was developed by MySQL AB, bought by


Sun Microsystems and bought again by Oracle. MySQL is an
open source database engine. MySQL is the preferred database
system for web based applications.

6 PostgreSQL: PostgreSQL is an enterprise grade RDBMS and


OODBMS available under open source licensing.

7 MongoDB: MongoDB is a NOSQL database engine. Mon-


goDB has the advantage of speed and flexibility and is used
by social media platforms where speed and flexibility are more
important than data integrity.

8 SAP ASE: SAP (formerly Sybase) Adaptive Server Enterprise


(ASE) is a fast relational database system.

9 Informix: Informix is an object oriented database system and


supports NoSQL features. It is owned by IBM.

10 Microsoft Access: Microsoft Access is suitable for desktop


based database management. It provides facilities to create
forms and reports.

COPA 122 Dr.V.Nagaradjane


11 SQLite: SQLite is a light weight database engine used for data
storage in mobile operating systems like Android, iOS, etc.

5.5 Codd’s Rules for RDBMS


• Rule 0 - Foundation rule: A relational database system must
be able to manage data entirely through relational rules.

• Rule 1 - Information rule: data in a database should be held


only in table.

• Rule 2 - Guaranteed access rule: Each and every datum


should be accessible through a combination of table, key and
column.

• Rule 3 - Null value rule: Absence of data should be repre-


sented through null value, irrespective of data type.

• Rule 4 - Active online catalogue rule: Table schema should


also be stored in tables and should be accessible through SQL.

• Rule 5 - Comprehensive data sublanguage rule: Database


should be accessed only through data sublanguage (SQL). No
other mode of access is permitted.

• Rule 6 - View updating rule: All views theoretically updat-


able should be updatable by the system.

• Rule 7 - High level insert, update and delete rule: The


data sub-language should support insert, update and delete
operations in addition to select option.

• Rule 8 - Physical data independence: The mode of physical


storage media and structure of media should not affect the data
sub-language.

• Rule 9 - Logical data independence: Any application ac-


cessing the data should be unaffected by the changes to schema
used for data tables.

COPA 123 Dr.V.Nagaradjane


• Rule 10 - Integrity independence: Database must be inde-
pendent of the application using the data.

• Rule 11 - Distribution independence: End user must not


feel any difference between data stored in local media and data
stored in several locations (over the network).

• Rule 12 - Non-subversion rule: Data must not be manip-


ulated through any mode other than the data sub-language
(SQL).

5.6 Key terms related to RDBMS


1 RDBMS: Relational Database Management System. It is
compliant with Codd’s rules and is accessed through SQL.

2 SQL: Structured Query Language - the sub-language used to


work with RDBMS.

3 Database: A collection of tables used to store data.

4 Table: A group of columns used to store data related to an


individual entity.

5 Column: One subhead for storing data in a table (like name,


mobile number, email id, etc.)

6 Row or Record: One set of information relating to an object


which fills up all the columns with data values (including null
value), like (’Krish’, ’345345345’, ’[email protected]’).

7 Row: One set of information relating to an object which fills


up all the columns with data values (including null value), like
(’Nameera’, ’345345345’,
[email protected]’).

8 Data Type: A column may have a data type. Common data


types supported by MySQL are char, varchar, int, date, time,
datetime, bigint, double, clob, blob. Different database servers
support slightly different names for data types.

COPA 124 Dr.V.Nagaradjane


Figure 5.4: Data Base Administrator’s Roles[9]

9 Primary key: The main column used for indexing and search-
ing data is called primary key. Primary key does not support
duplicate values.

10 Foreign key: The primary key of a different table used in


another table for relational, searching and indexing purposes is
called foreign key. Foreign key permits duplicate values.

11 Constraints: NOT NULL, AUTO INCREMENT, UNIQUE,


DEFAULT, PRIMARY KEY, FOREIGN KEY, INDEX etc. are
some of the constraints used to fill columns with valid data.

5.7 Data Base Administrator (DBA)


• Data Base Administrator (DBA) designs databases and tables.

• DBA decides the structure of table, called schema of table.

• DBA is responsible for creating relationships between tables.

• DBA creates user id and passwords for use by others.

• DBA is responsible for creating backup at periodic intervals.

• DBA restores data from backups whenever necessary.

COPA 125 Dr.V.Nagaradjane


• DBA is responsible for overall maintenance of the RDBMS
engine.

5.8 Data Base user


• Database users have a login id and password.

• Users login and perform tasks within their assigned rights.

• Some users can create databases and tables (just like admin),
some can alter tables, some can only insert data or select data,
some can only view data.

• Rights for each user can be granted or revoked by the DBA.

• Normal users can be dropped (removed) by the DBA.

• To create a new user name ’krish’, the DBA would run the
following mysql query:
CREATE USER ’krish’@’localhost’ IDENTIFIED BY ’password’;

• There are previleges to CREATE, SELECT, INSERT, UPDATE,


DELETE and DROP for normal users. e.g., DBA may grant
create, select and insert previleges to krish using the following
query:
GRANT CREATE, SELECT, INSERT ON *.*
TO ’krish’@’localhost’;

• Using REVOKE in place of GRANT in the above query will


revoke permissions. To remove create and insert permissions,
the following query will work:
REVOKE CREATE,INSERT ON *.*
TO ’krish’@’localhost’;

• Finally, a user may be removed from the list of users using drop
command. The following query removes our user account:
DROP USER ’krish’@’localhost’;

COPA 126 Dr.V.Nagaradjane


Figure 5.5: Table Schema[10]

5.9 Schema
• Schema describes the structure of a database table.

• Normally, the column names, data types and constraints form


the logical schema for table.

• The storage allocation and file/ disk related activities consti-


tute the physical schema.

• In mysql, decribe command displays the table schema. e.g., to


display the structure of a table named ITI, one may issued the
following SQL command: DESCRIBE ITI;

5.10 Rules for designing good tables


1 Determine the purpose of the database.

2 Organize the information to be stored in the database.

COPA 127 Dr.V.Nagaradjane


3 Divide the information into suitable tables.

4 Define column values and primary key.

5 Define relationships between tables.

6 Normalization is the process of defining the columns required


and methodically grouping them into suitable tables.

7 The purpose of normalization is to create a table in such a way


that each column may be closely related to the other.

8 When certain columns repeat with duplicate values, those columns


may be divided into separate tables.

9 Primary key is the unique identifier for each table. Values in


primary key column are to be unique (to occur only once).

9 Foreign key holds reference to primary key of another table.

5.11 Normalization of tables


• The process of starting with all required columns and finishing
with different tables and relationships is called Normalization.

• Normamization is applied in 5 different stages called Normal


Forms as follows:

1. 1NF or First Normal Form: Define column names and


data types.
2. 2NF or Second Normal Form: Remove repetition of
data.
3. 3NF or Third Normal Form: Define a primary key for
each table.
4. 4NF or Fourth Normal Form: Divide unrelated columns
of table into separate tables.
5. 5NF or Fifth Normal Form: If columns in a table can
be divided into separate tables connected by appropriate
keys, the table should be further divided.

COPA 128 Dr.V.Nagaradjane


5.12 Integrity rules and constraints in a
table
1 Domain Integrity: Specifying suitable constraints and setting
values permitted and not permitted in a table is called domain
integrity. For example, specifying that ID is a primary key and
has auto increment attributes is one way of specifying domain
integrity.
2 Entity integrity: Every table should have a primary key.
3 Referential integrity: Value referred in a foreign key column
should be present in some other table as a value in primary
column.

5.13 Relationships in tables


1 One to many relationship: One primary key column of a
table getting referred many times through foreign key value in
another table (patient.ID and visit. PATIENT ID columns in
patient and visit tables).
2 Many to many relationship: The appearance of many keys
of first table against many other keys of a second table is called
many to many relationship (Many product IDs of product table
appearing in several order IDs of order table is an example of
many to many relationship).
3 One to one relationship: If one key value of first table ap-
pears only once in a second table, it is called one to one re-
lationship (the relation between personal.AADHAR and con-
tact.AADHAR is one to one and cannot have more than one
relationship).

5.14 Data types in MySQL


5.14.1 String datatypes
1 CHAR(n): Character data type with n characters (fixed).

COPA 129 Dr.V.Nagaradjane


Maximum length: 255 characters.

2 VARCHAR(n): Variable number of characters. Maximum


length: 65,535.

3 BINARY(n): Stores binary bytes (instead of human readable


strings).

4 VARBINARY(n): Stores variable number of binary bytes (in-


stead of human readable strings).

5 TINYBLOB: Stores up to 255 binary bytes of data.

6 TINYTEXT: Stores up to 255 characters of data.

7 TEXT(n): Stores up to 65,535 characters of data.

8 BLOB(n): Stores up to 65,535 Binary Large OBjects (BLOB)


of data.

9 MEDIUMTEXT: Stores up to 16,777,215 Characters of data.

10 MEDIUMBLOB: Stores up to 16,777,215 Binary Large OB-


jects (BLOB) of data.

11 LONGTEXT: Stores up to 4,294,967,295 Characters of data.

12 LONGBLOB: Stores up to 4,294,967,295 Binary Large OB-


jects (BLOB) of data.

13 ENUM(”one”,”two”,”three”): Enum data type creates a


column whose data can have one of the given values.

12 SET( ”one”, ”two”, ”three” ): Set creates a data type


where the columns can have any one or combination of val-
ues defined inside the set (for the above type, ”one, two”,
”one,three”, ”one,two,three”, ”two,three” are some of the per-
missible values for given column).

COPA 130 Dr.V.Nagaradjane


5.14.2 Numeric datatypes
1 BIT(n): Can hold bit values. Maximum size is 64 bits.

2 TINYINT: Can hold integer values in the range of -128 to


+127 or 0 to 255.

3 BOOL or BOOLEAN: TRUE or FALSE value (0 - FALSE, ̸=


0 - TRUE).

4 SMALLINT: Integer values of -32768 to 32767 (signed) or 0


to 65535 (unsigned) may be stored.

5 MEDIUMINT: Integer values of -8388608 to 8388607 (signed)


or 0 to 16777215 (unsigned) may be stored.

6 INT or INTEGER: Integer values of -2147483648 to 2147483647


(signed) or 0 to 4294967295 (unsigned) may be stored.

7 BIGINT: Integer values of -9,223,372,036,854,775,808 to


9,223,372,036,854,775,807 (signed) or 0 to
18,446,744,073,709,551,615 (unsigned) may be stored.

8 FLOAT(size, d): Stores floating point numbers of given size


with d decimal places. It will be removed in future versions.

9 DOUBLE(size, d): Can store decimal numbers of given size


with d decimal places.

10 DEC(size, d) or DECIMAL(size, d): Precise data type for


handling decimal numbers.

5.14.3 Date and Time datatypes


1 DATE: Holds date in ’yyyy-mm-dd’.

2 DATETIME: Holds date and time in the format ’YYYY-MM-


DD hh:mm:ss’.

3 TIMESTAMP: Number of seconds since 01-Jan-1970 (UNIX


epoch)).

4 TIME: Time value in hh:mm:ss format.

COPA 131 Dr.V.Nagaradjane


5 YEAR: Four digit year values may be stored. e.g., ’2022’.

5.15 Queries and their uses


1 DDL - Data Definition Language: The commands used to
create or alter databases and tables is called DDL. Typical DDL
commands are:

1. create database ITI;


2. create table TRAINEE (reg no varchar(14) primary key,
name varchar(50), dob date not null, mark int not null
default 0, max mark int not null default 1);
3. alter table trainee add column percentage double default
0 after max mark;
4. drop table TRAINEE;
5. drop database ITI;

2 DML - Data Manipulation language: Helps to insert, up-


date and delete data values.

1. insert into trainee values(’001784000132’, ’Mala’, ’2002-


03-19’, 460, 500, 92.00);
2. update trainee set name=’Malarvizhi’ where reg no =
’001784000132’;
3. delete from trainee where reg no=’001784000132’;

3 DQL - Data Query Language: SQL commands used to


select data from tables falls under the category of DQL. Typical
DQL commands are:

1. select reg no, name, dob from TRAINEE


where name=’Ramakrishnan’;
2. select reg no, name, dob from TRAINEE
where reg no=’001784000132 ’;
3. select * from TRAINEE order by dob;
4. select * from TRAINEE order by dob DESC;

COPA 132 Dr.V.Nagaradjane


5. select * from TRAINEE where
name like ’Ra%’ order by dob;
6. select * from TRAINEE where name like ’%am%’ order
by dob;
7. select average(percentage) from TRAINEE;
8. select average(percentage) from TRAINEE
group by dob;
9. select average(percentage) from TRAINEE
group by dob order by percentage;
10. select average(percentage) from TRAINEE
having dob > ’2000-01-01’ group by dob order by per-
centage;

4 DCL - Data Control Language: Used for database adminis-


tration functions like creating user, changing password, grant-
ing rights, revoking rights, etc.

1. To create a new user name ’krish’, the DBA would run


the following mysql query:
CREATE USER ’krish’@’localhost’ IDENTIFIED BY ’pass-
word’;
2. There are previleges to CREATE, SELECT, INSERT, UP-
DATE, DELETE and DROP for normal users. e.g., DBA
may grant create, select and insert previleges to krish us-
ing the following query:
GRANT CREATE, SELECT, INSERT ON * . * TO ’kr-
ish’@’localhost’;
3. Using REVOKE in place of GRANT in the above query
will revoke permissions. To remove create and insert per-
missions, the following query will work:
REVOKE CREATE,INSERT ON * . * TO ’krish’@’localhost’;
4. Finally, a user may be removed from the list of users
using drop command. The following query removes our
user account:
DROP USER ’krish’@’localhost’;

COPA 133 Dr.V.Nagaradjane


5.16 Enforcing Primary key and foreign
key
• Primary key is a unique identifier for one row of data in a table.
No duplicate enties are permitted.

• As an example, one may create a table for storing name, ad-


dress and phone numbers. Since a person may have one ad-
dress and many mobile numbers, we may create two tables as
follows:

1. address: Containing id, name and address columns. It


may be created using the following command:
create table address (id bigint, name varchar(50) not null,
address varchar(300) not null default ”,primary key(id));
2. phone: containing id, person id, mobile columns, created
using the following command:
create table phone (id bigint auto increment primary key,
person id bigint, phone varchar(20) not null default ”,
constraint fk foreign key(person id) REFERENCES ad-
dress(id));

• Primary key in address table is referred as foreign key in phone


table.

• The following commands are permitted on address table:


insert into address values(1,’Ram’,’Uttar Pradesh’);
insert into address values(2,’Krish’,’Gujarat’);

• The following command will fail because primary key value of


2 has already been allotted to Krish:
insert into address values(2,’Govind’,’Andra Pradesh’);

• The following commands will work on phone table:


insert into phone values(0,1,’23423422’);
insert into phone values(0,1,’4563453343’);
insert into phone values(0,1,’23423422’);
insert into phone values(0,2,’23423423’);
insert into phone values(0,2,’45646454’);

COPA 134 Dr.V.Nagaradjane


• The zero (0) value against id column is permissible since auto -
increment property has been set.

• Multiple insertions of same person id values is permissible,


since the column is only a foreign key.

• Primary key in address table is referred as foreign key in mobile


table.

5.17 Adding Indices


1. Index is a special column on which frequent search operation
may be performed while querying the table.

2. We might like to create index on column name in table address.


This is possible using the following query:
create index name on address(name);

3. Alternately, index may have been declared while creating the


table itself. The SQL should be mildly modified as follows:
create table address (id bigint, name varchar(50) not null,
address varchar(300) not null default ”,primary key(id), in-
dex(name));

4. Declaration of index will make queries to work faster.

5.18 Concepts of Transactions


1. Transactions are a set of tasks to be carried out on a database.

2. Each query like insert, delete, drop, alter, grant, revoke creates
certain transactions.

3. Each transaction begins with opening of a particular entity


(typically a table) and ends in its closing.

4. Each transaction may contain several smaller tasks.

5. We might invoke an update query as follows:


update address set name=’Sriram’ where id=1;

COPA 135 Dr.V.Nagaradjane


6. Typically, the query will generate following operations to com-
plete the transaction:
open(address);
search for index=1;
set name=’Sriram’;
close(address);

5.19 ACID Property of Transaction


1. ACID property stands for Atomicity, Consistency, Isolation,
Durability.

2. Atomicity : The transaction should have either taken place or


failed. It should not leave the database with unfinished trans-
action.

3. Consitency : Each transaction should leave the database with


proper values of data.

4. Isolation: Although several transactions take place at the same


time, each transaction should be carried out as though it were
the only transaction.

5. Durability : Result of each transaction should remain perma-


nent, no matter what happens to the computer (like a restart).

5.20 Constraints
• Constraints are restrictions placed on the values a column may
or may not permit.

• Constraint specifiers follow the declaration of column name and


data type.

• Following are the constraints enforced by mysql:

1. NOT NULL: Ensures that the column value is always


something other than NULL.

COPA 136 Dr.V.Nagaradjane


2. UNIQUE: Duplicate values are not permitted in the col-
umn.
3. PRIMARY KEY: It is a combination of NOT NULL and
UNIQUE. It ensures unique non-null value for column.
4. FOREIGN KEY: Ensures that relationships between ta-
bles tables are not removed.
5. DEFAULT: This value is inserted if not value is specified
for the particular column.
6. CREATE INDEX: Helps to improve the search speed in
data tables.

5.21 Joining of tables


• Connecting two tables to produce results for select query is
called join.

• Four types of JOIN operations are permitted by mysql. They


are:

1. INNER JOIN: Intersection of two tables is selected.


2. LEFT JOIN: Intersection of two tables and entire data
in left table are selected.
3. RIGHT JOIN: Intersection of two tables and entire data
in right table are selected.
4. CROSS JOIN: Each row in left table is joined with all
rows in right table.

• The query select address.id, address.name, phone.phone from


address INNER JOIN phone on
address.id = phone.person id; will produce inner join selection.

• The query select address.id, address.name, phone.phone from


address LFET JOIN phone on
address.id = phone.person id; will prodce left join selection.

COPA 137 Dr.V.Nagaradjane


(a) INNER (b) LEFT JOIN (c) RIGHT (d) CROSS
JOIN JOIN JOIN

Figure 5.6: Types of JOINs in MySQL[11]

(a) INNER JOIN

(b) LEFT JOIN

• The query select address.id, address.name, phone.phone from


address RIGHT JOIN phone on
address.id = phone.person id; will prodce right join selection.

• The query select address.id, address.name, phone.phone from


address CROSS JOIN phone on
address.id = phone.person id; will prodce cross join selection.

5.22 Sub Queries


• Sub queries are executed first and the result substituted in the
main query.

• Imagine a condition where we know the name of person to be


contacted (Ram) and wish to get contact numbers.

COPA 138 Dr.V.Nagaradjane


(c) RIGHT JOIN

(d) CROSS JOIN

Figure 5.7: Resuls of JOIN Operations in MySQL

• Since ID value in address for Ram is not known, one may exe-
cute a subquery (select id from address where name=’Ram’;)
to find the same.

• The query with subquery may be executed as follows:


select phone from phone where person id = (select id from
address where name=’Ram’);

• Results of the subquery for names of Ram and Krish are shown
in fig.5.8.

5.23 Aggregate functions in MySQL


• Aggregate functions help to calculate count, sum, average,
minimum, maximum, standard deviation, etc.

• Following aggregate functions are commonly available in mysql:

1. count: Number of rows matching given condition (where


clause).
2. sum: Sum of values in particular column where rows
match given condition (where clause).

COPA 139 Dr.V.Nagaradjane


Figure 5.8: Sub-query and its result

3. avg: Average of values in particular column where rows


match given condition (where clause).
4. min: Minimum value of particular column where rows
match given condition (where clause).
5. max: Maximum value of particular column where rows
match given condition (where clause).
6. stddev: Standard deviation of value contained in par-
ticular column where rows match given condition (where
clause).

• A table named result with id, name, subject and mark columns
is created using the following query:
create table result (id bigint auto increment primary key, name
varchar(20), subject ENUM( ’Tamil’, ’English’, ’Maths’, ’Sci-
ence’, ’Social’), mark int);
• Following values may be inserted into the result table:
emph insert into result values(0,’Ram’,’Tamil’,94);
insert into result values(0,’Ram’,’English’,92);
insert into result values(0,’Ram’,’Maths’,100);
insert into result values(0,’Ram’,’Science’,98);
insert into result values(0,’Ram’,’Social’,91);
insert into result values(0,’Krish’,’Social’,76);

COPA 140 Dr.V.Nagaradjane


Figure 5.9: Inserting data into result table

(a) Count

(b) Sum

insert into result values(0,’Krish’,’Maths’,93);

• Following queries were run to populate the result table:


emph select subject, count(subject) from result group by sub-
ject order by subject;
select name, sum(mark) from result group by name order by
name;
elect name, avg(mark) from result group by name order by
name;
select min(mark) from result;
select max(mark) from result;

COPA 141 Dr.V.Nagaradjane


(c) Average

(d) Min (e) Max

Figure 5.10: Aggregate functions in MySQL

COPA 142 Dr.V.Nagaradjane


Chapter 6

Communicating in the
connected world

Syllabus
Local Networks, Communicating on a Local Network, Prin-
ciples of Communications, How do Ethernet Networks Work?,
How are Networks Built?, Routing Across Networks, How end-
user devices and local networks interact with the global In-
ternet. Concept of network communication. Local Networks
Explain the roles of devices in a network. What Does a Home
Network Look Like? How Does Wi-Fi Work? Introduction to
LAN Devices, Internetworking Devices, Introduction to www,
Concept of Internet, Web Browsers, internet servers and search
engines. Concepts of Domain naming Systems and E mail com-
munication. Introduction to video chatting tools and Social
Networking concepts.

6.1 Computer Networks


• The communication infrastructure meant for sharing of data
between computers is called computer network.

• Connection between computers may be through cable, WiFi


(Wireless Fidelity), bluetooth or any other method.

143
Figure 6.1: Address bit configuration: Class A network [73]

• Modem, repeater, hub, bridge, switch, firewall, etc. are the


essential infrastructure to run a network.
• Each computer connected to a computer assumes a unique
identifier called IP (Internet Protocol) Address
(IP4 - 216.58.201.174, IP6 - 2001: 0db8: 85a3: 0000: 0000:
8a2e: 0370: 7334).
• Domain name is converted to equivalent IP address using Do-
main Name Server (DNS).
• IP4 address is 32 bits (4 bytes) in length.
• Internet is controlld by the World Wide Web Consortium (W3C).

• There are 3 classes of IP address, as detailed below:


(i) Class - A network (Fig.6.1): High order byte (right
most 8 bits) of the network is reserved for network ID.
The remaining 24 bits are used to set IP address of the
host. This permits 126 networks and 16,777,214 hosts
per network.

(ii) Class - B network (Fig.6.2): High order 2 bytes (right


most 16 bits) of the network are reserved for network ID.
The first and second bits of network ID are always 1 and
0. The remaining 14 bits are used to set network IDs
(16,384 networks). The lower 2 bytes of the IP address
are meant for host ID (16,534 hosts).

(iii) Class - C network (Fig.6.3): High order 3 bytes (right


most 24 bits) of the network are reserved for network

COPA 144 Dr.V.Nagaradjane


Figure 6.2: Address bit configuration: Class B network [73]

Figure 6.3: Address bit configuration: Class C network [73]

ID. The first, second and third bits of network ID are


always 1, 1 and 0. The remaining 21 bits are used to
set network IDs (2,097,152 networks). The lowest byte
of the IP address is meant for host ID (254 hosts).

6.2 How do computer networks function?


6.2.1 Client Server computing
• Client and server are two computers behaving like a customer
and service person in a hotel desk.

• Both the client and the server have a unique IP address (to
locate the computer on the network) and Port number (to
identify the program which communicates over the network).

• The sets of {IPclient , P ortclient } and {IPserver , P ortserver } are


called half associations.

• Taken together, the IP and port data of client and server

COPA 145 Dr.V.Nagaradjane


({IPclient , P ortclient } and {IPserver , P ortserver }) form a full
association.

• On getting connected, the client places a request to the server


to get some job done (like the customer placing an order to
the service person in a hotel desk).

• The server gets any additional data required for processing,


completes the job and delivers the result to the client (like the
service person in a hotel desk offering the food items ordered
by the customer).

• The client side half association {IPclient , P ortclient } is called


client socket.

• The server side half association {IPserver , P ortserver } is called


server socket.

• As a real world example, www.google.com is a server and the


user computer accessing it is a client.

• The server awaits the arrival of a client request, completes the


request and keeps waiting for clients (called listening).

• The client and server might use Transmission Control Protocol


(TCP) for error free transmission of sensitive data (like bank
transactions, email, etc.).

• The client and server might use User Datagram Protocol (UDP)
for fast communication with some errors (like video sharing,
audio sharing) where small errors are permissible.

6.2.2 Peer to peer networking


• Peer to peer communication takes place between two comput-
ers connected on an equal status (unlike client and server).

• Peer to peer communication helps to share files and folders.

• Peer to peer communication helps in the easy sharing of printers


and scanners.

COPA 146 Dr.V.Nagaradjane


Figure 6.4: Network topologies [74]

• Peer to peer communication has the limitation of not permit-


ting connection to any external network.

6.2.3 Proxy server, Firewall and Proxy Firewall


• Proxy servers: Proxy servers run as the intermediary between
actual server and the client. The proxy server helps in content
filtering and load balancing of web servers.

• Firewall: Firewall separates a small network from the Inter-


net. It scrutinizes all incoming and outgoing data and prevents
communication of harmful data.

• Proxy Firewall: Proxy Firewall is an improvement to the ac-


tual firewall and provides security at deeper levels (layer 7 of
the 7 layer OSI model) of communication than the firewall.
Proxy firewall separates a small network from the Internet. It
scrutinizes all incoming and outgoing data and prevents com-
munication of harmful data.

6.3 Network Topologies


(i) Bus topology: Bus topology provides a single linear network
cable to which all other nodes are connected.

COPA 147 Dr.V.Nagaradjane


(ii) Star topology: Star topology provides single central node
through which all other nodes communicate with each other.

(iii) Ring topology: Ring topology ends where it began, all com-
puters/ nodes connected to the endless ring.

(iv) Mesh topology or Fully connected topology: Mesh topol-


ogy or fully connected topology has direct connection between
all computers connected to the network. It offers speed by it
is costly.

(v) Tree topology: Tree topology allows each node of the network
to divide/ diverge into 2 separate connections, each new node
dividing till the end of network is reached.

(vi) Hybrid topology: Hybrid topology allows different portions


of the network to adopt different topologies (like tree, mesh,
ring, etc.), with each topology connected to the other.

6.4 Network types


(i) PAN - Personal Area Network: Tiny network running inside
a few rooms of a building, typically created using Bluetooth
technology, is called Personal Area Network (PAN).

(ii) LAN - Local Area Network: Small network running inside a


building is called Local Area Network (LAN).

(iii) CAN - Campus Area Network: The network consisting of


several LANs located inside the campus, typically inside a Uni-
versity or College, is called Campus Area Network (CAN).

(iv) MAN - Metropolitan Area Network: A network larger than


a LAN, running across several buildings in a geographical area
(or a small city) is called Metropolitan Area Network (MAN)

(v) WAN - Wide Area Network: The network spread over a


large area, interconnecting several LANs and MANs is called
Wide Area Network (WAN).

COPA 148 Dr.V.Nagaradjane


6.5 Networking hardware
(i) Gateway: Gateway converts speeds, protocols and speeds be-
tween heterogeneous networks.

(ii) Router: Router forwards data packets to other routers. Each


router commands the traffic between different networks.

(iii) Hub: Hub transmits data between computers connected in


a LAN. Hub simply receives a data packet and forwards the
data to all other computers connected to the network, whether
the data is addressed to a computer or not. Hub results in
inefficient data transmission.

(iv) Switch: Switch is a device which transmits data received from


one node to just those computers which are meant to receive
the data. It results in efficient data transmission.

(v) Bridge: Bridge is a device which connects several networking


segments.

(vi) Repeater: Repeater receives a signal which is weak and trans-


mits the same at full energy to increase the range of the signal.

(vii) MODEM: MODEM stands for MODulation DEModulation -


which converts analogue signal to digital signal and vice versa.
MODEM converts digital information from computer to ana-
logue signal over telephone line and vice versa.

6.6 Networking cables


(i) Unshielded Twisted Pair (UTP) Cable: 4 pairs of cables
twisted together and usually connected through RJ45 is called
twisted pair. CAT 5e and CAT 6 cables are common twisted
pair cables.

(ii) Shielded Twisted Pair (STP) Cable: When each cable of


twisted pair is individually shielded using metal foil and the
entire set of cables is collectively shielded, the cable is called

COPA 149 Dr.V.Nagaradjane


Figure 6.5: Networking hardware [75]

Figure 6.6: Unshielded and Shielded twisted pair [76]

shielded twisted pair. This type of cable is less susceptible to


electromagnetic interferences.

(iii) Coaxial Cable: A copper core surrounded by plastic insulation


and a metal hood is called coaxial cable. Provides fast data
transmission and long range.

(iv) Fiber Optic Cable: Glass fibre core surrounded by plastic


insulation and a metal core is called fibre optic cable. It pro-
vides very high speed, very long range and very low loss of
energy during transmission. Fibre optic cable is not affected
by electromagnetic disturbances.

COPA 150 Dr.V.Nagaradjane


Figure 6.7: Coaxial cable [77]

Figure 6.8: Coaxial cable [78]

6.7 Wireless communication


1. NFC - Near Field Communication: It works between two
mobile devices when gently touching each other. Used for pay-
ment at PoS and pairing of bluetooth devices.
2. Bluetooth: Bluetooth is a wireless communication technology
with connection range of 40m to 400m under bluetooth version
4.
3. WiFi - Wireless Fidelity: WiFi is a technology for fast data
transmission within a range of 100m. Mobile devices have to
pair to a WiFi hotspot to enable data transmission.

6.8 Ethernet networks


• Ethernet provides a unique physical address to the computer
or any connected device.
• The physical address in ethernet (RJ-45 port) is called Media
Access Control (MAC) address.
• When a computer joins a network, the MAC address is linked
to an Internet Protocol (IP) address.
• The MAC to IP mapping lasts till the termination of connec-
tion.
• Data communication over the network is governed by the Open
System Interconnection (OSI) 7 layer model.

COPA 151 Dr.V.Nagaradjane


Figure 6.9: OSI 7 layer model [79]

6.8.1 OSI 7 layer model


6.8.2 Network protocols
• Protocol is a set of rules for transmission of data across the
network and communication between client and server.
• IP: Internet Protocol (IP) is the procedure used for transmis-
sion of data by routing of data packets from one host to an-
other. Each host connected to a network is assigned a unique
ID called IP Address.
• TCP/IP: Transmission Control Protocol (TCP) over Internet
Protocol (IP): TCP divides large data into smaller packets,
assigns sequence number to the packet, transmits the data
through IP layer, received the packets at the remote host, re-
ceives acknowledgement from the remote host, allows reassem-
bling of data packets at the remote host. TCP is an error free
protocol for transmission of data. It is a bit slow compared to
User Datagram Protocol. TCP requires a dedicated connec-
tion.

• UDP/IP: User Datagram Protocol (UDP) over Internet Pro-


tocol (IP) divides data packets into smaller packets. UDP

COPA 152 Dr.V.Nagaradjane


packets, called datagram packets, are transmitted over the IP
network. UDP applies checksums to verify integrity of data
packets. But, it does not care to verify whether all data pack-
ets were received by the remote host. UDP is fast but unreli-
able. UDP is adopted by streaming audio and streaming video
channels on the Internet. UDP is not suitable for financial
accounting applications like core banking (where reliability is
required).

• Telnet: Telnet is a protocol working on of TCP/IP to login and


control a remote computer over the Internet. Telnet works on
port number 23. It permits logging in to a computer through
the Internet.

• File Transfer Protocol (FTP): File Transfer Protocol (FTP)


helps in the transfer of large files between local and remote
hosts over the Internet. Port number 21 is used for FTP control
sequences and port number 20 is used for data transfer.

• Simple Mail Transfer Protocol (FTP): Simple Mail Trans-


fer Protocol (FTP) is used for transfer of email between local
host and remote host. Port number 25 is used SMTP. The
Interim Mail Access Protocol (IMAP) uses port number 143,
Post Office Protocol version 2 (POP2) uses port 109 and POP3
uses port number 110. Email transmission over Secure Socket
Layer (SSL) uses port number 993.

6.8.3 Logical and physical addresses


• Logical address is the IP address assigned to a host when it is
connected to a network.

• Physical address is the address of the networking hardware (like


ethernet adapter). It is also called the Media Access Control
(MAC) address.

• The mapping of a logical address to a physical address is called


address binding.

COPA 153 Dr.V.Nagaradjane


6.8.4 Dynamic Host Configuration Protocol (DHCP)
• When a Local Area Network (LAN) is implemented, each new
host connected to a LAN requires a unique IP address.

• Instead of assigning a static IP address to each host, the DHCP


assigns a new IP for each connected host.

• DHCP claims back unused IP addresses and reuses the address,


thus leading to efficient use of the addressing system.

• DHCP maintains a free pool of assignable IP addresses for new


hosts connected to the network.

6.9 Internet
• The global network of networks is called Internet.

• Internet supports several modes of data exchange, like Hyper


Text Transfer Protocol (HTTP), Hyper Text Transfer Proto-
col over Secure Socket Layer (HTTPS), File Transfer Protocol
(FTP), Simple Mail Transfer Protocol (SMTP), Voice Over
Internet Protocol (VOIP), etc.

• Internet supports many communication protocols like TCP/IP


and UDP/IP.

• Internet originated through a United States Government project


called ARPANET (Advanced Research
Projects Agency Network) created in 1969.

• All nodes connected to the Internet share the Internet Protocol


(IP).

• Internet works on the principle of Packet Switching, which


means information packets are transmitted and received through
various hardware and software components of the Internet till
they reach the destination.

• Each Packet has a TTL (Time To Live), which is the dura-


tion for which packet will get transmitted to through various

COPA 154 Dr.V.Nagaradjane


routers. If the packet cannot reach the destination before TTL,
it is discarded by the network to reduce traffic burden.

6.10 Introduction to WWW


• The WWW (World Wide Web) is governed by W3C (World
Wide Web Consortium).

• WWW works through Hyper Text Transfer Protocol (HTTP)


and Hyper Text Transfer Protocol over Secure Socket Layer
(HTTPS) on top of the TCP/IP protocol stack.

• Web pages are created using Hyper Text Markup Language


(HTML).

• WWW was invented by Tim Berners Lee at the CERN labs,


Geneva.

• Hyper text helps to create navigational links called hyper links.

• Each web address is called a URL (Uniform Resource Locator).

• Each website has a web server which shares its data with clients.

• Web clients are called browsers.

• First web browser was called WorldWideWeb and was created


by Tim Berners Lee.

6.11 Web browser


• Web browser receives data from a web server and renders the
same on the screen of the client machine.

• First web browser was called WorldWideWeb and was created


by Tim Berners Lee.

• Most popular web browsers are Firefox, Google Chrome, Opera,


Microsoft Edge, Apple Safari, etc.

COPA 155 Dr.V.Nagaradjane


• Browsers like Netscape navigator, Internet Explorer are dead
for all practical purposes.

• Web browser essentially renders the text, images, video and


animations from a web page.

• The address bar of the web browser can be opened using the
shortcut Ctrl+L.

• Normally, pressing Ctrl+S saves the web page, Ctrl+P prints


the web page, Ctrl+T opens new tab, Ctrl+Page Up/ Ctrl+Page
Down navigate through tabs.

6.12 Internet server and search engine


• Internet server is a software that sends pages requested through
URL.

• The data sent by the web server is rendered by the web browser.

• Web server usually runs on port number 80 (HTTP) and port


number 443 (HTTPS).

• Apache web server is the most popular open source web server.

• Microsoft IIS (Internet Information Server), nginx, GWS (Google


Web Server), etc. are some of the most common, commercially
supported web servers.

• At hardware level, a computer hardware that helps the running


of web server software is also called a web server.

• Rack mounted servers with option for inserting or removing


server machines is most common in the server industry.

6.13 Domain Name System (DNS)


• Domain Name System (DNS) is the convention used for nam-
ing URL.

COPA 156 Dr.V.Nagaradjane


• Different components of URL are separated by dot (.).
• The URL labels identify the owner of the domain (e.g., google,
yahoo, rediff, microsoft, etc.), the type of organization (e.g.,
.com for commercial ventures, .edu for educational Institutions,
.org for organizations, .in for Indian domains, etc.)
• Domain names are mapped to an IPV4 or IPV6 address.
• Address Resolution Protocol (ARP) is used by servers which
take human readable address and send back IP address.
• Reverse Address Resolution Protocol (RARP) is used by servers
which take IP address and send the human readable address in
return.
• DNS helps the conversion between names and IP addresses.

6.14 Email
• The system for electronic transmission of text and documents
over a network from the sender to recipient is called email.
• Email servers use port numbers 25 - SMTP (Simple Mail Trans-
fer Protocol), 109 - POP2 (Post Office Protocol 2), 110 -
POP3 (Post Office Protocol 3), 993 - IMAP (Internet Mes-
sage Access Protocol).
• Email clients have made it possible to access mailing system
from the browser or dedicated client programs.
• Email messages are fast in message delivery.
• the most popular email servers are gmail.com, yahoo.com, red-
iff.com, rediffmail.com, ymail.com, icloud.com, hotmail.com,
etc.
• Corporate companies have their own email servers with their
own domains.
• To use email service, a person needs to register and obtain an
email address from any of the email servers.

COPA 157 Dr.V.Nagaradjane


• To login, the URL of the email server should be accessed. Login
credentials are the email address and password of the registered
user. Sometimes, OTP (One Time Password) may be sent to
registered mobile number for extra security.
• After logging in, the Inbox displays all messages, Outbox dis-
plays all outgoing messages queued for delivery, Sent shows all
messages sent, Trash shows all deleted messages, SPAM shows
all unsolicited messages.
• Pressing Compose button opens an email compose dialog. The
¡To¿ fields takes the email address of intended recipient, CC
field takes the addresses of persons receiving carbon copy mails
(seen by all) and BCC field takes the address of persons receiv-
ing copies without the knowledge of other recepients, Subject
field takes short heading for the message, message field takes
the entire message, attachments (optional) may be uploaded
and the email may be sent.

6.15 Video chat tool


• Video chat tools help in sharing of live video between the caller
and the receiver.
• Video chat tools like Viber, Skype, Facebook Messenger, Google
Hangouts, Instagram, etc. are widely used.
• Video calling facility works through data streaming over the
Internet.

6.16 Voice Over IP (VOIP)


• Voice Over Internet Protocol (VOIP) is a system for making
audio calls over the Internet.
• VOIP clients bind to the mobile number of the user.
• When VOIP call is made, the recipient cannot distinguish the
call from a GSM (Global System for Mobile communication)
call.

COPA 158 Dr.V.Nagaradjane


• VOIP streams audio over the Internet and uses the mobile num-
ber of the caller as the identifier.

6.17 Social media networking


• Social media permits sharing of casual, usually non-commercial
information with one or several other persons.

• Social media permits sharing of photos, videos, text messages,


etc. over the Internet.

• Social media websites like Facebook, Twitter, LinkedIn Insta-


gram, Skype, Hangouts, WhatsApp, Telegram, etc. are some
of the most popular social media platforms.

• Social media encourages sharing of personal information and


getting appreciation from the recipients.

• Social media has become one of the necessary evils of the


modern society.

• Many modern day crimes relate to extracting information from


innocent youngsters and women and using the same informa-
tion for blackmailing the individual.

• Bullies in social media use fake identities and fake personal


details to attract innocent persons.

• Each person using the social media should exercise self restraint
and should not share any information which can be used by the
other party for blackmailing in the future.

• Social media offers a thrill and freedom from social constraints,


which is dangerous to the safety of innocent victims.

• The lack of moderation in social media may result in many good


natured persons committing follies of unfathomable nature.

COPA 159 Dr.V.Nagaradjane


COPA 160 Dr.V.Nagaradjane
Chapter 7

Design of web pages

Syllabus
Concepts of Static and Dynamic Web pages. Introduction
to HTML and various tags in HTML. Creating Forms with
controls using HTML. Concepts of CSS and applying CSS to
HTML Introduction to open source CMS viz,. Joomla, Word-
press, etc. and web authoring tools viz. Kompozer,FrontPage
etc.

7.1 Static and dynamic web pages


7.1.1 Static web pages
• Web pages which provide fixed content in the form of text,
images and video without any user interaction are called static
web pages.
• Web pages which interact with the user and provide based on
the actions of the user are called dynamic web pages.
• Static web pages use HTML (Hyper Text Markup Language).

7.1.2 Dynamic web pages


• Dynamic web page is created by scripts which result in dynamic
content based on the interaction of the user.

161
• Dynamic web pages can be created by:

1. Server side script: Script stored in the server and writ-


ten in languages like PHP, Perl, Python, ASP.NET, etc. is
called server side script. Server side scripts are useful for
data storage, data retrieval, storing photos received from
forms, authentication of login, managing session, etc.
2. Client side script: Script written in languages like
JavaScript, VBScript, etc. and running inside a browser
(or the client) is called client side script. Client side scripts
are suitable for error checking in forms and dynamic in-
teraction using mouse or keyboard.

• A combination of client side and server side scripting will render


a web page highly attractive and useful.

7.2 HTML tags


All HTML tags have a corresponding closing tag. Some tags might
not have a closing tag with end with / > symbol.

• HTML: All HTML files begin with <HTML> and end with
< /HTML>.

• HEAD: The title and meta information of a HTML file are


entered inside a pair of <HEAD> and < /HTML> tags.

• TITLE: Title of the document is enclosed inside a pair of


<TITLE> and < /TITLE> tags.

• BODY: All contents of the HTML file are enclosed inside a


<BODY> and < /BODY>.

• H1 to H6: Defines various levels of headings from level 1 to


level 6.

• TABLE: Table tag encloses a table. It has border option


wherein border thickness can be specified. TH tag defines
table header, TD defines table column and TR defines table
row.

COPA 162 Dr.V.Nagaradjane


• P: defines a paragraph.

• INPUT: Input tag can have several type options (like text,
date, email, number, etc.), a name, an ID and other attributes
like readonly if necessary.

• SELECT Select tag displays a combo box with various options


enclosed inside OPTION tags. Each option would have a value
property.

• OL: Ordered list. Each list item is defined by LI tag.

• UL: Un-ordered list. Each list item is defined by LI tag.

• textbfFORM: The contents enclosed inside a FORM tag can


be submitted to a server side script for data storage and be
accessed by a client side script for validation of input. It has
options for ACTION, METHOD (POST or GET), etc.

• SUBMIT: Submit button completes form data entry and sends


the data to specified URL.

• RESET: Reset button clears all entries from a form and pro-
vides a blank form.

• BUTTON: Displays a button with specified name, text and


ID.

• A: Anchor tag for hyper text linking. HREF option takes the
URL to be loaded when the link is clicked.

• B: BOLD tag.

• FONT: specifies name, color and size for font.

• IMG: IMS tag loads an image specified by the SRC option.

• CENTER: Centre aligns text and objects.

• SPAN: A place holder with an ID and name.

• MARQUEE: Marquee tag displays scrolling message, as seen


at the bottom of television display.

COPA 163 Dr.V.Nagaradjane


Table 7.1: Special characters in HTML
code char code char code char
&quot; ” &num; # &dollar; $
&amp; & &apos; ’ &lpar; (
&ast; * &plus; + &comma; ,
&period; . &sol; / &colon; :
&lt; < &equals; = &gt; >
&commat; @ &lsqb; [ &bsol; \
&Hat; ˆ &lowbar; &grave; ‘
&rcub; } &verbar; — &tilde; ∼
&beta; β &gamma; γ &delta; δ
&theta; θ &phi; ϕ &psi; ψ
&percnt; % &rpar; ) &minus;
&quest; ? &rsqb; ] &lcub; {
&alpha; α &pi; π &omega; ω
&semi; ;

7.3 Special characters in HTML

7.4 Creating HTML pages


7.4.1 Creating HTML pages
• HTML pages can be edited using text editor (notepad, gedit,
etc.) or can be edited using specialized tools like Dreamweaver,
Komposer, etc.

• The HTML files should be previewed in a browser (like Firefox,


Google Chrome, Edge, Safari, Opera, etc.).

• Firefox browser provides a debugging tool to spot errors through


Developer Console (shortcut: Ctrl+Shift+K).

• Some of the special characters used in HTML are tabulated in


Table 7.1.

COPA 164 Dr.V.Nagaradjane


• Sample HTML pages and their results are presented in the
following subsections.

7.4.2 Static information page


<html>
<head>
<title>
My Intro Page
</title>
<style>
p{
text-align: justify;
font-size: 240%;
font-style: bold;
font-weight: bold;
color: blue;
text-indent: 10mm
}
</style>
</head>
<body>
<h1 style=”color: red; text-align: center; font-size: 300%”>
Welcome to my introduction page: Your name
</h1>
<p>
My name is .... I am studying COPA trade in Govt. ITI for Women,
Puducherry. I am preparing for first semester examination. The ex-
amination starts on 29-Jan-2018.
</p>
<p>
The second semester starts on 01-02-2018.
</p>
</body>
</html>

COPA 165 Dr.V.Nagaradjane


Figure 7.1: Intro page in HTML

7.4.3 Creating ordered and unordered lists


<html>
<head>
<title>
List of computer peripherals
</title>
<style>
h1{text-align: center; color: blue}
ol {font-size: 120%; color: red}
</style>
</head>
<body>
<h1>List of computer peripherals</h1>
<ol>
<li>Monitor</li>
<li>Keyboard</li>
<li>Mouse</li>
<li>Printer
<ul>
<li>Line matrix printer</li>
<li>Daisy wheel printer</li>
<li>Golf ball printer</li>
<li>Dot matrix printer</li>
<li>Inkjet printer</li>
<li>LASER printer</li>
<li>Thermal printer</li>
<li>Dot matrix printer</li>
</ul>
</li>
<li>Scanner</li>
</ol>

COPA 166 Dr.V.Nagaradjane


Figure 7.2: List page in HTML

</body>
</html>

7.4.4 Creating table


<html>
<head>
<title>Ice creams</title>
<style>
h1{color: green; text-align: center}
th {vertical-align: middle; text-align-centre; font-weight: bold; back-
ground: lightgreen; color: red; font-size: 120%}
#odd {vertical-align: middle; text-align-centre; font-weight: normal;
background: #FFBBBB; color: blue; font-size: 120%}
#even {vertical-align: middle; text-align-centre; font-weight: nor-
mal; background: #BBBBFF; color: red; font-size: 120%}
</style>
</head>
<body>
<h1>Types of ice cream (<your name>)</h1>
<span align=”center”>
<table border=1>
<tr><th>Sl. No.</th><th>Name</th>
<th>Cream</th><th>Rate</th></tr>
<tr id=”odd”><td>1</td><td>Dessert</td>
<td><img width=20% src=”ice-creams/01-dessert.jpg”>
</td><td>Rs.120/-</td></tr>

COPA 167 Dr.V.Nagaradjane


Figure 7.3: Table page in HTML

<tr id=”even”><td>2</td><td>Cone</td>
<td><img width=20% src=”ice-creams/02-cone.jpg”>
</td><td>Rs.60/-</td></tr>
<tr id=”odd”><td>1</td><td>Chocolate</td>
<td><img width=20% src=”ice-creams/03-chaco.jpg”>
</td><td>Rs.90/-</td></tr>
<tr id=”even”><td>4</td><td>Cone</td>
<td><img width=20%
src=”ice-creams/04-strawberry.jpg”>
</td><td>Rs.100/-</td></tr>
</table>
</span>
</body>
</html>

7.5 Cascading Style Sheet (CSS)


• A text file containing style properties is called Cascading Style
Sheet (CSS).

• CSS defines how

• The cascading sheet sheet can be linked to a HTML file at the


header section.

COPA 168 Dr.V.Nagaradjane


• The following tag helps to insert a CSS sheet:
< link rel=”stylesheet” type=”text/css”
href=”< style-sheet> .css” >

• The following subsection shows the appearance of HTML file


with different CSS linkages.

• Styles may be specified in any one of the following methods:

1. Inline style: Specifying style just inside the tag is called


inline style specification. e.g., < h1 style = ”color: #FF0000;
text-align: center; background-color: #0000FF” > Head-
ing < /h1 > specifies that text should be red in color,
alignment should be centred and background should be
blue.

7.5.1 Red color theme


<html>
<head>
<title>Red style</title>
<link rel=”stylesheet” type=”text/css” href=”red.css”>
</head>
<body>
<h1>Ridge TV Channel</h1>
<marquee>
Breaking news &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
Nothing new under the Sun!
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;
Keep your cool!!
</marquee>
</body>
</html>

body {
background-color: #222277;
font-size: 300%;

COPA 169 Dr.V.Nagaradjane


color: #FF0000
}
h1 {
color: #FF0000;
text-align: center
}
marquee {
background-color: #0000FF
}

7.5.2 Green color theme


<html>
<head>
<title>Green style</title>
<link rel=”stylesheet” type=”text/css” href=”green.css”>
</had>
<body>
<h1>Ridge TV Channel</h1>
<marquee>
Breaking news &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
Nothing new under the Sun!
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;
Keep your cool!!
</marquee>
</body>
</html>

The green.css file is shown below:


body {
background-color: #222266;
font-size: 300%;
color: #00FF00
}
h1 {

COPA 170 Dr.V.Nagaradjane


color: #00FF00;
text-align: center
}
marquee {
background-color: #0000FF
}

7.6 CSS Property elements


1 align-content: Align content to left, right or center.

2 background: Specifies background color (Color is specified in


#000000 (black) #FFFFFF (white). First 2 digits represent
red, second 2 digits represent green and third 2 digits represent
blue. Each digit can change from 0 to F under hexadecimal
system).

3 background-color: Specifies background color (Color is spec-


ified in #000000 (black) #FFFFFF (white). First 2 digits
represent red, second 2 digits represent green and third 2 dig-
its represent blue. Each digit can change from 0 to F under
hexadecimal system).

4 border: size, type (solid, dotted, dashed, double dashed) and


color of border.

5 color: Color of element.

6 font-style: Font style may be italic, normal, oblique.

7 font-weight: may be normal, bold, bolder, lighter (number


400 is normal, 700 is bold).

8 font-size: Font size may be specified in pixels (e.g., 24px) or


percentage (100%, 150%, 200%).

9 font-family: Font family can be serif, sans, times, georgia,


etc.

10 text-align: Text align can be left, right, center or justified.

COPA 171 Dr.V.Nagaradjane


11 text-indent: The distance of text indent (in mm, cm, px) may
be specified.

12 text-align: Text align property may be top, bottom, middle,


sub, super, etc.

7.7 Creating HTML forms


• Forms begin with the <form> tag and end with </form> tag.

• Action property of form refers to the URL to be invoked when


the form is submitted.

• Method property of form submission may be GET or POST.

• Input type of ”submit” may be used to submit data to the


specified action URL.

• Input type of ”reset” may be used for clearing all changes to


the form.

• Some simple forms to calculate sum, difference, product, quo-


tient, age and power are presented in the following sections.

7.7.1 HTML form for greeting


HTML form to greet a person is presented in the following HTML
code:

<html>
<head>
<title>Enter your name</title>
<link rel=”stylesheet” type=”text/css” href=”red.css”>
</head>
<body>
<h1>Name form</h1>
<form name=”nameForm” action=”#” method=”POST”>
<center>
<table border=0>
<tr><td>Name</td><td>: </td>

COPA 172 Dr.V.Nagaradjane


<td><input type=”text” name=”n” placeholder=”Name”>
</td></tr>
</table>
<input type=”submit” value=”Greeting”
onClick=”alert(’Welcome ’+n.value)”>
</center>
</form>
</body>
</html>

7.7.2 HTML form for addition


HTML form to add 2 numbers:

<html>
<head>
<title>Add numbers</title>
<link rel=”stylesheet” type=”text/css”
href=”red.css”>
</head>
<body>
<h1>Add form</h1>
<form name=”addForm” action=”#” method=”POST”>
<center>
<table border=0>
<tr><td>Enter x</td><td>
: </td><td><input type=”text” name=”x”></td>
</tr>
<tr><td>Enter y</td><td>: </td>
<td><input type=”text” name=”y”></td></tr>
<tr><td colspan=3 style=”text-align: center”>
<input type=”button” value=”Add”
onClick=”z.value = Number(x.value)
+ Number(y.value)”></td></tr>
<tr><td>Result</td><td>
: </td><td><input type=”text”
name=”z” readonly></td></tr>

COPA 173 Dr.V.Nagaradjane


</table>
</center>
</form>
</body>
</html>

7.7.3 HTML form for subtraction


HTML form to subtract a number from another numbers:

<html>
<head>
<title>Subtract numbers</title>
<link rel=”stylesheet” type=”text/css” href=”red.css”>
</head>
<body>
<h1>Subtract form</h1>
<form name=”subForm” action=”#” method=”POST”>
<center>
<table border=0>
<tr><td>Enter x</td><td>: </td>
<td><input type=”text” name=”x”></td></tr>
<tr><td>Enter y</td><td>: </td>
<td><input type=”text” name=”y”></td></tr>
<tr><td colspan=3 style=”text-align: center”>
<input type=”button” value=”Subtract”
onClick=”z.value = Number(x.value) -
Number(y.value)”>
</td>
</tr> <tr><td>Result</td>
<td>: </td><td>
<input type=”text” name=”z” readonly>
</td></tr>
</table>
</center>
</form>
</body>

COPA 174 Dr.V.Nagaradjane


</html>

7.7.4 HTML form for multiplication

HTML form to multiply 2 numbers:

<html>
<head>
<title>Multiplication form</title>
<link rel=”stylesheet” type=”text/css” href=”red.css”>
</head>
<body>
<h1>Multiply form</h1>
<form name=”mulForm” action=”#” method=”POST”>
<center>
<table border=0>
<tr><td>Enter x</td><td>: </td><td><input type=”text”
name=”x”></td></tr>
<tr><td>Enter y</td><td>: </td>
<td><input type=”text” name=”y”></td>
</tr>
<tr><td colspan=3 style=”text-align: center”>
<input type=”button” value=”Multiply”
onClick=”z.value = Number(x.value) * Number(y.value)”>
</td></tr>
<tr><td>Result</td><td>: </td>
<td><input type=”text” name=”z” readonly>
</td></tr>
</table>
</center>
</form>
</body>
</html>

COPA 175 Dr.V.Nagaradjane


7.7.5 HTML form for subtraction
HTML form to divide a number by another numbers:

<html>
<head>
<title>Division of numbers</title>
<link rel=”stylesheet” type=”text/css” href=”red.css”>
</head>
<body>
<h1>Division form</h1>
<form name=”divForm” action=”#” method=”POST”>
<center>
<table border=0>
<tr><td>Enter x</td><td>: </td>
<td><input type=”text” name=”x”></td></tr>
<tr><td>Enter y</td><td>: </td>
<td><input type=”text” name=”y”></td></tr>
<tr><td colspan=3 style=”text-align: center”>
<input type=”button” value=”Divide”
onClick=”z.value = Number(x.value) / Number(y.value)”>
</td></tr>
<tr><td>Result</td><td>: </td>
<td><input type=”text” name=”z” readonly>
</td></tr>
</table>
</center>
</form>
</body>
</html>

7.7.6 HTML form to calculate age


HTML form to calculate age:

<html>
<head>
<title>Age calculation</title>

COPA 176 Dr.V.Nagaradjane


<link rel=”stylesheet” type=”text/css” href=”green.css”>
</head>
<body>
<h1>Age calculation</h1>
<form name=”ageForm” action=”#” method=”POST”>
<center>
<table border=0>
<tr><td>Enter DOB</td><td>: </td>
<td><input type=”date” name=”dob”></td></tr>
<tr><td colspan=3 style=”text-align: center”>
<input type=”button” value=”Age”
onClick=”res.value = (new Date(Date.now() -
new Date(dob.value).getTime()).getUTCFullYear()-1970)”>
</td></tr>
<tr><td>Age</td><td>: </td>
<td><input type=”text” name=”res” readonly>
</td></tr>
</table>
</center>
</form>
</body>
</html>

7.7.7 HTML form to calculate power of a number


HTML form to calculate power of a number:

<html>
<head>
<title>Power</title>
<link rel=”stylesheet” type=”text/css” href=”green.css”>
</head>
<body>
<h1>Power form</h1>
<form name=”powForm” action=”pow.php”
method=”POST”>
<center>

COPA 177 Dr.V.Nagaradjane


<table border=0>
<tr><td>Enter x</td><td>: </td>
<td><input type=”text” name=”x”></td></tr>
<tr><td>Enter y</td><td>: </td>
<td> <input type=”text” name=”y”> </td> </tr>
<tr><td colspan=3 style=”text-align: center”>
<input type=”submit” value=”Power”>
<input type=”reset” value=”Reset”> </td></tr>
</table>
</center>
</form>
</body>
</html>

7.7.8 PHP script to calculate power of a number


PHP script to calculate power of a number:

<?php
$x = $ POST[’x’];
$y = $ POST[’y’];
$z = pow($x, $y);
echo $x . ” ˆ” . $y . ” = ” . $z;
?>

COPA 178 Dr.V.Nagaradjane


Chapter 8

Javascript

Syllabus
Introduction to Web Servers and their features. Introduction
to Programming and Scripting Languages. Introduction to
JavaScript and its application for the web. JavaScript Basics
– Data types, Variables, Constants. Conversion between data
types. The Arithmetic, Comparison, Logical and String Opera-
tors in JavaScript. Operator precedence. Arrays in JavaScript
– concepts, types and usage. Program Control Statements and
loops in JavaScript. Introduction to Functions in JavaScript.
Built in JavaScript functions overview. The String data type in
JavaScript. Introduction to String, Math and Date Functions.
Concepts of Pop Up boxes in JavaScript. Introduction to the
Document Object Model. Concepts of using Animation and
multimedia files in JavaScript.

8.1 Algorithms
1) The sequence steps taken to solve a problem is called an algo-
rithm.

2) Algorithm helps to create computer program for problem solv-


ing.

179
8.2 Flowcharts
1) Graphical representation of the step by step solution of a prob-
lem is called flowchart.
2) Flowchart symbols and their purposes are given below:
 

1  Oval Start or End of flowchart.



Connector - Indicates
 flowchart continues where
2 Circle
a matching name or
number is found.
3 - Arrow Indicates flow direction.
4 Parallelogram Input or output.

5 Rectangle Processing
@
@ Decision making (condi-
@
6 @ Rhombus tions - if/ switch, loops -
for/while).

8.3 Web servers


8.3.1 Introduction to web servers
1 Web server sends HTML pages in response to request from
client. Web server uses Hyper Text Transfer Protocol (HTTP).
2 Web server uses port number 80 for general data exchange and
port number 443 for data exchange over Secure Socket Layer
(SSL).
3 Scripts executed by the webserver are called server side scripts.
4 PHP, Perl, Python and ASP.NET are some of the programming
languages used for server side scripting.
5 Some scripts embedded in HTML pages are executed by the
browser. The scripts executed on browser are called client side
scripts.

COPA 180 Dr.V.Nagaradjane


6 Javascript and VBScript are some of the most common client
side scripting languages.

7 Microsoft Internet Information Server (IIS), Apache httpd, ng-


ingx, Google Web Sever (GWS) and IBM Websphere are some
of the most common web servers.

8.3.2 Features of web server


1 Port numbers 80 and 443 are used by web servers.

2 Web address is called Uniform Resource Locator (URL).

3 URL parts are separated by forward slash (/) symbol.

4 If a URL begins with http:// the communication takes place


on port number 80 and it is unsecure.

5 If a URL begins with https:// the communication takes place


on port number 443. Secure Socket Layer (SSL) protocol is
used to prevent data intrusion.

6 The last part of a web URL is the name of the file.

7 A folder named ‘htdocs’ or ‘wwwroot’ serves as the root direc-


tory of the web server.

8.4 Programming Languages


8.4.1 Compiler based languages
1 The human readable program is called source code.

2 A special program called compiler converts the source code to


machine readable binary code.

3 A source code should follow certain formatting details, called


syntax, if the program should be successfully compiled.

4 Compiler detects errors and converts/ translates the code only


if the entire program has correct syntax.

COPA 181 Dr.V.Nagaradjane


5 Since compilation is done only once, the time spent on remov-
ing syntax and logical errors (called debugging) does not affect
the time required for running on a computer.

6 After compilation, machine code runs very fast on a computer.

7 Assembly language, C, C + + , Java, C#, etc. are some of


the most popular compiled languages.

8 Compiler based languages are very strict about syntax and data
types.

8.4.2 Interpreter based programming languages


1 Interpreter is a special program to translate few lines of source
code, load it to the processor based on program flow.

2 Interpreted programs are slower than compiled programs.

3 Interpreted programming languages enforce liberal syntax (they


forgive some deviations) and have less stringent data types.

4 Interpreted programs are easier and faster to develop for small


projects.

5 The liberal nature of interpreted programming languages per-


mits more errors and more complications for large programs.

6 A class of languages suitable for embedding inside a larger


program are called scripting languages.

7 Javascript, Perl, Python, Unix/Linux shell script, etc. are some


of the most popular scripting languages.

8.5 Javascript
1 Javascript loosely follows the syntax of Java programming lan-
guage.

2 Javascript is embedded inside HTML code.

COPA 182 Dr.V.Nagaradjane


3 A Javascript function is embedded inside a pair of < script >
< /script > tags.

4 The script tag begins with one or both of the following at-
tributes: type = ”text/javascript” and language = ”javascript”.

5 Javascript can be used as a procedural language (only functions


are permitted) or as an Object oriented language (new data
types called classes are permitted).

6 Each line of Javascript code ends with a semi-colon (;), unless


it begins a new block using curly brace({).

7 Javascript runs inside a browser.

8 Script can be written within the HTML file itself or in an ex-


ternal file (with .js extension).

9 External script file (say welcome.js) may be embedded using src


attribute of script tag (<script type=”text/javascript” lan-
guage=”javascript” src=”welcome.js”¿ ¡/script>)

8.5.1 Comments in Javascript


1 Comments in Javascript can cover single line or multiple lines.

2 Single line comments start with // symbol and run till the end
of the line in which it is placed. For example,
x*=2; //current value of x is doubled.
//The following code calcualtes age of a person.
are examples of single line comment.

3 Multiple line comment starts with /∗ and ends only when ∗/


is found. For example,
/∗
The following lines are ignored by the browser.
x + =5;
y=Math.pow(x,2);
∗/
is an example of multi-line comment.

COPA 183 Dr.V.Nagaradjane


5 Commented portions are ignored by the browser.

6 Comments help the programmer to understand the meaning of


code at a later date.

8.5.2 Application of Javascript for web


1 Javascript can be embedded in HTML code.

2 Support for Javascript is available in all the modern web browsers.

3 Javascript methods can be easily invoked through onClick prop-


erty of a button.

4 Javascript can be used to dynamically interact with the user of


a web page.

5 Since Javascript is executed inside a browser, the danger of


malware spreading to the system through the script is very
low.

8.5.3 Data types in Javascript


1 Javascript supports the following primitive (basic level) data
types:

Sl. No. Primitive type Description


A sequence of characters is called
1 String a String. e.g., ”Hello”. It is en-
closed in double quotes.
Any numerical value, whether in-
2 Number teger or floating point is a Num-
ber.e.g. 3, 6.23.
Contains the result of a logical ex-
3 Boolean
pression. e.g., true, false.
When a variable is undeclared, it
4 Undefined
is categorized as undefined.
It signifies the absence of any spe-
5 NULL
cific value.
2 Javascript supports non-primitive data types called Object (ref-
erence type objects).

COPA 184 Dr.V.Nagaradjane


Sl. No. Non-Primitive Description
Represents the basic reference
type. New data types in Javascript
1 Object
may be defined using function it-
self.
Array represents a collection of in-
dexed values. e.g. var num=new
2 Array Array(”Zero”,”One”, ”Two”,
”Three”); alert(num[2]); displays
Two in the alert dialog.
Regular expression used for manip-
3 RegExp
ulation of strings.

8.5.4 Variables and constants in Javascript


1 A variable represents a memory location in which values can
be stored and retrieved.
2 Javascript variable names must start with alphabets (A-Z or
a-z) or underscore ( ) or dollar symbol ($).
3 Numbers can be used in variable names anywhere except the
first location.
4 Variable declaration starts with the keyword var. e.g., var
$x=1,y=3, z;
5 Javascript variables are case sensitive. i.e., var a=10, A=20;
declares two different variables named a and A.
6 A variable declared outside the scope of any function is called
a global variable.
7 If a declaration starts with the keyword const instead of var,
the variable so declared can be assigned a value only once.
e.g., const PI=3.14159625; will make PI a constant. New
values assigned to it (like PI=1;) will fail.

8.5.5 Conversion between data types


1 Data of any type (e.g. ”25.67”) can be converted to number
using the Number() function (e.g., x = Number(”25.67”); )

COPA 185 Dr.V.Nagaradjane


2 Data of any type can be converted to String using String()
function (e.g. str=String(23.23);).

3 Data of any type can be converted to Boolean type (true or


false) using Boolean() function.

4 The typeof operator helps to determine the data type of a


variable. e.g.,
var name=”Ram”, mark=95;
alert(typeof name);
alert(typeof mark);
displays String and Number as the data types respectively.

5 NaN is a special number which indicates a value too large for


storage in number type (like ∞).

6 null is another data type stored in a variable when there is no


value in a variable.

7 var x; alert(typeof x); displays that x is undefined.

8.5.6 Arithmetic Operators in Javascript


1 Javascript provides operators for basic operations like Division,
Multiplication, Addition, Subtraction, etc.

8.5.7 Assignment Operators in Javascript


1 Javascript provides assignment operators to assign the results
of mathematical expression to variables.

8.5.8 Comparison operators in Javascript


1 Comparison operators compare the left and right side results
based on Boolean logic (true or false) results. List of compar-
ison operators is shown in Table 8.3.

COPA 186 Dr.V.Nagaradjane


Table 8.1: Arithmetic operators in Javascript
Airthmetic
Sl.
Oper- Purpose Example Precedence
No.
ator
1 ∗∗ Exponentiation x = 102 ; 1
2 ∗ Multiplication x = 10 ∗ 2; 2
3 / Division x = 10/2; 3
Modulo
4 % x = 10%4; 4
Remainder
5 + Addition x = 10 + 2; 5
6 − Subtraction x = 10 − 2; 6
7 ++ Increment x = 10; x + +; 7
8 −− Decrement x = 10; x − −; 8

Table 8.2: Assignment operators in Javascript


Sl. Prece-
Operator Purpose Example
No. dence
1 = Assignment x = 10; 1
Add and As-
2 += x = 10; x+ = 4; 2
sign
Subtract and
3 −= x = 10; x− = 4; 3
Assign
Multiply and
4 ∗= x = 10; x∗ = 4; 4
Assign
Take power
5 ∗∗ = x = 2; x ∗ ∗ = 4; 5
and Assign
Divide and
6 /= x = 10; x/ = 4; 6
Assign

COPA 187 Dr.V.Nagaradjane


Table 8.3: Comparison operators in Javascript
Sl.
Operator Purpose
No.
Equal to (ignore data type. e.g.,
”20”==20 gives true as the re-
1 ==
sult, since data types are not con-
sidered.)
Equal to (compare data type and
2 ===
value. ”20” === 20 is false.)
3 != Not equal to. Ignore data type.
Not equal to. Gives true result
4 ! == only when the data type and value
are identical.
5 > Greater than.
6 >= Greater than or equal to.
7 < Less than.
8 <= Less than or equal to.

Table 8.4: Logical operators in Javascript


Sl.
Operator Purpose
No.
1 && Logical AND.
2 ∥∥ Logical OR.)
3 ! Logical NOT operator (Negation).

8.5.9 Logical operators in Javascript


1 Logical operators help to combine the results of several logical
operations (AND, OR, NOT, etc.) based on Boolean logic.
Table 8.4 shows the logical operators used in Javascript.

8.5.10 Special operators in Javascript


1 Following are some of the uncategorized, but important oper-
ators used in Javascript (Table 8.5).

COPA 188 Dr.V.Nagaradjane


Table 8.5: Special operators in Javascript
Sl.
Operator Purpose
No.
Returns the data type of a vari-
1 typeof
able.
2 new Creates a new object.
Evaluates the logical expression to
the left of ?. Executes left side
of : if it is true, right side of :
3 ? : ternary
otherwise. e.g., var x=2; y =
(x! =2)?5:8; sets y value to 8,
since the logical expression is false.
Checks whether a variable belongs
4 instanceof
to particular data type.
Takes a value from an array. Used
in for loops. e.g., var x = {
5 in
’One’,’Two’, ’Three’ }; for(var y
in x) alert(y);

8.5.11 String operators in Javascript


1 String class supports assignment and string concatenation op-
erators (Table 8.6).

8.5.12 Arrays in Javascript


1 Array is a collection of values in a single variable.

2 Array elements are numbered from 0 (0,1,2,3,...).

3 Each element of an array may be accessed using []. e.g. x =


{3, 5, 2, 10}; alert(x[1]); displays 5.

4 In a for loop, elements of array may be accessed using index


values (0 to n) or using in operator. e.g.,
x={3,5,2,10};
for(var i=0;i<x.length; i + + )
alert(x[i]);
and

COPA 189 Dr.V.Nagaradjane


Table 8.6: String operators in Javascript
Sl.
Operator Purpose
No.
Assigns string value on the right
1 = side to a variable on the left side.
e.g., var name=”Gayathri”.
Adds 2 strings together. var
x=”COPA”, y=” is great.”; var
2 +
z=x + y; sets ”COPA is great.”
as the value in z.
Appends the string on right side
to the variable on left side. e.g.,
3 += var x=”Sun”, y=” is the nearest
star.”; x + =y; sets ”Sun is the
nearest star.” in variable x.

x={3,5,2,10};
for(var y in x)
alert(x[y]);
display all the elements array x.

5 Array may be declared using a pair of { } or new Array();


function.

8.5.13 Associative arrays or Hash maps


1 Instead of accessing array elements using a numeric index, it is
possible to permit some name to each element.

2 Such an array having a name for index is called an associative


array or hash map.

3 An associative array may be declared in any one of the follow-


ing styles:
var x={’Tamil’:92,’English’:80, ’Maths’:83, ’Science’:87, ’So-
cial Science’:81};
or
var x= new Array(’Tamil’:92,’English’:80, ’Maths’:83, ’Science’:87,
’Social Science’:81);

COPA 190 Dr.V.Nagaradjane


4 Left side of an associative array or hash is called key and the
right side is called value. e.g., in array x, ’Maths’ is key and
83 is value.

5 Elements of associative arrays are accessed using the key. e.g.,


y = x[′ T amil′ ]; sets value of y to 92.

8.5.14 Control statements in Javascript


1 Control statements help in conditional execution of portions of
code.

2 Conditional controls may be imposed using


(i) if...else condition,
(ii) switch ... case ...break condition, or
(iii) ternary operator (?:).

8.5.15 If ... else condition


1 The if condition contains a condition part. In case the condi-
tion is true, the block (enclosed by a pair of { }) immediately
following if condition is executed.

2 An if condition having a single line might omit the pair of {


}.

3 In case the if condition fails, an optional else block may be


coded. Else may also check for a condition using an if (else if ).

4 Else block may also omit the pair of { } if the code for it
contains a single line.

Example of if condition
<html>
<head>
<title>Test of if condition</title>
<script type=”text/javascript” language=”javascript”>
function ageMessage() {
var age = this.ageForm.age.value;

COPA 191 Dr.V.Nagaradjane


if(age < 13) {
document.write(”<h1 style=’color:#FF0000’>You are a kid </h1>”);
}
else if(age < 20) {
document.write(”<h1 style=’color:#FF0000’>
You are a teenager! </h1>”);
}
else if(age < 36)
document.write(”<h1 style=’color:#FF0000’>
You are young! </h1>”);
else if(age < 50)
document.write(”<h1 style=’color:#FF0000’>
You are middle aged! </h1>”);
else
document.write(”<h1 style=’color:#FF0000’>
You are old! </h1>”);
}
</script>
</head>
<body>
<form name=”ageForm”>
<center>
Enter your age: <input type=”number” name=”age”></br />
<input type=”button” value=”Get message”
onClick=”ageMessage()”>
</center>
</form>
</body>
</html>

How the if condition program works?


1 The if ladder first tests whether the age is less than 13. In case
it is correct, the message ”You are a kid!” is displayed.

2 In case the value is the first test fails (age ¿= 13), the else if
part tests whether the age is between 13 and 19. In such a
case, the message ”You are a teenager!” loads.

COPA 192 Dr.V.Nagaradjane


3 In case the age is greater than or equal to 20, the third else
if condition checks whether the age is less than 36. If so, the
message ”You are young!” is displayed.

4 In case the age is greater than or equal to 36, the third else
if condition checks whether the age is less than 50. If so, the
message ”You are middle aged!” is displayed.

5 When all the if conditions fail, the last else is reached. It


displays the message ”You are old!”.

8.5.16 Switch condition


1 Switch condition takes one argument (e.g. switch(x)).

2 It checks the input against several case values (e.g., case 2:)
and executes the lines following the matching case.

3 All cases, other than the last one end with break keyword.

4 The last condition may be called def ault :, which handles


cases not matching any of the previous ones.

Example of switch condition


<html>
<head>
<title>Test of switch condition</title>
<script type=”text/javascript” language=”javascript”>
function nameMessage() {
var name = this.nameForm.name.value;
var length=name.length;
switch(length) {
case 1:
case 2:
case 3:
case 4:
case 5:
document.write(
”<h1 style=’color:#FF0000’>Very short name!

COPA 193 Dr.V.Nagaradjane


</h1>”);
break;
case 6:
case 7:
case 8:
case 9:
case 10:
document.write(”<h1 style=’color:#FF0000’>
Length of your name is normal! </h1>”);
break;
case 11:
document.write(”<h1 style=’color:#FF0000’>
Your name is bit long! </h1>”);
break;
default:
document.write(”<h1 style=’color:#FF0000’>
Your name is too long! </h1>”);
}
}
</script>
</head>
<body>
<form name=”nameForm”>
<center>
Enter your name: <input type=”text” name=”name”></br />
<input type=”button” value=”Get message”
onClick=”nameMessage()”>
</center>
</form>
</body>
</html>

How the switch...case program works?


1 The switch takes length of name as argument.

2 For cases 1, 2, 3, 4 and 5, it displays the message ”Very short


name!”.

COPA 194 Dr.V.Nagaradjane


3 For cases 6, 7, 8, 9 and 10, it displays the message ”Length of
your name is normal!”.

4 For case 11, it displays the message ”Your name is bit long!”.

5 As the default case (length > 11), it displays the message


”Your name is too long!”.

6 Note that cases and case groups end with break.

7 The last condition (default) need not have a break.

8.5.17 The ternary operator (?:)


1 A simple if ... else condition may be re-written using one liner
called ternary.

2 Ternary operator has 3 parts.

3 First part of the ternary operator (to the left of ?) is the


condition. The condition may be either true or false.

4 The second part of the ternary, placed to the right of ? and


the left of :, is executed if the condition is true.

4 The third part of the ternary, placed to the right of :, is executed


if the condition is f alse.

5 Consider the following lines:


x = 25;
y = (x < 21)?“Good′′ : “Bad′′ ;
can you guess the value of y?

6 y has the value of “Bad”, since the condition turns out to be


false.

Example of ternary operator (?:)


<html>
<head>
<title>Test of if condition</title>
<script type=”text/javascript” language=”javascript”>

COPA 195 Dr.V.Nagaradjane


function bmiMessage() {
var wt = this.bmiForm.wt.value,
ht=this.bmiForm.ht.value/100; //Convert height from centimeter to
metre.
var bmi=wt/ht/ht;
var mess=”Your BMI is ”;
mess + = bmi<=20.3?”very good!”:”very high. You need exercise!”
document.getElementById(”res”).innerHTML=”<h1 color=#FF0000>
” + mess + ”</h1>”;
}
</script>
</head>
<body>
<form name=”bmiForm”>
<center>
Enter weight: <input type=”number” name=”wt”></br />
Enter height in centi metre: <input type=”number” name=”ht”></br
/>
<input type=”button” value=”Get message”
onClick=”bmiMessage()”>
<span id=”res”> </span>
</center>
</form>
</body>
</html>

8.5.18 Loops in Javascript


1 Javascript supports 4 types of loops:

1. f or loop with index value.


2. f or − in loop with list of array elements.
3. while loop.
4. do − while loop.

2 For loop having index value handle only integer index.

COPA 196 Dr.V.Nagaradjane


8.5.19 For loop in Javascript
1 Index value of f or loop may be declared before commencement
of the loop or at the loop itself. (e.g., var i; f or(i = 0; i <
10; i + +) is equivalent to f or(var i = 0; i < 10; i + +)).

2 The f or loop has 3 parts, viz., (i) initialization part, (ii) con-
dition part, (iii) increment part.

3 The initialization part sets the initial value of index variable.

4 The f or loop keeps running so long as the condition part (sec-


ond of the three parts) is true.

5 The increment part increases or decreases value of variable.


e.g., f or(var i = 0; i < 100; i + +), f or(var i = 0; i <
100; i+ = 2), f or(var i = 100; i >= 0; i − −), f or(var i =
0; i < 100; + + i), f or(var i = 0; i < 100; i+ = 10) are all
valid increments to the index variable of f or loop.

6 Each of the 3 parts of f or loop is separated by a ; (semi-colon).

7 One of more of the parts of for loop may be omitted.e.g.,


var i = 0; f or( ; i < 10; i + +), f or(var i = 0; i < 10; ),
f or(var i = 0; ; )

8 The special loop f or( ; ; ) is called forever loop, since it runs


for ever unless terminated.

Example of for loop


<html>
<head>
<title>
Example of for loop
</title>
</head>
<body>
<script type=”text/javascript” language=”javascript”>
var x = new Array(4,2,6,8,12,15,25), sum=0;
document.write(”Sum of ”);

COPA 197 Dr.V.Nagaradjane


for(var i=0; i<x.length; i + + ) {
document.write(x[i] + (i==x.length-1?” = ”:” + ”));
sum + = x[i];
}
document.write(sum);
</script>
</body>
</html>

8.5.20 f or − in loop in Javascript


1 f or − in loop is used in conjunction with arrays and lists.

2 A typical f or − in loop to move through the elements of an


array creates an index variable which changes value from the
first index to the last.

3 The f or − in loop is a convenient replacement to for loop


having separate declaration, index limit checking and increment
parts.

Example of f or − in loop
<html>
<head>
<title>
Example of for-in loop
</title>
</head>
<body>
<script type=”text/javascript” language=”javascript”>
var x = new Array(4,2,6,8,12,15,25), sum=0;
document.write(”Sum of ”);
for(var y in x) {
document.write(x[y] + ” ”);
sum + = x[y];
}
document.write(” is ” + sum);

COPA 198 Dr.V.Nagaradjane


</script>
</body>
</html>

Example of f or − in loop for associative array


Mark statement using f or − in loop and associative array

<html>
<head>
<title>
Example of for-in loop
</title>
</head>
<body>
<script type=”text/javascript” language=”javascript”>
var x = {’Tamil’:92, ’English’:98, ’Maths’:100, ’Science’:94, ’Social’:91};
var sum=0;
document.write(”<center><h1>Mark statement</h1>”+
”<table border=1>”);
document.write(”<tr><th>Subject</th>”+
”<th>Mark</th></tr>”);
for(var y in x) {
document.write(”<tr><td>” + y + ”</td>
<td style=’text-align:right’>” + x[y] + ”</td></tr>”);
sum + = x[y];
}
document.write(”<tr><td
style=’color: #FF0000; text-align:center’>Total</td>
<td style=’color:#FF0000; text-align:right’>” +
sum + ”</td></tr></table>”);
</script>
</body>
</html>

8.5.21 While loop in Javascript


1 While loop checks a condition. If the condition yields true, the
loop portion is executed.

COPA 199 Dr.V.Nagaradjane


2 If the loop contains only one statement, use of a pair of curly braces
({ }) is optional.

3 If the loop contains more than one statement, the entire loop body
is enclosed in a pair of curly braces({ }).

4 Index variable of the while loop should be declared and initialized


before the while loop begins.

5 Index variable, if any, should be incremented or decremented in a


separate line within the while loop.

Example of while loop


<html>
<head>
<title>
Example of for-in loop
</title>
<script>
function table() {
var x=this.document.tabForm.n.value, y, i=1;
document.write(”<center><h1 style=’color:#FF0000’>” +
x + ” Table</h1><h2>”);
while(i<=10) {
y = i*x;
document.write(i + ” x ” + x + ” = ” + y + ”<br />”);
i++
}
document.write(”</h2></center>”);
}
</script>
</head>
<body>
<center>
<form name=”tabForm” method=”GET” action=”#”>
Enter table number: <input type=”number” name=”n”> <br />
<input type=”button” value=”Create table” onClick=”table()”>
</form>
</center>
</body>

COPA 200 Dr.V.Nagaradjane


</html>

8.5.22 The do ... while loop in Javascript


1 Do ... while loop is a special loop which gets executed at least
once, because the condition is checked only at the last statement
of the loop.

2 The index variable, if any, should be declared outside the loop.

3 The do ... while loop checks the condition at the last line (which
is a while).

Example of do ... while loop - Fibonacci series


Example of do ... while loop - Fibonacci series
<html>
<head>
<title>
Example of do ... while loop
</title>
</head>
<body>
<script>
var i=1, x=1,y=1;
document.write(”<h1 style=’color:#FF0000’>Fibonacci series</h1><br
/>”);
document.write(”<h1 style=’color:#0000FF’>” + i + ”) ” + x + ”<br
/>”);
var next=false;
do {
document.write(( + + i) + ”) ” + y + ”<br />”);
var z=x;
x=y;
y + =z;
next = confirm(”Do you want the next Fibonacci number”);
}while(next);
document.write(”</h2>”);
</script>
</body>

COPA 201 Dr.V.Nagaradjane


</html>

8.5.23 Functions in Javascript


1 Generally, functions have 3 components:

1. The function keyword at the beginning.


2. The name of function following the function keyword. The
name of function contains pair of brackets (), which might
contain arguments.
3. Body of the function enclosed in a pair of curly braces ({ }).
The function might use return keyword to return a value after
processing data.

2 In general, a named block of code is called function, which may be


invoked using the given name.

3 A variable declared inside the function dies within that function.

4 A function may access variables declared inside the function or with


a global scope (outside any function).

5 Any changes made by a function to the global variables is perma-


nent and is visible in other functions too.

Example of functions with and without arguments and return


value
The following code shows 3 functions, having different combination of
arguments and return values.
<html>
<head>
<title>
Test of Javascript functions
</title>
<script>
//Function without argument and without return value
function add1() {
var x = prompt(”Enter x”),
y = prompt(”Enter y”),

COPA 202 Dr.V.Nagaradjane


z=Number(x) + Number(y);
alert(x + ” + ” + y + ” = ” + z);
}
//Function with arguments but without return value
function add2(x, y, z) {
var z=Number(x) + Number(y);
alert(x + ” + ” + y + ” = ” + z);
}
//Function with arguments and return value
function add3(x, y) {
var z = Number(x) + Number(y);
return z;
}

</script>
</head>

<body>
<script>
add1();
add2(5, 10);
var res = add3(20,45);
document.write(”20 + 45 = ” + res);
</script>
</body>
</html>

8.5.24 OOPS in Javascript


1 OOPS stands for Object Oriented Programming System.
2 Object is a programming entity having properties (to store values)
and methods (to work with properties).
3 Javascript supports Object creation using function.
4 A function can be converted to a class definition.
5 Variable declared inside the function is accessed with dot operator.
6 A method is declared using the expression this.method = function()
{}.

COPA 203 Dr.V.Nagaradjane


Example of objects using Javascript function

Example of objects using Javascript function


<html>
<head>
<title>
OOPS using Javascript
</title>
<script>
function Student(name, dob, grade) {
this.name=name;
this.dob=dob;
this.grade=grade;
this.getName = function() {
return this.name;
}
this.getDOB = function() {
return this.dob;
}
this.getGrade = function() {
return this.grade;
}
this.setGrade = function(gr) {
this.grade = gr;
}
}
</script>
</head>
<body>
<script>
var s1 = new Student(’Desiga’, ’2000-05-12’,’A’),
s2 = new Student(’Gayathri’,’2001-03-01’,’B’);
document.write(”<h1 style=’color:#FF0000’>
Before changing grade < /h1 ><h2 style=’color:#0000FF’>”);
document.write(s1.getName() + ”: ” + s1.getDOB() +
”: ” + s1.getGrade() + ”<br />”);
document.write(s2.getName() + ”: ” + s2.getDOB() +
”: ” + s2.getGrade() + ”<br />”);
s1.setGrade(’S’);
s2.setGrade(’A’);
document.write(”</h2><br /><br />

COPA 204 Dr.V.Nagaradjane


< h1 style=’color:#FF0000’> After changing grade
</h1><h2 style=’color:#0000FF’>”);
document.write(s1.getName() + ”: ” + s1.getDOB() +
”: ” + s1.getGrade() + ”<br />”);
document.write(s2.getName() + ”: ” + s2.getDOB() +
”: ” + s2.getGrade() + ”<br />”);
document.write(”</h2>”);
</script>
</body>
</html>

8.5.25 Built in JavaScript functions overview


1 Functions which are readily available in the general environment of
Javascript are called built-in functions.

2 Buil-in functions help to process data belonging to the built-in data


types.

3 Built-in functions of Javascript may be categorized under the fol-


lowing heads:

1. Number functions
2. String functions
3. Array functions
4. Date functions
5. Math functions

4 The built-in functions belonging to the above categories are de-


scribed in the following sections.

Built-in functions in Number data type


• toExponential(): Formats a number in exponential (X × 10y )
notation.

• toFixed(digits): Formats a number with given number of digits


after the decimal point.

• toLocaleString(): Formats a number based on browser geo-location.

COPA 205 Dr.V.Nagaradjane


• toPrecision(digits): Formats the number with given total number
of digits (including those to the left and right of decimal point).

• toString(): Returns String value.

• valueOf(): Returns value of the number.

Built-in functions in String data type


• charAt(index): Returns character at given index location. Count-
ing starts from 0.

• charCodeAt(index): Returns UNICODE value of the character at


given location. Counting starts from 0.

• concat(s1,s2, s3): Joins given Strings (s1, s2, s3, etc.) with
original String and returns the joined String.

• indexOf(s1): Returns the location where the given String s1 occurs


inside the original String. Returns -1 if no occurrence of s1 is
available inside the original String.

• lastIndexOf(s1): Returns the last location where the given String


s1 occurs inside the original String. Returns -1 if no occurrence of
s1 is available inside the original String.

• localeCompare(s1): Compares original String and given String.


Returns -1 if the original String sorts before given String, 0 if both
are equal and 1 if the original String sorts after the given String.

• length(): Returns the length of String.

• match(s1): Compares the original and given Strings based on reg-


ular expression notation.

• replace(s1, s2): Search for occurrences of s1 inside the original


String and replace with s2. String s1 may have regular expression.

• search(s1): Searches the original String for the given String s1.
The String s1 may have regular expression.

• slice(begin, end): Splits the original String between given begin-


ning and end points. Returns the split String.

COPA 206 Dr.V.Nagaradjane


• toLocalLowerCase()/ toLocalUpperCase(): Returns lower case
version (or upper case version) according locale String based on
current geo-locale.

• toLowerCase()/ toUpperCase(): Returns lower case version (or


upper case version) according locale String.

Built-in functions in Array data type


• concat(a1, a2, a3): Appends arrays a1, a2, a3, etc. to the original
array and return the resultign array.

• every(function): Returns values which satisfy given function. The


function should return Boolean value.

• filter(function): Returns values which satisfy given filter function.


The function should return Boolean value.

• forEach(function): Calls given function for each element of the


array.

• indexOf(val): Returns the firts occurrence location of the given


value in the original array.

• join(): Creates a String using the values of the array.

• lastIndexOf(val): Returns the last location at which given value


occurs.

• map(function): Calls given function with each element of the array


and returns the results in new array.

• pop(): Remove the last element of the array.

• push(): Add new element to the end of the array.

• reduce(): Apply given function to the right and left elements and
replace them with given result till there remains only a single ele-
ment.

• reduceRight(): Reduces given array from right to left, applies


given function and returns a single value.

• shift(): Removes the first element of the array. Returns the value
of removed element.

COPA 207 Dr.V.Nagaradjane


• slice(begin, end): Splits the array from given beginning through
the given end.

• sort(): Sorts elements of the array.

• splice(location, length, value): Adds given value at given loca-


tion. It removes elements at given location if the length is greater
than 0.

• unshift(): Adds one element to the beginning of array.

Built-in functions in Date data type


• Date(): Date and time of today and now.

• getDate(): Returns day of month (month counting starts at 0).

• getDay(): Returns day of week (day count starts at 0).

• getFullYear(): Returns year stored in the date object in 4 digit


format.

• getHours(): Return the time stored in the date object in 24 hour


format.

• getMilliSeconds(): Returns the millisecond value of time stored


in date object.

• getMinutes(): Returns the minutes part of time stored in the date


object.

• getMonth(): Returns month value stored in the date object (month


count starts at 0).

• getSeconds(): Returns the seconds part stored in the date object.

• getTime(): Returns milliseconds passed since the epoch date of


01.01.1970 (midnight).

• getUTCDate(), getUTCDay(), getUTCFullYear(),


getUTCHours(), getUTCMilliseconds(), getUTCMinutes(),
getUTCMonth(), getUTCSeconds(): get day of month, day
of week, year, hours, milli-seconds, minutes, month and seconds in
Coordinated Universal Time.

• setDate(dt): Set dt value in the day of month part of date object.

COPA 208 Dr.V.Nagaradjane


• setFullYear(y): Set y value in full year part of date object.

• toDateString(): Returns the date and time values in human read-


able string format.

• toGMTString(): Returns human readable date and time in Green-


wich Mean Time format.

• toLocalFormat(): Converts date to given format string.

• toLocaleString(): Returns string value of date to the local date


and time format.

• toLocaleTimeString(): Returns time part of the date according


local format.

• toSource(): Return string equivalent of date object.

• toUTCString(): Returns string value of date object in Coordinated


Universal Time format.

• valueOf(): Returns the primitive value of date object.

• Date.parse(str): Parse the string and obtain equivalent date ob-


ject.

• Date.UTC(): Returns milliseconds value based on Coordinated


Universal Time.

Built-in functions in Math data type


• Math.abs(x): Returns absolute value of given number, ignoring +
or - signs.

• Math.acos(x): Returns arc cosine (cos−1 ) value of x.

• Math.asin(x): Returns arc sine (sin−1 ) value of x.

• Math.atan(x): Returns arc tangent (tan−1 ) value of x.

• Math.atan2(x, y): Returns the arc tangent (tan−1 ) of x


y value.

• Math.ceil(x): Returns the integer just greater than given fraction


x.

• Math.cos(x): Returns the cosine value of x.

COPA 209 Dr.V.Nagaradjane


• Math.exp(x): Return ex value of x, where e is the base for Napier’s
logarithm (e = 2.718281828459)

• Math.floor(x): Returns the integer just lower than the given frac-
tion x.

• Math.log(x): Returns natural logarithm to the base e for the value


of given x.

• Math.log10(x): Returns logaithm to the base 10 for value of x.

• Math.max(x,y,z,...): Returns maximum of the given set of values.

• Math.min(x,y,z,...): Returns minimum of the given set of values.

• Math.pow(x,y): Returns x power y (xy ) value.

• Math.random(): Returns random number between 0 and 1.

• Math.round(x): Rounds given number x to the nearest integer


value.

• Math.sin(x): Returns sine value of x.

• Math.sqrt(x): Returns square root of x.

• Math.tan(x): Returns tangent value of x.

8.5.26 Built-in functions in RegExp data type


• RegExp.match(exp): Matches given exp regular expression against
the given string. Returns the matching part.

• RegExp.test(exp): Matches given exp regular expression against


the given string. Returns true if a matching part is found.

Popup boxes in Javascript


1 Popup box opens out of a web page to convey an information, to
confirm an action or to obtain an input.

2 Following types of popup boxes are supported by Javascript:

1. alert(message): Displays given message through a popup


dialog.

COPA 210 Dr.V.Nagaradjane


2. confirm(message): Confirms whether given option should
be OK or Cancel.
3. prompt(message, default): Prompts for an input by dis-
playing a message and a default value (optional).

<html>
<head>
<title>Dialogs in Javascript</title>
</head>
<body>
<script>
var x = prompt(”Enter x:”,”10”);
var y = prompt(”Enter y:”,”20”);
if(confirm(”Do you wish to add the numbers?”)) {
var z = Number(x) + Number(y);
alert(x + ” + ” + y + ” = ” + z);
}
else
alert(”You have chosen not to do anything with the given numbers”);
</script>
</body>
</html>

Document Object Model (DOM)


1 Accessing elements of a web page as though they belong to a doc-
ument (using the this.document interface methods and properties)
is called Document Object Model (DOM).

2 Document Object Model (DOM) may be visualized as shown in


Fig.8.1.

3 DOM supports access to HTML elements. Such element properties


of DOM are shown in Fig.8.2.

Methods and properties of Document Object Model (DOM)


(1) getElementById(id): Returns the element having the given id
from the HTML document.

COPA 211 Dr.V.Nagaradjane


Figure 8.1: Document Object Model[82]

Figure 8.2: Properties of Document Object Model[83]

COPA 212 Dr.V.Nagaradjane


(2) getElementByName(name): Returns the HTML element having
the given name.

(3) getElementsByTagName(tag): Returns an array of elements hav-


ing the given tag name.

(4) getElementsByClassName(cls): Returns an array of objects be-


longing to given class name.

(5) write(str): Writes given string value to the document.

(6) writeln(str): Writes given string value to the document and ap-
pends a newline character.

(7) innerHTML: Sets HTML portion for a particular element of the


document.

(8) innerText: Sets text value for a particular element of the docu-
ment.

Example of DOM
<html>
<head>
<title>
Test of DOM
</title>
<script type=”text/javascript”>
function welcome() {
var name = document.nameForm.n.value; //DOM access
document.write(”Welcome ” + name + ”!”); //DOM method write is
used
}
</script>
</head>
<body>
<form name=”nameForm” method=”GET” action=”#”>
<center>
Enter name: <input type=”text” name=”n”><br />
<input type=”button” value=”Message” onClick=”welcome()”>
</center>
</form>
</body>

COPA 213 Dr.V.Nagaradjane


Figure 8.3: Properties of Browser Object Model[83]

</html>

8.5.27 Browser Object Model (BOM)


1 Browser Object Model (BOM) is supported by the window class.

2 The window class of BOM is the parent of all other objects. The
structure of BOM is shown in Fig.8.3.

Methods of window object in BOM


1 alert(msg): Displays alert message.

2 prompt(msg, default): Displays input dialog with given message


and default value.

3 confirm(msg): Displays confirmation dialog with OK and Cancel


options.

4 open(): Opens a new window.

5 close(): Closes current window.

6 setTimeout(): Waits for given amount of time before taking ac-


tion.

Methods of window.history object in BOM


1 window.history.forward(): Equivalent to pressing forward button
in browser.

COPA 214 Dr.V.Nagaradjane


2 window.history.back(): Equivalent to pressing back button in
browser.

3 window.history.go(number): Loads given page number in history


object.

Methods of window.screen object in BOM


1 window.screen.width: Returns the width of screen.

2 window.screen.height: Returns the height of screen.

3 window.screen.availWidth: Returns available width after deduct-


ing the width of unusable portions.

4 window.screen.availHeight: Returns available height after de-


ducting the height of unusable portions (like title bar, status bar,
etc.).

5 window.screen.colorDepth: Returns color depth.

6 window.screen.pixelDepth: Returns pixel depth.

COPA 215 Dr.V.Nagaradjane


COPA 216 Dr.V.Nagaradjane
Chapter 9

Advanced Excel Concepts

Syllabus
MS excel revision (row, columns, basic formatting, insert menu,
Print setup, etc. ) and Look up introduction and functions Types of
references and cell naming Excel Linkage Custom Format and Excel
Protection Tips and tricks Pivot table and Pivot chart Conditional
formatting Advanced Graphs Power Queries

9.1 Introduction to Excel features and Data


Types
9.1.1 Introduction to features of Excel
• Excel works on the basis of cells, one cell being the intersection of
a column and a row.

• Columns (vertically aligned dividers) have the alphabet names (A,B,C,


... Z, AA, AB, ..., AZ, BA...).

• Rows have numeric identifier (1, 2, 3, ...).

• Cells are addressed by combination of column name - row number,


e.g. A1 for the first cell, B6 for the cell at second column, sixth
row.

• Excel has a large collection of functions (entered in a cell after


typing = sign), which are helpful in data analysis and computations.

217
• Excel can sort and arrange data in easily readable format.

• Excel can draw charts (like pie, bar, column, scatter, etc.) to help
visualize data entered in cells.

• The latest version of Excel can have maximum of 10,48,576 rows


and 16,384 columns. The maximum number of rows and columns
may vary from version to version.

9.2 Lookup functions


• Lookup functions search in an array of data for a particular value.

• They return given column value when matching row is found.

• Lookup functions are:

1. LOOKUP(value, range to search, range to return): Searches


for given value in the range of cells specified. It returns the
corresponding value from the matching row.
2. VLOOKUP(value, range to search, column index to re-
turn): Searches for given value in the first column of the
range of cells specified. It returns the corresponding column
index value from the matching row.
3. HLOOKUP(value, range to search, row index to return):
Searches for given value in the first row of the range of cells
specified. It returns the corresponding row index value from
the matching row.

9.3 Cell protection


• Cells can be protected at the cell level, sheet level or workbook
level.

• Selected cell can be protected by opening Home − > Alignment


− > Format cells. Choose Locked checkbox. Pressing Ok button
locks the cells.

• To protect a sheet or workbook, go to Review − > Changes − >


Protect Sheet or Review − > Changes − > Protect Workbook.

COPA 218 Dr.V.Nagaradjane


9.4 Sorting in MS Excel
• To sort data, select all the cells containing the data to be sorted.

• Avoid the most common mistakes of selecting the just the single col-
umn containing the values to be sorted and omitting some columns
which you might consider unnecessary of inclusion. Such an error
may result in separation of data from its proper row members.

• Click Data− > Sort. In the dialog that opens, keep or remove the
tick mark against the field ”My data contains headers”.

• The sort options contain 3 columns. First, select the column using
which data needs to be sorted. In case the data contains headers,
the header name is displayed. Otherwise, column name in alphabets
(A,B,C,...) is displayed.

• In the second criterion, choose either values, cell color or cell icon.

• In the third criterion, choose smallest to largest or largest to small-


est for number. Choose A to Z or Z to A for text data.

• Press sort button to sort the data.

9.5 Cell referencing


• When the name of cell (like B5) is referenced in a formula, it can
be done in 3 different ways, as detailed below:

1. Relative referencing - dynamic row & column change mode


2. Semi-relative referencing - fynamic row & static column mode
or static row and dynamic column mode
3. Absolute referencing - static row & static column mode

• Relative referencing: In this mode, copying the formula to a new


cell (e.g., add 4 to columns & 3 to rows) causes the cell reference
to change relative to the new column (by adding the same 4 to
columns & 3 to rows to the reference made in the formula).

• Semi-relative referencing: In this mode, either the row or column


references are static, denoted by a $ symbol preceding the row
number or column name.

COPA 219 Dr.V.Nagaradjane


• Absolute referencing: In this mode, both column name and row
number are static and are preceded by a $ symbol. When the
formula is copied from one cell to another, the cell references do
not change.

9.6 Filtering of data in MS Excel


• For filtering data, the first row should contain headers.

• Select all the data including headers.

• Choose Data − > Filter. A triangular filter marker appears to the


right of each column in the first row of data.

• Clicking the triangular marker of any column permits sorting in as-


cending or descending order, sorting by color, search for specific
values, applying several filter conditions for numbers (like equals,
does not equal, greater than, less than, less than or equal to, be-
tween, top 10, above average, below average, custom filter) and
text (like equals, does not equal, begins with, ends with, contains,
does not contain,custom filter).

• Filter helps to select data based on convenient criterion.

9.7 Validation of data in MS Excel


• Select the cells (or column or row) in which data validation is re-
quired.

• Choose Data − > Data Validation from the menu. Select Data
Validation.

• The data validation dialog appears.

• Select the data type from Allow criterion.

• Select the data criterion (between, not between, equal to, not equal
to, greater than, less than, greater than or equal to, less than or
equal to).

• Enter the values for validation.

COPA 220 Dr.V.Nagaradjane


• If you wish to display an error message for wrong input, click Input
Message tab and enter the title and content of error message.

• Press OK to apply the condition.

• To indicate error in data by circle, choose Data − > Data Validation-


¿Circle invalid data.

9.8 Analyzing data using charts in MS


Excel
• MS Excel supports column, line, pie, area, scatter and other chart
types like stock, surface, doughnut, bubble and radar.

• To display a chart like column, line, pie or bar, type X-Axis title in
the one column and Y-Axis title in the next column.

• Enter X-Axis values and Y-Axis values in the selected columns.

• Select the data (including title).

• Choose Insert menu. Click the type of chart like column, line, pie,
bar or scatter.

• The chart is inserted by Excel.

• Edit display parameters if necessary.

9.9 Data tables in MS Excel


• Using data table, Excel can be made to calculate the results for a
row, a column or an array.

• If you wish to create a column based data table, fill the input values
on the left. Calculate the result for the first row.

• Select the entire table, choose Data − > What If Analysis − >
Data Table.

• Choose first column in the input box (leave the row value blank).

• Excel will fill up the remaining blank cells.

COPA 221 Dr.V.Nagaradjane


• Similarly, you can create a row based data table. You need to
create a row based input, calculate the result in the first column of
the next row. Choose first cell of the row in row input (leave the
column value blank) during creation of data table.

• If you wish to create a matrix using data table, enter input values
in 2 cells, calculate the result value in a new cell.

• Create a row of inputs to the right of the result cell.

• Create a column of inputs below the result cell.

• Select the new matrix. Leave the row and column input cells uns-
elected.

• Choose What Data − > If Analysis − > Data Table.

• In the input box, select the cells for row and column input.

• When OK button is pressed, Excel fills all the cells of the matrix
based on your formula.

9.10 Pivot table in MS Excel


• Pivot table (and pivot chart) provide a means for summarizing data
presented in a table.

• Choose the table based on which pivot table needs to be created.

• Choose Insert − > Pivot − > Pivot Table.

• MS Excel inserts a summary table in a new worksheet.

9.11 Goal seek in MS Excel


• Suppose you have a formula in a cell.

• If you wish to know the input for which the formula will yield a
desired result, goal seek will help you.

• Click the cell containing the formula. Choose Data − > What If
Analysis − > Goal Seek.

• In the first cell of the dialog, enter desired result.

COPA 222 Dr.V.Nagaradjane


• In the second cell, enter the address of the cell containing wrong
input, which needs to be adjusted to produce the desired new result.
• Press seek button and see the suggested new input value.
• Press OK to accept the modified input and cancel to discard the
changes.

9.12 Scenarios in MS Excel


• Scenario helps to save different sets of input values and compare
the results of different scenario later on.
• To create a scenario, create a set of input values and calculate the
result.
• Choose Data − > What If Analysis − > Scenario. Enter a title.
• Choose cells for which different sets of input values are to be tested.
Use control to select more than one cell.
• Save the scenario with an optional comment.
• Repeat the same steps to create more such scenarios. Save different
input values for each scenario.
• You can choose any of the scenario at a later time to see the results.

9.13 Advanced graphs in MS Excel


• Insert menu in MS Excel provides several graph options, including
line chart, scatter diagram, column bart, bar chart, pie chart and
3-D surface charts.
• The data to be visualized in the graph is to be entered with appro-
priate column headings.
• After selecting the data to be visualized, accessing the Insert − >
Chart menu item provides the list of options available for charting.
• Chart may be inserted as a floating frame over a spreadsheet or as
a separate sheet.
• Right clicking various regions of a chart provides the options for
customizing the chart.

COPA 223 Dr.V.Nagaradjane


(a) Column chart (b) Donut chart

(c) Histogram chart (d) Waterfall chart

Figure 9.1: Advanced charts in MS Excel [14]

9.14 Advanced graphs in MS Excel


• Insert menu in MS Excel provides several graph options, including
line chart, scatter diagram, column bart, bar chart, pie chart and
3-D surface charts.

• The data to be visualized in the graph is to be entered with appro-


priate column headings.

• After selecting the data to be visualized, accessing the Insert − >


Chart menu item provides the list of options available for charting.

• Chart may be inserted as a floating frame over a spreadsheet or as


a separate sheet.

• Right clicking various regions of a chart provides the options for


customizing the chart.

• Fig.9.1 shows some of the advanced chart options available in MS


Excel.

COPA 224 Dr.V.Nagaradjane


Figure 9.2: Menu for importing external data in MS Excel [15]

9.15 Power query in MS Excel


• MS Excel provides advanced option for importing data from cloud
storages and other data sources.

• Fig.9.2 shows the menu for connecting to external data source in


MS Excel.

• On connecting to an external data source, the raw data is to be


imported to a worksheet.

• The raw data imported into the worksheet should be suitably trans-
formed/ reorganized for easy charting.

• An appropriate chart may be created using the transformed data


and chart elements modified as per requirements.

• Whenever the particular workbook is opened in MS Excel or when


Ctrl + F 5 is pressed to refresh the spreadsheet or when Ctrl +
Alt + F 5 is pressed to refresh the entire workbook, external data
is synchronized and fresh data is imported.

• Charts created using power query option are automatically redrawn


by MS Excel when data changes.

COPA 225 Dr.V.Nagaradjane


COPA 226 Dr.V.Nagaradjane
Chapter 10

E-Commerce

Syllabus
Introduction to E Commerce and advantages. Building business on
the net. Payment and Order Processing, Authorization, Charge-
back and other payment methods. Security issues and payment
gateways.

10.1 Definition of E-Commerce


1 e-commerce stands for electronic commerce, which means selling
or buying goods through electronic means like Internet, phone line,
sms, etc.
2 Selling or buying goods through electronic means (based on product
description and photos) is called E-Commerce.
3 e-commerce may be carried out over phone line, SMS or the Inter-
net.
4 The buyer relies upon the description, photos and videos of the
product being sold online to make a decision.
5 e-commerce involves to entities (the buyer and the seller) connected
through a common platform.

10.1.1 Types of e-commerce


1 B2B or Business to Business: When the seller is a business firm

227
and the buyer too is business firm (not an individual consumer),
the e-commerce transaction is called B2B or Business to Business
transaction.

2 B2C or Business to Consumer: When the seller is an online


business firm and the buyer is an individual, the online business
transaction is called B2C or Business to Consumer.

3 C2B or Consumer to Business: When the seller is an individual


and the buyer is a business firm, the online business model is called
C2B or Consumer to Business.

4 C2C or Consumer to Consumer: When the seller and the buyer


are both individuals, the online business model is called C2C or
Consumer to Consumer.

10.2 Scope of e-commerce platform


1 e-commerce platforms like quikr, olx, etc. have local scope.

2 e-commerce platforms like Flipkart, Shopclues, Snapdeal, etc.

3 e-commerce platforms like eBay, amazon, etc. have global scope


in electronic commerce.

4 Scope of the e-commerce platform ranges from local level to global


level.

5 Benefits

10.3 Benefits of e-commerce


1 Electronic commerce helps the buyer to choose the most competi-
tive price for a product from several alternate sellers.

2 e-commerce allows a seller to fetch competitive price for products.

3 e-commerce helps a consumer to order a product from far off places,


even if such product is not available in the local market.

COPA 228 Dr.V.Nagaradjane


10.4 Disadvantages of e-commerce
1 Descriptions and photos provided by the seller may not match the
delivered product.

2 A product may get damaged during transit, since the seller and the
buyer are located at far off places.

3 The buyer may fail to pay for a product.

4 The buyer might return the product after using it for few days,
which could result in the loss of transit and other expenses to the
seller.

5 The buyer might get delivery of the product on the expected date.

10.5 De-Commerce vs. traditional com-


merce
Table 10.1 shows the difference between e-Commerce and traditional com-
merce.

10.6 Capabilities for e-commerce


1 An e-commerce platform should provide a cart, where items may
be added or removed.

2 Options for payment through CoD (Cash on Delivery), credit card,


debit card, netbanking and wallet transfer should be supported by
the platform.

3 e-commerce platform should provide a dedicated transport mecha-


nism to deliver the products on specified time line.

4 The buyer and seller should be permitted to share and rate their
experience for each online transaction.

10.7 Technology issues


1 The online platform should provide secure transaction facilities to
prevent fraudsters from cheating a buyer or seller.

COPA 229 Dr.V.Nagaradjane


Table 10.1: Difference between E-Commerce and traditional com-
merce
No. e-commerce traditional commerce
Buyer cannot touch or feel Buyer can examine the
1
the product before buying. product before buying.
2 Bargaining is restricted. Bargaining is possible.
Shipping time results in de- Immediate delivery of prod-
3
lay in getting the product. uct.
User needs to figure out the Usually, a demo is given at
4
usage procedure by himself. the shop floor.
Testing a product before Testing before purchase is
5
purchase is not possible. possible.
In case of dispute, the buyer
and seller need to be fluent Conversations regarding a
6
in a common language (like product are easy.
English).
e-commerce platform
Product infiltration
allows manufacturers to
7 through the market chain
speedily distribute their
takes time.
new products.
The buyer can be assured
Fraudulant platforms might
8 of product delivery for the
result in loss to the buyer.
money paid.
e-commerce permits com- Visiting several shops to
9
parison of several products. buy a product is cumber-
some.

COPA 230 Dr.V.Nagaradjane


2 The payment gateway should be secure and be available 24 × 7.

3 Reward points and redemption system should be provided to en-


courage the buyer.

4 Broken Internet connection before completing a transaction might


result in loss of money to the buyer.

10.8 Types of E-Commerce web sites


1 Transactional type sites: In transactional type, physical stores
provide an online alternative. Customers can either visit the physi-
cal store or the online store to get a product.

2 Information delivery sites: Large manufacturers might run web-


sites simply to disseminate information about their products. These
sites might include online fora for discussion on technical issues.

3 e-market place: This type of website permits registration of buyers


and sellers. The e-marketplace functions as the facilitator between
the buyer and the seller and takes commission amount for the ser-
vice.

10.9 Building business on the net


1 Building an online business requires the seller to create visuals and
descriptions for the products.

2 The seller should ensure that the description is unambiguous.

3 The seller should keep the buyer updated about each stage of the
online transaction from purchase to eventual delivery of product.

4 The seller should ensure that the buyer is provided a pleasant ex-
perience through all stages of his transaction.

5 The buyer should have the service and support for the online prod-
uct.

6 The online business platform should provide an easy interface to


the users.

COPA 231 Dr.V.Nagaradjane


10.10 Online catelogue
• Providing full description of a product sold online is called the online
catelogue.

• The online catelogue shoud describe all physical and internal fea-
tures.

• The online catelogue should provide clear instructions for operating


a product.

• Online catelogue should provide clear price tag for each product.

• Online catelogue should describe defects, if any, in the product.

10.11 Shopping cart


• The place for keeping all selected items before final checkout from
an online store is called a cart.

• Cart provides facility to add, remove or modify products through


online.

• Cart items are deleted when a purchase transaction is made online.

10.12 Checkout pages


• After adding items to the cart, the customer is provided detailed
list of items, quantities, rates and amounts for each transaction.

• When the user provides confirmation that the items in the cart are
really meant to be purchased, the checout page redirects the user
to payment page.

10.13 Payment for e-commerce transac-


tion
• Payment for an online transaction may be made through the fol-
lowing methods:

COPA 232 Dr.V.Nagaradjane


1. Cash On Delivery (COD): The buyer pays money when the
product is delivered.
2. Credit card: A card bearing 16 digit number, expiry month
& year, name of card holder and a Card Verification Value
(CVV) and permitting permitting spending first and collection
on later date is called credit card. This card permits payment
of money for goods and services. This amount should be paid
up during the credit card bill cycle. Credit card permits con-
version of large purchase amount to EMI (Equated Monthly
Installment) payment.
3. Debit card: A card bearing 16 digit number, expiry month &
year, name of card holder and a Card Verification Value (CVV)
is called and permits spending the money already debosited
in an account is called debit card. This card permits payment
of money for goods and services from prepaid deposits.
4. Internet banking: Internet banking permits logging in to a
bank site using an ID and password and authorizing the online
payment. Some banks send an OTP (One Time Password) to
registered mobile number/ email ID, which should be entered
in the online site to make sure that the original owner of the
account is makign the transaction.

• All the above methods of payment might require entry of an OTP


(One Time Password) received on the registered email ID or mobile
number.

• Some banks permit entry of certain numbers from a predefined grid


pattern to be entered to complete a transaction.

10.14 Security issues for online payment


• The user should ensure that green color lock icon appears near the
address bar of the browser.

• The user should ensure that the lock icon is not crossed out.

• The user should ensure that the Internet connection is stable for
completing payment transaction in one go.

• The user should ensure that the payment transaction is completed


within the shortest possible time limit. Otherwise, the session might

COPA 233 Dr.V.Nagaradjane


expire and the money may remain unpaid to the e-commerce site,
but debited from the bank account of the user.

• The user should ensure that the payment URL begins with https,
which is a secure communication protocol over hyper text trans-
mission protocol.

10.15 Payment gateway


• A third party online payment system which receives money from
the buyer and transfers the same to the seller is called a payment
gateway.

• CCAvenue, PaySeal, PayPal, etc. are some of the common payment


gateways.

• For each successful transaction, the payment gateway takes a com-


mission and transfers the remaining amout to the account of the
beneficiary.

COPA 234 Dr.V.Nagaradjane


Chapter 11

Cyber security

Syllabus
Overview of Information Security, SSL, HTTPS, Security threats,
information Security vulnerability and Risk management. Introduc-
tion to Directory Services, Access Control, Security, Privacy pro-
tection, Audit and Security. Introduction to IT Act and penalties
for cybercrimes.

11.1 Cyber security


1 Protecting computer users from online attacks aimed at damaging
the data, software, monetary loss or any other damages is called
cyber security.

2 The term cyber means interaction of computers through Network.

3 Cyber crime is a malafide act happening inside the networking do-


main.

4 Victims of cyber crimes might loose data or money.

11.2 Information security


• Information security is the practice of preventing unauthorized use
of information.

• Information Security is abbreviated to InfoSec.

235
• Under information security, any device having processor and mem-
ory is categorised under computing device.
• Keeping the data of a device safe from unauthorized users is called
information security.
• CIA: CIA is the abbreviation for Confidentiality, Integrity & Avail-
ability under information security.

11.3 Threats to information security


• Worms: Worms are little scripts sent through email attachments.
These enter the computer system when user tries to open the at-
tachment. Worms might result in scare, loss of data from the
system.
• Phising attacks: Creating a cheat URL resembling an authentic
website and making the victim to reveal login credentials is called
phishing attack. In most of the cases, phishing victims innocently
reveal bank login details, which are misused by the attacker.
• Trojans: A normal looking program may have an embedded mal-
ware. The malware might collect sensitive data and transmit the
same to the attacker.
• Computer virus: A malicious which becomes hooked to the opearat-
ing system and keeps continuously working to damage data stored
in the device is called virus. Virus spreads through Internet, storage
media like pen drive, etc.
• Breach of information security might result in theft of proprietory
manufacturing processes or fomulae from large firms.

11.4 Vulnerability
• Sources of weakness in the IT infrastructure for potential theft of
information is called vulnerability.
• Vulnerabilities may be found in the operating system. These vul-
nerabilities are targeted by hackers and exploited.
• The network connection might be insecure due to lack of firewall,
anti-virus and other online protection software packages.

COPA 236 Dr.V.Nagaradjane


• An application software might include a vulnerability. When this
software runs, hackers may intrude the system and cause damages.

• Failure to conduct periodic security audit of computer systems


might result in data vulnerability.

• Identifying sources of data disruption and ensuring continuous safety


of business data is called risk management.

11.5 Risk management


• The likelihood of loss of data due to security vulnerability is called
risk.

• Risk management is the process of ensuring smooth functioning of


business without permitting any attack on the information held by
an organization.

• A team of people calculate the risk faced by an organization based


on existing vulnerabilities and sources of threat. The team decides
upon the safe practices, software and hardware implementations to
be adopted for complete information safety.

• To ensure information safety, an organization should have (i)security


policy, (ii)organization of information security, (iii)human resource
security, (iv)access control, (v)physical security, (vi)security inci-
dent management, (vii)safe disposal of damaged hard copies, (viii)safe
disposal of damaged storage media.

11.6 Introduction to Directory Services


• Directory service is a single access point which could take a user to
sevel other services located at different URLs.

• The directory service simplies the job of security administrator to


the safe maintenance of directory service alone.

• Directory service may store data in several computers. But, the


user should find that the directory is a single point.

• The directory service should be able to include new objects based


on changes to network.

COPA 237 Dr.V.Nagaradjane


• Searching for information from various locations on the network
should be easy.
• The directory system should be independent of the physical location
of the user or the administrator.
• The information stored in directory service should be accessible
from any operating system.
• LDAP (Light Weight Directory Access Protocol) provides an easy
mechanism for querying directory service.

11.7 Access control


• Access control is the selective permission to particular individuals
to access a computer and perform their works.
• Access control may be physical security to the computer. Users may
be permitted to use the computer only if they are authenticated
through smart card, finger print, iris scan, etc.
• Access control may be implemented through software. Users may
be required to provide a valid pair of identifier (ID) and password.
• Access control may be implemented through a combination of phys-
ical and software controls.
• The layout of the access control components is called access control
topology.

11.8 Software development security


• Security is implemented at the development stage of a software.
• Security of software is designed to cover the entire life cycle of
software.
• Software Development Life Cycle (SDLC) is the planning of the
security measures to be incorporated in a software throughout the
life span of the software.
• Protection from disclosure: is the prevention of disclosure of
source code by any individual involved in the development of a
software product.

COPA 238 Dr.V.Nagaradjane


• Protection from alteration: The source code should not be al-
tered without appropriate authorization.
• Protection from destruction: Any individual should not have the
right to delete or destroy the entire software.
• Whois making the request: Any request for changing or deleting
software components should be recorded.
• Verify access rights: Any request from a user should be verified
against the rights granted to the user. The user should be prevented
from carrying out actions which are not permitted.
• Maintaining historical records: A chronological record of all ac-
cesses made by individuals and changes brought about to source
code should be maintained.
• Error handling: The software framework should be able to handle
configuration errors, session errors and exception in a consistent
manner.

11.9 Privacy protection


• Data relating to several types of individuals may be held in the IT
infrastructure of an organization.
• Protecting the data from unauthorized access is called privacy pro-
tection.
• Breach of privacy protection might result in huge damage to indi-
viduals and organizations.
• Medical records of patients, record of criminals, financial data of
companies, genetic material, address and contact details of individ-
uals, record of web surfing behaviour, record of credit card, debit
card or Internet banking creditials are some of the privacy data
which should not be compromized.

11.10 Information security audit


• Information security is audited by a team of experts with reference
to vulnerabilities, threats and preventive measures for data protec-
tion.

COPA 239 Dr.V.Nagaradjane


• The information security audit thoroughly analyses all threat events
of the past and formulates security measures for the future.

• Information security audit should be performed in a periodic man-


ner, i.e., once every month, every quarter, etc.

• Seggregation of duties should be adopted to ensure that no single


employee has all the data needed to make a fraudulant transaction.

• All segments of the organization should be protected through phys-


ical and password security measures.

• The audit team should ensure that customers of the organization


can feel safe when their data is divulged for business purpose.

• IT audit should probe abnormal behaviour of any individual, which


might be an indication of potential fraud/ theft of data.

11.11 Introduction to I.T. Act


• Information Technology Act, 2000 was introduced to prevent and
punish cyber crimes.

• I.T. Act provides support for ecommerce.

• I.T. Act protects individuals from being victimized by cyber frauds.

• A major amendment to the IT act was made in 2008.

11.12 Penalties for cybercrimes

COPA 240 Dr.V.Nagaradjane


Table 11.1: Cyber crimes and punishments
Sl. Sec Cyber Max. Max. Both
No. tion crime Prison Fine ?
Tampering docu- 2
1 65
ments years 2 Lakh Yes

2 66 Hacking 3
years 5 Lakh Yes
Receiving stolen
3 66B 3
computer/ mobile 1 Lakh Yes
years

4 66C Password abuse 3


years 1 Lakh Yes
Cheating with com-
5 66D 3
puter 1 Lakh Yes
years
Publishing private
6 66E 3
images of others 2 Lakh Yes
years
7 66F Cyber terrorism
Life − No

COPA 241 Dr.V.Nagaradjane


Table 11.2: Cyber crimes and punishments
Sl. Sec Cyber Max. Max. Both
No. tion crime Prison Fine ?
Publishing obscene 5
8 67
content years 1Lakh Yes

Publishing sexual 7
9 67A
content years 1Lakh Yes

5; 7 1Lakh;
Publishing child years 1Lakh
10 67B (sub-
porn (sub- Yes
se- se-
quent) quent)
Failure to maintain
11 67C 3
records by operator undefined Yes
years
Non-compliance 3
12 68
with orders years 2Lakh Yes

Refusal to decrypt 7
13 69
data years undefined Yes
Disclosure of wrong 3
14 70
information years 1Lakh Yes

COPA 242 Dr.V.Nagaradjane


Chapter 12

Cloud Computing and


Application Development

Syllabus
Benefits of cloud services, different categories. Resources avail-
able in cloud. Identify Phases of the Application Development Life
Cycle. Describe Roles in each of phases of the Application Devel-
opment Life Cycle.

12.1 Cloud computing


• Cloud computing means storage and processing of data on remote
computers connected through the Intenet.

• Thin clients like Chromebooks can store data and run programs in
the remote cloud.

• Cloud services are offered by several companies, including Microsoft,


IBM, Apple Computer, Google, DropBox, etc.

12.2 Categories of cloud services


• Private clouds: Private clouds are services maintained by large
firms for their internal usage.

243
• Public clouds: Public cloud services are accessed over the common
Internet. The services may be paid or free. OneDrive, iCloud,
Google Drive, DropBox, etc. are examples of public cloud.
• Hybrid clouds: Hybrid clouds provide some public services acces-
sible to everyone and some restricted services accessible for internal
use of employees.
• Community clouds: Some individuals or organizations having com-
mon interests may share data and storage on a cloud. For persons
or organizations outside the particular community, the cloud looks
like a private cloud.

12.3 Resources available on cloud


• Data storage: Photos and documents may be uploaded to cloud
server and accessed from any device.
• SaaS: Software as a Service (SaaS) provides for access to software
from any connected device. This has created annual subscription
and renewal model for software packages.
• IaaS: Infrastructure as a Service (IaaS) provides access to state of
the art IT infrastructure through cloud computers. Amazon Web
Services (AWS), Google Cloud, IBM Cloud and Microsoft Azure are
some of the IaaS services for enterprises.
• PaaS: Certain program development projects might require spe-
cific platforms, which may be costly to acquire. PaaS (Platform
as a Service) provides complete development platform for specific
duration on rental over the Internet.

12.4 Application Development Lifecycle


• Application development begins with the assessment of customer
demand, passes through planning, development and testing.
• After testing, the software may be deployed.
• Deplyoment brings new bugs to light.
• Bug fixing and maintenance are the next phases in software devel-
opment lifecycle.

COPA 244 Dr.V.Nagaradjane


Figure 12.1: Application Development Life Cycle[81]

• Some software packages might require minor improvements or com-


plete revamping. New releases of the software should be brought
out to address such needs.

12.5 Application Development Life Cycle


(ADLC)
• ADLC involves the following phases:

1. Gathering information
2. Analysis
3. Design
4. Coding and testing
5. User and system tests
6. Deploymet (Production)
7. Maintenance

COPA 245 Dr.V.Nagaradjane


COPA 246 Dr.V.Nagaradjane
Chapter 13

Python Programming
(Optional 1)

Syllabus
Introduction to Python, History of Python, Features, Setting up
path, Basic Syntax, Comments, Variables, Different Data Types,
Casting, string, Boolean
Python Operators Conditional Statements, Looping Control State-
ments, String Manipulation, Lists, Tuple, sets, Dictionaries, Arrays,
Iterators, date, math modules, Input and Output.

13.1 Introduction to Python


• Python is a general purpose programming language created by
Guido van Rossum[13] in the year 1991.

• It supports dynamic data types, which means the language decides


the data type to be used for a variable.

• Python supports automatic garbage collection, which means unused


memory will be automatically released.

• Python uses indentation (aligning code to the right) for defining


blocks and inner blocks of code (no need to use { and }.)

247
Figure 13.1: Giodo Van Rossum, Creator of Python[13]

13.2 History of Python


• Python was developed as a successor to ABC programming lan-
guage.

• Python was developed by Guido van Rossum in 1991 at Centrum


Wiskunde & Informatica (WCI) in Netherlands.

• Python2 was released on 2000 and Python3 in 2008.

• Guido van Rossum relinquished all responsibilities relating to Python


in the year 2018.

• Python version 3.10, released in 2022, is the current release of


Python.

• Python language interpreter is available for several platforms and


the same may be downloaded from the URL
https://www.python.org/downloads/.

13.3 Features of Python


• Python supports both procedural programming (function oriented)
and Object Oriented Programming System (OOPS).

• Python support Aspect Oriented Programming (AOP) and metapro-


gramming, which help to create special objects called magic objects.

• Python is a dynamically typed language. Data types need not be


declared by the programmer.

COPA 248 Dr.V.Nagaradjane


• Python has an automatic garbage collector to reclaim unused mem-
ory.

• Python supports late binding (otherwise called dynamic linkage),


which means that function names are looked up only during execu-
tion.

• Late binding offers flexibility during development, where programs


may compile even when some functions are not yet implemented.

• Python has support for filter, map, list, set, dictionary, generator,
itertools, functools, etc.

13.4 Setting up path for Python


• On installation of the latest version of Python, a folder named c:
python3x, where x is the release number, is available.

• To include Python from the command line, one may issue the com-
mand PATH=%PATH%;c:
python3.

• To permenantly add the Python folder to PATH variable:

1. Open control panel or settings app.


2. Search for environment variables.
3. Choose either system variables or user variables.
4. Click upon variable named PATH. Press Edit button.
5. Add the line c:
python3 to the PATH variable.
6. Save the changes. Now, Python would run from command
line.

13.5 Basic Syntax


• Python statements need not end with ;

• Each block of code is indented to the right.

• Fig. 13.2 shows a simple hello statement displayed through print


function in Python.

COPA 249 Dr.V.Nagaradjane


(a) Command Line Execution

(b) Editing Python script (c) Executing Python script

Figure 13.2: Executing Python Code

• Instead of running the code on the command line, program code


may be typed in a file (say hello.py) and executed by invoking
python interpreter with the file name as argument, e.g., (python3
hello.py)

13.6 Comments in Python


• Single line comments may start with # symbol. Any text to the
right of single line comment is ignored.

• Multiline comments may start with three double quote symbols


(”””). Any content till the occurrence of same triplet of double
quotes (”””) is ignored.

• Comments are ignored by Python.

13.7 Variables
• A variable may start with any alphabet or underscore ( ).

• A variable name may contain alphabets, numbers and underscore


( ). No special characters are allowed.

COPA 250 Dr.V.Nagaradjane


• Variables are case sensitive. x=5 and X=10 will assign values to
x and X as different variables. (print(x,X) will produce 5 10 as
result.

• Variables come into existence on first assignment of value.

• Obsolete variables will be automatically removed from memory


(garbage collection).

13.8 Data Types in Python


1. byte: One byte of size of data. Stores values from -128 to +127.

2. int: Integer data type. Occupies 2 or 8 bytes of storage.

3. float: Floating point number storage. Memory occupied may be


in the range of 2 bytes to 8 bytes.

4. complex: Contains a real part and imaginary part, representing a


complex number.

5. bool: Stores TRUE or FALSE as the value.

6. str: String data type.

7. None Variable does not belong to any data type.

8. list: A list is enclosed inside square brackets [].

9. tuples: Tuples are enclosed inside paranthises().

1. dict: Name value pairs are stored in dict. Dict is enclosed inside
curly braces{ }. Names and values are separated by colon : symbol.

2. set: A list of items enclosed in curly braces{ } is called a set.

3. frozenset: A list of items enclosed in curly braces{ }, which are


themselves arguments for frozenset() function is called a frozenset.

4. memoryview: Holds memory address of given variable.

5. bytearray: A series of byte values of given size.

COPA 251 Dr.V.Nagaradjane


13.9 Casting data to other types
• Data belonging to one type (e.g. str) may be cast to other types
using casting functions which have the name of target data type
itself (e.g. int()).

• Following are the common data casting functions:

1. int(): Casts given data to integer type.


x=int(”12”)
will store integer 12 in variable x.
2. float(): Casts given data to float type.
x=float(”12.74”)
will store floating point number 12.74 in variable x.
3. str(): Casts given data to string type.
x=25
y=12
z=str(x)+str(y)
print(z)
will display 2512, since both x and y were converted to strings
and then added (concatenated).
4. boolean(): Casts given data TRUE or FALSE. The value is
FALSE for 0 and TRUE for 1.

• Fig. 13.3 shows the conversion of data to int type and str type.

13.10 Operators in Python


13.10.1 Arithmetic operators in Python
Arithmetic operators are shown in Table 13.1.

13.10.2 Assignment operators in Python


Assignment operators are shown in Table 13.2.

13.10.3 Comparison operators in Python


Comparison operators are shown in Table 13.3.

COPA 252 Dr.V.Nagaradjane


(a) Casting to int using int()

(b) Casting to string using str()

Figure 13.3: Casting data to other types

Table 13.1: Arithmetic operators in Python


Sl. No. Operator Purpose Usage
1 + Addition z =x+y
2 − Subtraction z =x−y
3 ∗ Multiplication z =x∗y
4 / Division z = x/y
Integer / modulo re-
5 % mainder after divi- z = x%y
sion
6 ∗∗ Power z = x ∗ ∗y
Quotient of division
7 // z = x//y
operation

COPA 253 Dr.V.Nagaradjane


Table 13.2: Assignment operators in Python
Sl. No. Operator Purpose Usage
Assign right side
1 = value to left side z = x + y
identifier
z=5
2 += Add and assign.
z+ = 12
z=5
3 −= Substract and assign
z− = 12
z = 12
4 ∗= Multiply and assign
z∗ = 5
z = 60
5 /= Divide and assign
z/ = 5
Find Power and as- z = 3
6 ∗∗ =
sign z∗∗=2
Find remainder and z = 13
7 %=
assign z% = 5
Find quotient and z = 13
8 // =
assign z// = 5
Bitwise AND and as- z = 5
9 &=
sign z& = 4
Bitwise OR and as- z = 5
10 |=
sign z| = 8
= Bitwise XOR and as- z=5
11
sign z=7
Bitwise Right shift z = 5
12 >>=
and assign z >>= 2
Bitwise left shift and z = 5
13 <<=
assign z <<= 2

COPA 254 Dr.V.Nagaradjane


Table 13.3: Comparison operators in Python
Sl. No. Operator Purpose Usage
Equal to. Compares
left and right sides.
1 == Returns TRUE only if (x == y)
if both sides are
equal.
Not equal to. Com-
pares left and right
sides. Returns
2 != if (x! = y)
TRUE only if both
sides are NOT
equal.
Greater than. Re-
turns TRUE only if
3 > if (z > 6)
left side is greater
than right side.
Less than. Returns
TRUE only if left
4 < if (z < 6)
side is less than right
side.
Greater than or
equal to. Returns
TRUE only if left
5 >= if (z > 6)
side is greater than
or equal to the right
side.
Less than or equal
to. Returns TRUE
6 <= only if left side is less if (z < 6)
than or equal to the
right side.

COPA 255 Dr.V.Nagaradjane


Table 13.4: Logical operators in Python
Sl. No. Operator Purpose Usage
Returns TRUE only
if both left side and if (x ==
1 and
right side expres- y and y == z)
sions are TRUE.
Returns TRUE if ei-
ther left side or if (x! =
2 or
right side expression y or y == z)
is TRUE.
Returns TRUE if the
3 not right side expression if (! z > 6)
is FALSE.

Table 13.5: Identity operators in Python


Sl. No. Operator Purpose Usage
Returns TRUE of
1 in both variables refer if (xisy)
to the same object.
Returns TRUE of
both variables DO
2 is not if (xisnoty)
NOT refer to the
same object.

13.10.4 Logical operators in Python


Logical operators are shown in Table 13.4.

13.10.5 Identity operators in Python


Identity operators are shown in Table 13.5.

13.10.6 List Membership operators in Python


List membership operators are shown in Table 13.6.

13.10.7 Bitwise operators in Python


Bitwise operators are shown in Table 13.7.

COPA 256 Dr.V.Nagaradjane


Table 13.6: List Membership operators in Python
Sl. No. Operator Purpose Usage
Returns TRUE if a
1 in value is found in a if (xisy)
list of items.
Returns TRUE if
a value is NOT
2 not in if (xisnoty)
FOUND in a list of
items.

Table 13.7: Bitwise operators in Python


Sl. No. Operator Purpose Usage
z=5
1 & Bitwise AND. z&4
returns 4
z=5
2 | Bitwise OR z|8
returns 13
z=5
3 ˆ Bitwise XOR zˆ7
returns 2
z=5
4 >> Bitwise Right shift z >>= 2
returns 1
z=5
k = z << 2
5 << Bitwise left shift
makes k to assume a
value of 20

COPA 257 Dr.V.Nagaradjane


13.11 Conditional Statements
• Python supports if ... elif ... else ... condition. The elif and else
parts are optional.

• Each block (if, elif or else) is denoted by a : and appropriate in-


dentation.

• Sample code for the three forms of if condition is presented below:

1) if condition: x = int(input(”Enter your age: ”))


if(x<18):
print(”You are a kid!”)

2) if else condition:
x = int(input(”Enter your age: ”))
if(x<18):
print(”You are a kid!”)
else:
print(”You are not a kid!”)

3) if elif else condition:


x = int(input(”Enter your age: ”))
if(x<18):
print(”You are a kid!”)
elif(x<25):
print(”You are young!”)
elif(x<50):
print(”You are middle aged!”)
else:
print(”You are a respectable senior!”)

13.12 Looping in Python


• Python supports 2 types of loops:

1. for loop: For loop can take a string, an array or a range


object as argument. Following is a for loop to print numbers
from 2 to 10:
for x in range(2,11,1):
print(x)

COPA 258 Dr.V.Nagaradjane


else:
print(”Finished for loop”)
Else part in the above loop is optional. The following for loop
prints one, two, three:
for x in [”one”,”two”,”three”]:
print(x)
The following for loop prints Hello (string is split into letters):
for x in ”Hello”:
print(x)
2. while loop: The while loop gets executed till given condition
is true. Following while loop prints numbers from 2 to 10:
i=2 while i <= 10:
print(x)
i+=1
else:
print(”Finished while loop”)

3. Each of the above 2 loops may have an else indented at the


level of the loop itself. The else gets executed when the loop
finishes.

13.13 Functions in Python


• Functions begin def keyword.

• Functions have a name and arguments (which may be blank).

• Return values can be specified using return statement.

• The folllowing function calculates factorial of given number. def


fact(n):
f=1
for x in range(1,n+1,1):
f∗=x
return f
print(fact(6))

• Arbitrary number of arguments can be taken as argument to a


function if declared with ∗ before the argument name. Following
function calcualtes average of given numbers:
def avg(∗n):

COPA 259 Dr.V.Nagaradjane


s=1
for x in n:
s += x
return s/len(n)
print(avg(6,2,8,1,4))
print(avg(2,4))
The result would be 4.4 and 3 (average of given numbers).

13.14 File handling in Python


• Files can be opened using open function.

• Permitted modes are: r - read, w - write, a - append, x - write


(error if file already exists.

• Calling close function on file object closes the file.

• Following function writes the string All the best with Python
programming! to a file named copa.txt:
f = open(”copa.txt”,”w”)
f.write(”All the best with Python programming!”);
f.close()

• Following code reads the file copa.txt and displays the content:
f = open(”copa.txt”,”r”)
print(f.read())
f.close()
It prints All the best with Python programming! on the screen.

• readline() function may be used instead of read function to read


the file line by line.

13.15 Strings in Python


• Python supports single line strings and multiline strings.

• Single line strings begin and end with ” or ’ (double quote or single
quote).
e.g.,
x=”Good ”
y=”morning”

COPA 260 Dr.V.Nagaradjane


• Multiline strings begin and end with ””” or ”’ (3 consecutive double
quotes or single quotes). e.g.,
x=”””Hello,
How are you?”””

• Parts of string may be printed using array symbol. e.g.,


print(x[0:2]) would print He.

• lower, upper, strip (trim spaces), lstrip, rstrip, find, swapcase, title,
split, isupper, islower, istitle, isspace, isnumeric, isdigit, isdecimal,
isalnum, capitalize, endswith, startswith, splitlines, swapcase, join,
ljust, rjust, repalce, capitalize, casefold and center are some of the
methods which can be called upon given string.

13.16 Lists in Python


• Lists in Python are enclosed in [ ] (square brackets).e.g., x =
[”COPA”,”is”,”an”,”excellent”,”course”] is a valid list.

• Lists behave similar to arrays. List elements can be accessed using


their index (beginning in 0)
e.g.,
x = [”COPA”,”is”,”an”,”excellent”,”course”]
print(x[3])
prints the word excellent.

• append, clear, copy, count, extend, index, insert, pop, remove,


reverse and sort are some of the methods which can be called upon
given list.

• Lists allow duplicate values.

13.17 Tuples in Python


• Tuples in Python are enclosed in ( ) (parantheses).e.g., x = (”COPA”,
”is”, ”an”, ”excellent”, ”course”) is a valid tuple.

• Tuples behave similar to arrays. List elements can be accessed using


their index (beginning in 0)
e.g.,
x = (”COPA”, ”is”, ”an”, ”excellent”, ”course”)

COPA 261 Dr.V.Nagaradjane


print(x[3])
prints the word excellent.
• Although tuples look similar lists, tuples elements cannot be mod-
ified after declaration.
• Tuples allow duplicate values.
• count and index are the two methods which can be called upon
given tuples.

13.18 Dictionaries in Python


• Dictionaries are key value pairs separated by : symbol and enclosed
in { } (curly brackets). e.g., x = { ”trade”:”COPA”, ”name”:”Krish”,
”year”:2022, ”mark”:”100%”} is a valid Dictionary.
• Dictionary does not permit duplicate entries of key values. Newer
values overwrite older values for the same key. e.g. x[”name”]=”Ram”
will change name from Krish to Ram.
• Dictionary elements can be modified after declaration.
• New elements may be added to dictionary after declaration.
• Dictionary does not allow duplicate values.
• clear, copy, fromkeys, get, items, keys, pop, popitem, setdefault,
update, values are the two methods which can be called upon given
sets.

13.19 Arrays in Python


• Arrays in Python are enclosed in [ ] (square brackets).e.g.,
x = [”COPA”, ”is”, ”an”, ”excellent”, ”course”]
is a valid array.
• Arrays and lists share many similarities.
• Array elements can be accessed using their index (beginning in 0)
e.g.,
x = [”COPA”,”is”,”an”,”excellent”,”course”]
print(x[3])
prints the word excellent.

COPA 262 Dr.V.Nagaradjane


• append, clear, copy, count, extend, index, insert, pop, remove,
reverse and sort are some of the methods which can be called upon
given arrays.
• Lists allow duplicate values.

13.20 Iterators in Python


• Iterators help to access all elements of lists, sets, tuples and arrays
sequentially.
• Calling next() method gives the next element of iterator.
• Iterator can be created using iter() method.
e.g.,
x = [”COPA”,”is”,”an”,”excellent”,”course”]
y=iter(x)
print(next(y))
print(next(y))
prints the word COPA followed by is.

13.21 Datetime module in Python


• Datetime module provides date and time classes.
• Date class has three components, viz., year, month and day.
• Date class provides a constructor which takes year, month and day
values.
• Date class provides following functions: ctime, fromisocalendar,
fromisoformat, fromordinal, fromtimestamp, isocalendar, isoformat,
isoweekday, replace, strftime, timetuples, today, toorinal and week-
day.
• strftime may be formatted using %Y, %m, %d, %H, %M %S, etc.
for formatting date and time.

13.22 Math module in Python


• Math module provides several statistical, scientific and trigonomet-
ric functions.

COPA 263 Dr.V.Nagaradjane


• Salient functions in math module are: math.acos, math.acosh,
math.asin, math.asinh, math.atan, math.atanh, math.atan2, math.ceil,
math.comb, math.copysign, math.cos, math.cosh, math.degrees,
math.dist, math.erf, math.erfc, math.exp, math.expm1, math.fabs,
math.factorial, math.floor, math.fmod, math.frexp, math.fsum,
math.gamma, math.gcd, math.hypot, math.isclose, math.isinfinite,
math.isinf, math.isnan, math.isqrt, math.idexp, math.igamma,
math.log, math.log10, math.log1p, math.log2, math.perm, math.pow,
math.prod, math.radians, math.remainder, math.sin,
math.sinh, math.sqrt, math.tan, math.tanh, math.trunc.

• Math class provides the following constants: math.e, math.inf,


math.nan, math.pi, math.tau.

13.23 Input and Output in Python


• Python provides a function called input for collecting input from
the keyboard.

• Output in Python can be provided through print function.

• The following code shows a simple program which collects name of


a person and offers a greeting:
name = input(”Enter your name: ”)
print(”Hello ”+name+”, Have a pleasant day!”)

COPA 264 Dr.V.Nagaradjane


Chapter 14

Java Programming (Optional


2)

Syllabus

Object Oriented Programming with Core Java, Java Programming


features, JVM, Byte codes and Classpath, Java Program Devel-
opment, Compilation and Execution of Java programs, Basic Java
language elements – keywords, comments, data types and variables.
Java Arithmetic, Assignment, Relational, Logical, Increment Decre-
ment operators and expressions. Java String Operators, Java Input
and Output streams: System in, System out. Input using Scanner
class and Console class methods. Decision making and flow con-
trol using if, if ... else, nested if, switch case and the conditional
ternary operators in Java. Loop control flow using while, do –
while loops, for loop, using the break, continue statements. Ter-
minating the Java program. Java Number, Character and String
Classes. Arrays in Java. Java Objects, Classes, Constructors and
Methods - Passing data and objects as parameters to methods.
Method Overloading and Overloaded constructors. Inheritance in
Java, Concept of Virtual methods, Concept of Abstract classes and
methods, Java Interfaces and their advantages, Creating, imple-
menting and extending interfaces, Polymorphism in Java, Creating
and using Packages in Java

265
14.1 Object Oriented Programming with
Core Java
• Object Oriented Programming System (OOPS) is the concept of
building objects with properties and methods to solve programming
problems.

• Objects are created using class keyword.

• Variables inside a class take the name of properties and functions


inside a class assume the name of methods.

• A class is a template or mould, using which several objects can be


created. Hence the name Object Oriented Programming System.

• Java is a purely object oriented language. No single line of code


can be written outside of a class.

• A special method called main written inside a public class having


same name as the file name is the entry point for execution.

14.1.1 Concepts involved in OOPS


• Classes are similar to new data types, which permit declaration of
variables.

• Inheritance: A Class may be extended by a subclass (called child


class). Child class is said to inherit the properties and methods of
parent class.

• Multiple inheritance: A class may have only a single parent class


(called single inheritance). If multiple parents are required, one
may use Interfaces as parents.

• Polymorphism: When same method name appears in parent and


child classes, calling the same method name may result in different
classes to execute the method.

• Virtual classes and virtual functions: Virtual functions and vir-


tual classes override function or classes of the same name in the
parent class.

COPA 266 Dr.V.Nagaradjane


• Static properties and methods: Static properties and methods
are not bound to any instance of object. Static properties and
methods belong to the class itself (and are not bound to any par-
ticular instance of an object).

14.1.2 Concepts involved in OOPS


• Data encapsulation: Providing different levels of access rights to
different methods and properties is called data encapsulation.

• Java provides 3 levels of data encapsulation:

1. public: A class, method or property may be declared public.


It means such a class, method or property is accessible to all
other classes without any restriction.
2. private: A class, method or property may be declared pri-
vate. Private classes, methods or properties are accessible
only inside the particular class.
3. protected: Protected class, method or property is accessible
only inside 2 spaces: (i) inside the declaring class itself, (ii)
inside the child classes.

14.2 Features of Java programs


• Write Once, Run Anywhere (WORA): Java programs follow the
paradigm of Write Once, Run Anywhere. A program written and
compile on one platform runs on any other platform.

• Byte code compilation: Since platforms for programs are differ-


ent, Java compiles the source code into a platform independent
byte code, which is store inside a class file.

• Java Virual Machine (JVM): The byte code is compile for a


hypothetical computer system called Java Virtual Machine (JVM).

• Just-In-Time (JIT) compilation:When the program is executed,


the byte code of the JVM is again subjected to another translation
to create platform dependent executable code. The compilation
just prior to execution is called Just-In-Time (JIT) compilation.

COPA 267 Dr.V.Nagaradjane


• Java Development Kit (JDK): Set of compilation tools (mainly
represented by the command javac) and its dependencies is called
Java Development Kit (JDK). official JDK is is available from the
URL https://www.oracle.com/java/technologies/java-se-glance.html
(It is called Java SE (Standard Edition))

• Java Runtime Environment (JRE): Java Runtime Environment


(JRE) is a virtual computer which executes byte code and interfaces
with real operating system and processor. JRE can provide prudent
optimizations for particular processor and operating system due to
Just-In-Time (JIT) re-compilation of code.

14.2.1 Classpath
• Classpath is an environment variable which sets the file system path
of any Java library required for compiling and running other Java
programs.

• The CLASSPATH variable may have more than one value. On


Windows, each value is separated by semi-colon (;). On Linux and
Mac OS, the values are separated by colon (:).

• To set or edit CLASSPATH on Windows, open Control Panel,


search for environment variables. Open environment variable list
(user and system variables are available).

• Choose New or Edit for CLASSPATH. Append the required file


path.

• To set CLASSPATH on Linux, open issue the command export


CLASSPATH=$CLASSPATH:/yourpath in Terminal. This will
set classpath temporarily for the user.

• To set CLASSPATH for all users on Linux platform, open the file
/etc/prof ile.

• Append the line export CLASSPATH = $CLASSPATH:


yourpath on a convenient line. The CLASSPATH variable will be
set up after a logout and relogin or restart.

14.3 Java Program Development


• Typing source code and compilation: Java programs are to be

COPA 268 Dr.V.Nagaradjane


typed in a text file (called source code file), compiled into byte code
(called class file) using the command javac ¡filename¿.

• Running byte code (class file): The class file containing byte
code may be executed using the command java ByteCodeFile. No
extension (.class) should be added. e.g., to execute a class file
named Hello.class, the command should be java Hello (.class ex-
tension should be omitted).

• Java programs can be typed on a text editor (notepad on Windows,


gedit on Ubuntu Linux).

• After saving the code, open command prompt (cmd on Windows,


Terminal on Linux).

• The source code should be compiled using javac command to get


byte code file.

14.3.1 Welcome program


• A simple Java program to print the message Welcome to Java is
typed using either the command notepad Welcome.java on Win-
dows or gedit Welcome.java on Ubuntu Linux.

• The following code is typed and the document is saved:


import java.lang.*;
public class Welcome
{
public static void main(String arg[]) {
System.out.println(”Welcome to Java!”);
}
}

• The source code file is saved with the name Welcome.java (name
of the public class with letter to letter match).

• The source code is compile using the command javac Welcome.java


and run using the command java Welcome as shown in Fig.14.1

COPA 269 Dr.V.Nagaradjane


Figure 14.1: Compilation and running of Java program

Table 14.1: Keywords in Java


abstract continue for new switch
assert default goto package synchronized
boolean do if private this
break double implements protected throw
byte else import public throws
case enum instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp volatile
const float native super while

14.4 Keywords/ Reserved words in Java


• Keywords or reserved words are the restricted words which have
special meaning to Java language.

• Keywords are not be used for declaration of variables or functions.

• Java reserves about 50 words as keywords. They are presented in


Table 14.1:

14.5 Comments in Java


• Comments in Java are of three types:

COPA 270 Dr.V.Nagaradjane


1. Single line comments: Single line comments start with //
(double forward slash) characters. Any content to the right
side of the comment characters till the end of line is ignored.
2. Multiline comments: Multiline comments begin with /* and
continue over several lines until a */ is encountered.
3. Javadoc comments: Javadoc comments begin with /** and
continue over several lines until a */ is encountered. These
comments help to generate automatic documentation for the
program using javadoc tool.
• The following code shows the use of different types of comment:

import java.lang.*;

public class Welcome


{
public static void main(String arg[]) {
System.out.println("Welcome to Java!");
}
}

14.6 Data types in Java


• Data types in Java are presented in Table 14.2.

14.7 Variable declaration in Java


1. Variables in Java should start with alphabets or character.
2. Numbers may be included in variable name at any location other
than the first.
3. Java variables are case sensitive (int a; and int A; are different
variables).
4. Variable names should not include space. They might have in-
stead.
5. Java follows Camel Back Notation for variable declaration. If a
variable name contains more words than one, each subsequent word
will begin with a capital letter.

COPA 271 Dr.V.Nagaradjane


Table 14.2: Keywords in Java
Sl. Data Memory Value
Sl. type allotted range
1 byte 1 byte -128 to 127
2 short 2 bytes -32,768 to +32,767
3 int 4 bytes -2,147,483,648 to
+2,147,483,647
-
4 long 8 bytes 9,223,372,036,854,775,808
to
+9,223,372,036,854,775,807
5 float 4 bytes 6 to 7 decimal digits
6 double 8 bytes upto 15 decimal digits
7 boolean 1 bit true or false (1 or 0)
8 char 2 bytes One unicode character

6. ageOfPerson, nameOfStudent, balanceOfBankAccount are some of


the variables declared using Camel Back Notation.

7. Camel Back Notation is not mandatory. One may choose to ignore


the notation.

14.8 Operators in Java


14.8.1 Arithmetic operators in Java
Arithmetic operators are shown in Table 14.3.

14.8.2 Assignment operators in Java


Assignment operators are shown in Table 14.4.

14.8.3 Comparison operators in Java


Comparison operators are shown in Table 14.5.

COPA 272 Dr.V.Nagaradjane


Table 14.3: Arithmetic operators in Java
Sl. No. Operator Purpose Usage
1 + Addition z = x + y;
2 − Subtraction z = x − y;
3 ∗ Multiplication z = x ∗ y;
4 / Division z = x/y;
Integer / modulo re-
5 % mainder after divi- z = x%y;
sion
6 ++ Increment by one z = x + +; or
z = + + x;
7 −− Decrement by one z = x − −; or
z = − − x;

14.8.4 Logical operators in Java


Logical operators are shown in Table 14.6.

14.8.5 Bitwise operators in Java


Bitwise operators are shown in Table 14.7.

14.8.6 String operators in Java


String operators are shown in Table 14.8.

14.9 Standard Input - output streams


• Java provides console output through System.out class, which pro-
vides print and println methods.

• Java provides java.util.Scanner class for reading lines of string


and any other data type. java.util.Scanner has nextLine, nextInt,
nextFloat(), nextByte(), nextShort, nextLong,
nextDouble methods to read different data types.

• Following example shows typical use of System.out, System.in and


java.util.Scanner classes.:

COPA 273 Dr.V.Nagaradjane


Table 14.4: Assignment operators in Java
Sl. No. Operator Purpose Usage
Assign right side
1 = value to left side z = x + y
identifier
z=5
2 += Add and assign. z+ = 12
//makes z 17.
z=5
3 −= Substract and assign z− = 12
//makes z −7.
z = 12
4 ∗= Multiply and assign z∗ = 5
//makes z 60.
z = 60
5 /= Divide and assign z/ = 5
//makes z 12.
z = 13
Find remainder and
6 %= z% = 5
assign
//makes z 3
z=5
Bitwise AND and as-
7 &= z& = 4
sign
//makes z 4
z=5
Bitwise OR and as-
8 |= z| = 8
sign
//makes z 13
z=5
= Bitwise XOR and as- =
9 z 7
sign
//makes z 2
z=5
Bitwise Right shift
10 >>= z >>= 2
and assign
//makes z 1
z=5
Bitwise left shift and
11 <<= z <<= 2
assign
// makes z 20

COPA 274 Dr.V.Nagaradjane


Table 14.5: Comparison operators in Java
Sl. No. Operator Purpose Usage
Equal to. Compares
left and right sides.
1 == Returns TRUE only if (x == y)
if both sides are
equal.
Not equal to. Com-
pares left and right
sides. Returns
2 != if (x! = y)
TRUE only if both
sides are NOT
equal.
Greater than. Re-
turns TRUE only if
3 > if (z > 6)
left side is greater
than right side.
Less than. Returns
TRUE only if left
4 < if (z < 6)
side is less than right
side.
Greater than or
equal to. Returns
TRUE only if left
5 >= if (z > 6)
side is greater than
or equal to the right
side.
Less than or equal
to. Returns TRUE
6 <= only if left side is less if (z < 6)
than or equal to the
right side.

COPA 275 Dr.V.Nagaradjane


Table 14.6: Logical operators in Java
Sl. No. Operator Purpose Usage
Returns TRUE
only if both left if(x==y
1 && side and right &&
side expressions y==z)
are TRUE.
Returns TRUE if
if(x!=y
either left side or
2 || ——
right side expres-
y==z)
sion is TRUE.
Returns TRUE
if the right side
3 ! if (!z > 6)
expression is
FALSE.

Table 14.7: Bitwise operators in Java


Sl. No. Operator Purpose Usage
z = 5;
1 & Bitwise AND. z = z&4;
z = 5;
2 | Bitwise OR z = z|8;
z=5;
3 ˆ Bitwise XOR
zˆ7;
z = 5;
4 >> Bitwise Right shift
z >>= 2;
z = 5;
5 << Bitwise left shift k = z << 2;
Bitwise Right shift
z = 5;
6 >>> without reference to
z >>= 2;
sign bit
Bitwise left shift
z=5
7 <<< without reference to
k = z << 2
sign bit

COPA 276 Dr.V.Nagaradjane


Table 14.8: String operators in Java
Sl. No. Operator Purpose Usage
String
x=”Hello ”,
Concatenate two
1 + y=”world!”, z;
strings
z=x+y;
//
Concatenate new String
String and assign x=”Hello ”;
2 +=
result to the original x+=”world!”;
String.

import java.util.*;
public class InputDemo
{
public static void main(String arg[]) {
String name;
int age;
double x, y, z;
Scanner sc = new Scanner(System.in);
System.out.print("Enter your name: ");
name = sc.nextLine();
System.out.print("Enter your age: ");
age = sc.nextInt();
System.out.print("Enter x: ");
x = sc.nextDouble();
System.out.print("Enter y: ");
y = sc.nextDouble();
z = x+y;
System.out.println("Hello "+
name+",\n You are "+age+
" years old!\n"+x+"+"+y+" = "+z);
}
}

COPA 277 Dr.V.Nagaradjane


Figure 14.2: Use of System.out, System.in and java.util.Scanner
classes

[fragile]
Fig. 14.2 shows the how System.out, System.in and
java.util.Scanner classes work.

14.10 Conditions in Java


• Java provides 3 types of condition based evaluation environments:

1. if condition: If condition evaluates given expression and pro-


ceeds to execute the conditional part if the expression is true.
Optionally, the false result may be handled inside an else
block. The else block may be extended through further con-
ditional evaluation using else if blocks.
2. switch ... case condition: Switch case takes an argument
and compares it against several cases. The matching case
block starts execution. Subsequent case blocks are also ex-
ecuted until break statement is found. In case none of the
cases matches the input, default block will be executed.
3. Ternary (?:) operator: A condition with either true or false
result may be executed in a single line using ternary oper-
ator. Look at the following code: int x=16; String mes-
sage=(x¡18?”Not eligible”:”eligible”); printf(”You are ”+mes-
sage+” to vote.”);

14.10.1 If condition
[fragile]

COPA 278 Dr.V.Nagaradjane


Following code shows the use of if condition:

import java.util.Scanner;
public class Age
{
public static void main(String arg[]) {
int age;
Scanner sc = new Scanner(System.in);
System.out.print("Enter your age: ");
age = sc.nextInt();
if(age<5) {
System.out.println(
"You are eligible for Kinder Garten school!");
}
}
}

14.10.2 If ... else condition


[fragile]
Following code shows the use of if condition:

import java.util.Scanner;
public class Age
{
public static void main(String arg[]) {
int age;
Scanner sc = new Scanner(System.in);
System.out.print("Enter your age: ");
age = sc.nextInt();
if(age<5) {
System.out.println(
"You are eligible for Kinder Garten school!");
}
else {
System.out.println(
"You may join a primary or secondary or
higher secondary school!");
}

COPA 279 Dr.V.Nagaradjane


}
}

14.10.3 If ... else if ... else condition


[fragile]
Following code shows the use of if condition:

import java.util.Scanner;
public class Age
{
public static void main(String arg[]) {
int age;
Scanner sc = new Scanner(System.in);
System.out.print("Enter your age: ");
age = sc.nextInt();
if(age<5) {
System.out.println(
"You are eligible for Kinder Garten school!");
}
else if(age<10){
System.out.println(
"You may join a primary school!");
}
else if(age<15) {
System.out.println(
"You may join a Secondary school!");
}
else {
System.out.println(
"You may join a higher secondary school!");
}
}
}

14.10.4 Switch ... case ... default condition


[fragile]
Following code shows the use of switch ... case ... default condition:

COPA 280 Dr.V.Nagaradjane


import java.util.Scanner;
public class Arithmetic
{
public static void main(String arg[]) {
double x, y, z;
int c;
Scanner sc = new Scanner(System.in);
System.out.print("Enter x: ");
x = sc.nextDouble();
System.out.print("Enter y: ");
y = sc.nextDouble();
System.out.print(
"1 - Add\n2 - Subtract\n3 - Multiply\n
4 - Divide\nEnter choice: ");
c = sc.nextInt();
switch(c) {
case 1: z = x+y; System.out.println(z); break;
case 2: z = x-y; System.out.println(z); break;
case 3: z = x*y; System.out.println(z); break;
case 4: z = x/y; System.out.println(z); break;
default: System.out.println("Invalid choice!");
}
}
}

• The switch - case - default program code shown above calculates


results of arithmetic operations.

• Variables x and y hold the inputs. Choice may be made 1, 2, 3 or 4


is to be entered as choice for addition, subtraction, multiplication
or division.

• Switch statement puts variable c to test. The case statements from


1 to 4 make appropriate calculation and display of result.

• Each case statement is ended using a break. Otherwise, if a person


chooses addition, all the remaining (3 other operations) will be
performed.

• Fig.14.3 shows the execution of the above program.

COPA 281 Dr.V.Nagaradjane


Figure 14.3: Execution of switch-case-default program

14.10.5 Ternary operator


[fragile]
Following code shows the use of ternary operator condition:

import java.util.Scanner;
public class Age
{
public static void main(String arg[]) {
int age;
Scanner sc = new Scanner(System.in);
System.out.print("Enter your age: ");
age = sc.nextInt();
String eligibility;
eligibility = age<18? "not eligible":"eligible";
System.out.println("You are "+
eligibility+" to cast your vote!");
}
}
• The ternary code determines eligibility to cast vote based on age.
• The program takes age as an input.
• It uses ternary operator. The first part evaluates the condition
age < 18 followed by a question mark.
• The second part of ternary operator following question mark is
the true part. If the condition is true, the String ”not eligible” is
returned. A colon (:) is placed after second part.
• The third part of ternary operator following colon (:) is the false
part. If the condition is false, the String ”eligible” is returned.
• Fig.14.4 shows the execution of the above program.

COPA 282 Dr.V.Nagaradjane


Figure 14.4: Execution of ternary operator program

14.11 Loops in Java


• Loops carry out repeated execution of a code block.

• Java provides 3 types of loops:

1. while loop: While loops checks a condition. If the condition


is true, the code block following while statement is executed.
while(condition) {
...
}
is a typical while loop.
2. do ... while loop: Do while loop allows the loop block to
freely execute during the first run. At the end of the loop
block, a condition portion in while statement allows or stops
further cycles of execution.
do {
...
} while(condition);
is a typical do-while loop.
3. for loop: for loop has three parts separated by two semi-
colons. First part is for initializatio, second part checks con-
dition and the third part is for increment or decrement of
variable.
for(int i=0;i<10;i++) {
...
}
is a typical for loop.

• The continue statement makes the loop to proceed to the next


cycle without executing the subsequent statements of the loop.

• The break statement ends looping and transfers control to the next
code block.

COPA 283 Dr.V.Nagaradjane


Figure 14.5: Execution of while loop program

14.11.1 While loop


[fragile]
Following code shows the use of while loop for reversing given integer:

import java.util.Scanner;
public class Reverse
{
public static void main(String arg[]) {
long num, n, rev=0;
Scanner sc = new Scanner(System.in);
System.out.print("Enter any large integer: ");
n = num = sc.nextLong();
while(num > 0) {
rev = (rev*10)+(num%10);
num = (int)((num-(num%10))/10);
}
System.out.println("Reverse of "+n+" is "+rev);
}
}

• The while loop program shows the logic for reversing given integer.

• Variables n and num take the input.

• While loop checks whether num is zero. If not, the last digit is
taken out using by taking modulo remainder by 10. The last digit
is added to the result variable after multiplying it by 10.

• New value of num is calulated by removing the right most digit.

• Fig.14.5 shows the execution of the above program.

COPA 284 Dr.V.Nagaradjane


14.11.2 Do - while loop
Following code shows the use of Do ... while loop for repeated calcualtion
of arithmetic results:

import java.util.Scanner;

public class DoWhile


{
public static void main(String arg[]) {
double x, y, z;
int c;
char opt;
Scanner sc = new Scanner(System.in);
do {
System.out.print("Enter x: ");
x = sc.nextDouble();
System.out.print("Enter y: ");
y = sc.nextDouble();
System.out.print(
"1 - Add\n2 - Subtract\n3 - Multiply\n
4 - Divide\nEnter choice: ");
c = sc.nextInt();
switch(c) {
case 1: z = x+y;
System.out.println(z);
break;
case 2: z = x-y;
System.out.println(z);
break;
case 3: z = x*y;
System.out.println(z);
break;
case 4: z = x/y;
System.out.println(z);
break;
default: System.out.println(
"Invalid choice!");
}
System.out.print(
"Do you wish to continue (y/n): ");

COPA 285 Dr.V.Nagaradjane


Figure 14.6: Execution of do - while loop program

opt = sc.next().charAt(0);
} while(opt==’y’ || opt == ’Y’);
}
}

• The do while loop program simply keeps on calculating sum, dif-


ference, product or division so long as the continue option is y or
Y.

• Since the variable opt is checked at the end of the loop, the loop
runs at least once.

• Fig.14.6 shows the execution of the above program.

14.11.3 For loop


Following code shows the use of for loop to calculate factorial of given
number:

import java.util.Scanner;
public class Fact
{
public static void main(String arg[]) {
long fact=1;
int n;

COPA 286 Dr.V.Nagaradjane


Figure 14.7: Execution of for loop program

Scanner sc = new Scanner(System.in);


System.out.print(
"Enter number to get factorial: ");
n = sc.nextInt();
for(int i=1;i<=n;i++) {
fact *= i;
}
System.out.println("Factorial of "+n+" is "+fact);
}
}

• The for loop program takes an integer input and calcualtes its fac-
torial.

• Variable named factorial is declared with initial value of 1.

• First part of the for loop declares variable i and intializes it to 1


(int i=1;). A semi-colon ends the first part.

• The second part of the for loop checks whether the value of i is less
than or equal to the given input number (i <= n;). A semi-colon
ends the second part.

• Third part of the for loop increments the variable i by 1 after each
cycle (i + +).

• Fig.14.7 shows the execution of the above program.

14.12 Number and Character class


• Number class is the superclass of Byte, Integer, Long, Float, Dou-
ble, BigInteger and BigDecimal classes.

• It is an abstract class, which means some methods are declared but


not implemented (to be implemented by the child class).

COPA 287 Dr.V.Nagaradjane


• Number class as such cannot be used for creating objects. Its
subclasses are used.

• This class has abstract methods called byteValue, intValue, long-


Value, floatValue and doubleValue.

• Character class is the wrapper class for char data type (which is
primitive) in Java.

• Character class may take a char as the argument of its constructor.

• Character class supports isLetter, isDigit, isWhitespace, isUpper-


Case, isLowerCase, toUpperCase, toUpperCase and toString.

14.13 String class


• String class holds a series of characters.

• Strings can be concated using + operator. Concatenated string


may be assigned to the original String itself using += operator.

• String class has the following methods: concat, contains, contentE-


quals, copyValueOf, endsWith, equals, equalsIgnoreCase, format,
getBytes, getChars, hashCode, indexOf, intern, isEmpty, lastIn-
dexOf, length, matches, offsetByCodePoints, regionMatch, replace,
replaceFirst, repalceAll, split, startsWith, subSequence, substring,
toCharArray, toLowerCase, toString, toUpperCase, valueOf.

14.14 Arrays in Java


• Arrays are declared using the [] notation in Java. e.g., int[] mark
= 90,93,100,98,92;

• Array elements are indexed from 0. In the mark array declared


above, mark[2] is 100.

• Number of elements in an array may be obtained using length prop-


erty of array.

Following code shows the use of arrays in Java:

COPA 288 Dr.V.Nagaradjane


import java.util.Scanner;

public class Mark


{
public static void main(String arg[]) {
int mark[] = new int[5];
int total=0;
String sub[] = {"Lang-1","Lang-2",
"Maths","Science","Social"};
Scanner sc = new Scanner(System.in);
for(int i=0; i<mark.length; i++) {
System.out.print("Enter mark in "+
sub[i]+ ": ");
mark[i] = sc.nextInt();
}

System.out.println(
"Statement of Marks\nSubject\tMark");
for(int i=0; i<mark.length; i++) {
System.out.println(sub[i]+"\t"+mark[i]);
total += mark[i];
}
System.out.println("Total\t"+total);
}
}

• The Mark class declares two arrays.

• An integer array called mark is created without intial values (int


mark[] = new int[5];). A String array called sub is created with 5
initial values.

• The first for loop obtains marks for all 5 subjects. Second for loop
displays them.

• The second for loop calculates total mark and displays the same
after exiting the for loop.

• Fig.14.8 shows execution of mark program.

COPA 289 Dr.V.Nagaradjane


Figure 14.8: Mark program using array

14.15 Working with objects, methods and


properties
• Classes are created as a programming representation of real world
objects.
• Properties and methods of class: Classes have properties (vari-
ables) and methods (functions) encapsulated through access spec-
ifiers (public, protected or private).
• Let us consider paper (the ordinary paper used by us) as a class.
• It may have properties called colour, size and price.
• Paper class may have a constructor with initial values for all the 3
properties or less.
• Paper class may have methods for printing and writing.
• Programmer’s imagination and the needs of the problem are the
factors which influence the number of properties and methdods in
a class.
• Constructor overloading If a class has more than one constructor,
it is called constructor overloading. Overloaded constructors share
the same name but take different arguments.
• method overloading: If a class has got more than one method
with the same name, the arguments should be different. Such
methodd with same name but different arguments are called over-
loaded methods.

COPA 290 Dr.V.Nagaradjane


14.15.1 Class, constructor, properties and meth-
ods
The code for implementing Paper class is shown below:

public class Paper


{
protected String size, colour;
protected double price;

public Paper() { //constructor


size = "a4";
colour = "white";
price = 0.45;
}
public Paper(double p) { //constructor
size = "a4";
colour = "white";
price = p;
}
public Paper(String size, String colour,
double price) {
this.size = size;
this.colour = colour;
this.price = price;
}

public String write() {


return "Something is being written on me.";
}
public String write(String s) {
//write method is overloaded
return s+" is being written on me.";
}
public String print() {
return "Something is being printed on me!";
}

public void setColour(String c) {


//setting properties

COPA 291 Dr.V.Nagaradjane


colour = c;
}
public void setSize(String s) {
size = s;
}
public void setPrice(double p) {
//setting price
price = p;
}
public double getPrice() {
// getting price
return price;
}
public String toString() {
return size+ " size paper having "+
colour+" colour and costing "+price;
}
public static void main(String []arg) {
Paper p1 = new Paper(), p2 = new Paper(0.41),
p3 = new Paper("a5","red",0.24);
p1.setColour("blue");
p1.setSize("a4");
p1.setPrice(0.46);
p2.setColour("green");
System.out.println(p1.toString());
System.out.println(p1.write());
System.out.println(p2.toString());
System.out.println(p2.print());
System.out.println(p3.toString());
System.out.println(p3.write("Lesson"));
}
}

• The paper class has 3 constructors (called constructor overload-


ing) with different arguments.

• Normally, set and get methods are used to modify and read prop-
erties. This convention helps in the development of Java beans.

• The method named write is overloaded with 2 different sets of


arguments (called method overloading).

COPA 292 Dr.V.Nagaradjane


Figure 14.9: Paper class

• In order to execute the class, main method is declared. It is a


public method with static property (which can be called without
instantiating any object).

• Fig.14.9 shows execution of paper class program.

14.16 Inheritance
• Inheritance is the bestowal of parent class properties and methods
(other than those which are private) on a child class.

• Paper class may be used as the parent for child classes named book,
notebook, newspaper, etc.

• We may think of implementing child class named book.

• In addition to inheriting the properties of Paper class, print method


and toString method will be overridden to create virtual methods.

• Following code shows implementation of Book class.

14.16.1 Book class


The code for implementing Book class is shown below:

public class Book extends Paper


{
protected String title, author;
public Book(String title, String author, double price) {
super(price);
this.title = title;
this.author = author;

COPA 293 Dr.V.Nagaradjane


this.size = "a5";
this.colour = "white";
}
public String print() {
//virtual method. It is overridden in the child class
return "Although I was a paper, "+
"I have been converted into a book!";
}
public String toString() {
//virtual method. It is overridden in the child class
return "I am a book. My title is \’"+
title+"\’. My cost is "+price;
}
public static void main(String arg[]) {
Paper p1 = new Paper(),
b1 = new Book("All is well that ends well",
"William Shakespear", 240.5);
System.out.println("Paper says: "+
p1.toString()+". "+p1.print());
System.out.println("Book says: "+
b1.toString()+". "+b1.print());
}
}

• The Book class declares Paper class as its parent using the extends
keyword.
• Book class has one constructor which takes title, author and price.
The first line of the book constructor calls constructor of its paprent
class using super() method.
• The methods print and toString have been overridden in the Book
class. They become virtual methods inside the child class, since
they behave differently for invocation on Paper class and Book
class.
• Fig.14.10 shows execution of Book class program.

14.17 Abstract class in Java


• Abstract class is an unfinished class in which one or more methods
are simply declared without offering implementation.

COPA 294 Dr.V.Nagaradjane


Figure 14.10: Book class

• Abstract class permits regular methods and abstract methods.

• Abstract class is an unfinished class. Hence, instances cannot be


declared for an abstract class.

• Subclasses of an abstract class may implement the abstract meth-


ods and become normal classes.

• An abstract subclass of book class may be created by declaring an


abstract method typeOfFinishing().

14.17.1 FinishedBook - abstract class


The code for implementing FinishedBook as an abstract class is shown
below:

public abstract class FinishedBook extends Book


{
public FinishedBook(String t, String a, double p) {
super(t,a,p);
}
public abstract String getFinishingType();
}

The above code is insufficient to create a regular class. Hence, a class


named BoundBook is created (try to create PaperBackBook by yourself)
as follows:

14.17.2 BoundBook extends FinishedBook class


BoundBook class extends FinishedBook class and implements getFinish-
ingType() method, thus graduating to a full fledged class:

COPA 295 Dr.V.Nagaradjane


Figure 14.11: Execution of BoundBook class

public class BoundBook extends FinishedBook


{
public BoundBook(String t, String a, double p) {
super(t,a,p);
}
public String getFinishingType() {
return "I am a bound book.";
}
public static void main(String arg[]) {
BoundBook b = new BoundBook(
"The Comedy of Errors",
"William Shakespear",350);
System.out.println("BoundBook says: "+
b.toString()+". "+b.getFinishingType());
}
}

• Fig.14.11 shows execution of BoundBook class.

14.18 Interfaces in Java


• Interfaces are special type classes in which methods are simply de-
clared without implementation.

• If any class wishes to be a member of an interface, it should either


implement all the methods declared inside the parent interface or
declare some of them abstract.

• Interface is a generic template which ensures that certain methods


are found in its child class.

• Interfaces cannot be used to instantiate objects.

• We may define an interface named Student with member functions


study, appearInExam, attendConvocation.

COPA 296 Dr.V.Nagaradjane


• Classes called ITIStudent, PolytechnicStudent and CollegeStudent
may be created by implementing the interface Student.

• A Java class may extend only one parent class but may implement
many interfaces.

14.18.1 Student Interface


An inteface called Student, 3 classes called ITIStudent, PolytechnicStu-
dent and CollegeStudent implementing the Student interface and a public
class called InterfaceDemo are created as shown in the following code:

interface Student
{
public String study();
public String appearInExam();
public String attendConvocation();
}

class ITIStudent implements Student


{
public String study() {
return "I am preparing as per DGT Syllabus.";
}
public String appearInExam() {
return "I am appearing in All India Trade Test.";
}
public String attendConvocation() {
return "I get National Trade Certificate.";
}
}

class PolytechnicStudent implements Student


{
public String study() {
return "I am preparing as per "+
"Board of Techical Education Syllabus.";}
public String appearInExam() {
return "I am appearing in "+
"Technical Education Board exam.";

COPA 297 Dr.V.Nagaradjane


}
public String attendConvocation() {
return "I get Diploma Certificate.";
}
}

class CollegeStudent implements Student


{
public String study() {
return "I am preparing as per University Syllabus.";
}
public String appearInExam() {
return "I am appearing in University exam.";
}
public String attendConvocation() {
return "I get Under Graduate/ " +
"Post Graduate Certificate.";
}
}

public class InterfaceDemo


{
public static void main(String arg[]) {
Student i = new ITIStudent(),
p = new PolytechnicStudent(),
c = new CollegeStudent();
System.out.println("ITI Student says: "+
i.study()+" "+i.appearInExam()+" "+
i.attendConvocation());
System.out.println("Polytechnic Student says: "+
p.study()+" "+p.appearInExam()+" "+
p.attendConvocation());
System.out.println("College Student says: "+
c.study()+" "+c.appearInExam()+" "+
c.attendConvocation());
}
}

• Fig.14.12 shows execution of classes implementing Student inter-


face.

COPA 298 Dr.V.Nagaradjane


Figure 14.12: Execution of classes implementing Student interface

14.19 Polymorphism in Java


• Polymorphism is the behaviour of a function with the same name
in different ways.

• Just as a single person displays different characteristics at differ-


ent places, polymorphism permits different behaviour for function
having the same name.

• Functions having same name but different argument implement


polymorphism determined at compile time.

• Overriding functions of parent and subclasses having same name


and same arguments are executed at runtime by the JVM. This is
also called dynamic binding or late binding of functions.

• We may think of creating a class called Rectangle with overloaded


methods named getArea (with one or two arguments). These to
overloaded methods (getArea) will be bound at compile time, called
static binding.

• We may extend Rectangle class in Oval class and override the above
two getArea methods. These 2 virtual methods will be bound at
runtime, called dynimically binding.

14.19.1 Polymorphism - Rectangle and Oval classes


Rectangle and Oval class calculate areas based on breadth and length or
double major axis and double minor axis.:

class Rectangle
{
public double getArea(double x, double y) {
return x*y;

COPA 299 Dr.V.Nagaradjane


}
public double getArea(double x) {
return x*x;
}
}

class Oval extends Rectangle


{
public double getArea(double x, double y) {
return Math.PI*x*y/4;
}
public double getArea(double x) {
return Math.PI*x*x/4;
}
}

public class Poly


{
public static void main(String arg[]) {
Rectangle r = new Rectangle(), o = new Oval();
System.out.println("For Sides 3,4:"+
" area of rectangle "+
r.getArea(3,4)+" area of oval: "+o.getArea(3,4));
System.out.println("For Side 3: "+
"area of square "+
r.getArea(3)+" area of circle: "+o.getArea(3));
}
}
• Fig.14.13 shows execution of classes implementing Rectangle and
Oval.
• The Rectangle results are compile time polymorphism results (those
invoked on variable r).
• The Oval class getArea results are run time polymorphism results
or dynamic binding results or late binding results.

14.20 Packages in Java


• Packags are Java class files organized inside folders.

COPA 300 Dr.V.Nagaradjane


Figure 14.13: Polymorphism in Java

• While referring to classes inside folders, the folder path and class
are separated by dot (.) symbol.

• All Java source code files in a package begin with the keyword
package. It is followed by the folder path and semi-colon.

• Public classes declared inside packages can be accessed from other


packages.

• Packages can be converted to jar files (using jar command) and


may be distributed as reusable libraries.

• We could create packages called org.copa and place Rectangle and


Oval classes inside of that packages.

• We may refer the packages in Pack.java and get the same results.

• Packages are very useful for developers of new libraries.

14.20.1 Package org.copa


• Create folder org. Then create folder copa inside org.

• On Windows, issue the command md org, followed by md org


copa.

• On Linux or Mac, issue the command mkdir org, followed by mkdir


org/copa.

• Edit Rectangle class inside the the folder org.copa, using either
notepad org\copa\Rectangle.java or
gedit org/copa/Rectangle.java or
vim org/copa/Rectangle.java.

• Type the following content:

COPA 301 Dr.V.Nagaradjane


package org.copa;

public class Rectangle


{
public double getArea(double x, double y) {
return x*y;
}
public double getArea(double x) {
return x*x;
}
}

• Edit Oval class inside the the folder org.copa, using either notepad
org\copa\Oval.java or
gedit org/copa/Oval.java or
vim org/copa/Oval.java.

• Type the following content:

package org.copa;

public class Oval extends Rectangle


{
public double getArea(double x, double y) {
return Math.PI*x*y/4;
}
public double getArea(double x) {
return Math.PI*x*x/4;
}
}

14.20.2 Accessing the package org.copa


• The following class file named Pack.java imports both
org.copa.Rectangle and org.copa.Oval and runs the getArea meth-
ods.

import org.copa.Rectangle;
import org.copa.Oval;

public class Pack

COPA 302 Dr.V.Nagaradjane


Figure 14.14: Packages in Java

{
public static void main(String arg[]) {
Rectangle r = new Rectangle(), o = new Oval();
System.out.println(
"For Sides 3,4: area of rectangle "+
r.getArea(3,4)+" area of oval: "+o.getArea(3,4));
System.out.println(
"For Side 3: area of square "+
r.getArea(3)+" area of circle: "+o.getArea(3));
}
}

• The Rectangle results are compile time polymorphism results (those


invoked on variable r).

• The Oval class getArea results are run time polymorphism results
or dynamic binding results or late binding results.

• The above package can be converted to a Java ARchive (jar) file


using the command jar cf shape.jar org. If shape.jar is included
in classpath, the classes org.copa.Rectangle and org.copa.Oval be-
come available to other programmers.

• Fig.14.14 shows execution of classes implementing Rectangle and


Oval accessed from package named org.copa.

COPA 303 Dr.V.Nagaradjane


COPA 304 Dr.V.Nagaradjane
References

[1] https://www.wikihow.com/Maintain-Lab-Computers

[2] https://oakdome.com/k5/computer-lab-rules/

[3] https://in.pinterest.com/pin/ 48554502225799381/?nic v3=


1a5RdrJAX

[4] https://www.tutorialsmate.com/2022/01/components-of-
computer.html

[5] https://blogs.windows.com/ windowsexperience/ 2021/06/24/


introducing-windows-11/

[6] https://www.plus2net.com/php tutorial/pdf-data-student.php

[7] https://oracletutes.com/rdbms-relational-database-management-
system/

[8] https://www.javatpoint.com/data-models

[9] https://www.supraits.com/oracle-practice/ oracle-application-


services/dba-services/

[10] https://www.tutorialspoint.com/ bdbms/ dbms data schemas.htm

[11] https://www.javatpoint.com/mysql-join

[12] https://support.microsoft.com/en-us/office/lookup-function-
446d94af-663b-451d-8251-369d5e3864cb

[13] https://en.wikipedia.org/wiki/ Python programming language

[14] https://www.excelcampus.com/charts/10-advanced-charts/

[15] https://support.microsoft.com/en-us/office/about-power-query-
in-excel-7104fbee-9e62-4cb9-a02e-5bfb1a6c536a

305
[16] https://en.wikipedia.org/wiki/Solid-state drive

[17] https://news.samsung.com/global/samsung-electronics-unveils-
high-performance-990-pro-ssd-optimized-for-gaming-and-creative-
applications

[18] https://www.ifsecglobal.com/global/choose-right-type-fire-
extinguisher/

[19] https://en.wikipedia.org/wiki/History of computing hardware.

[20] http://www.tutorialspoint.com/ com-


puter fundamentals/computer second generation.htm

[21] http://www.tutorialspoint.com/ com-


puter fundamentals/computer third generation.htm

[22] http://www.tutorialspoint.com/ com-


puter fundamentals/computer fourth generation.htm

[23] http://www.tutorialspoint.com/ computer


fundamentals/computer fifth generation.htm

[24] http://www.tutorialspoint.com/ com-


puter fundamentals/computer types.htm

[25] http://bene.com/pics/office-furniture/workplaces/t-
workstation/t-workstation-03.jpg

[26] http://www.apple.com/shop/buy-ipad/ipad-air-2

[27] https://pixabay.com/en/photos/laptop/

[28] http://www.samsung.com/us/explore/galaxy-s7-features-and-
specs/

[29] https://www.raspberrypi.org/blog/raspberry-pi-2-on-sale/

[30] https://en.wikipedia.org/wiki/Cloud computing#/ me-


dia/File:Cloud computing.svg

[31] https://blog.hostonnet.com/wp-content/
uploads/2014/08/Keyboard-White-on-Black.jpg

[32] http://llg.cubic.org/docs/mouse.jpg

COPA 306 Dr.V.Nagaradjane


[33] https://upload.wikimedia.org/wikipedia/ com-
mons/e/e3/Scanner.view.750pix.jpg
[34] http://cdn.makeuseof.com/wp-content/ up-
loads/2012/03/bambooconnect.png?b34c28
[35] https://upload.wikimedia.org/wikipedia/commons/c/cd/ Hyper-
textEditingSystemConsoleBrownUniv1969.jpg
[36] https://mrcenet.files.wordpress.com/ 2011/12/ color monitor.jpg
[37] http://static2.shop.indiatimes.com/ images/products/additional/
original/B948722 View 1/ computers/ lcd-tft/ dell-tft-23-inch-
monitor-s2330mx.jpg
[38] http://images17.newegg.com/is/image/newegg/24-112-024-
TS?$S300$
[39] http://us.aoc.com/images/monitors/E2476VWM6/
large/E2476VWM6-front.png
[40] http://n3.sdlcdn.com/imgs/a/o/a/TVS-Electronics-MSP-430-
Printer-SDL209857912-1-7176b.jpg
[41] http://s7.computerhistory.org/is/image/CHM/102630084p-03-
01?$re-zoomed$
[42] http://common.ziffdavisinternet.com/ encyclopedia images/
CHAINPTR.GIF
[43] https://upload.wikimedia.org/ wikipedia/commons/5/52/IBM
Selectric typeball.jpg
[44] http://www.jeffdwoskin.com/ printers/img/ charac-
ter/daisywheel.jpg
[45] http://static.electronicsweekly.com/news/wp-
content/uploads/sites/16/2015/04/01apr15LumeJet-v-Inkjet.jpg
[46] http://www.explainthatstuff.com/laserprinters.html
[47] http://www.solopress.com/blog/wp-
content/uploads/2013/03/direct-thermal-printing-graphic.jpg
[48] http://cdn2.hubspot.net/hub/108303/file-16282842-
jpg/images/c–users-stef-documents-front burner-front burner-
great lakes blog-plotter print-resized-600.jpg

COPA 307 Dr.V.Nagaradjane


[49] http://images.pcworld.com/news/graphics/146957-8086-
chip b.jpg

[50] http://www.us-trading-center.com/ assets/img/ recycling/cpus/


386-486Individual.jpg

[51] http://www.activewin.com/reviews/hardware/processors/intel/-
p422ghz/designsse.shtml

[52] http://www.pcstats.com/articleimages/200703/c2de6600 frntrear.jpg

[53] http://innoreviews.com/wp-content/uploads/2016/03/I3-
3220.jpg

[54] http://innoreviews.com/wp-content/uploads/2016/03/I3-
3220.jpg

[55] http://techgage.com/wp-content/uploads/2013/12/Intel-Core-i7-
Haswell-500x362.jpg

[56] http://www.amd.com/PublishingImages/ photography/product/


360px/amd-opteron-4000.png

[57] http://ebay.18004memory.com/ ebaypics/SDRAM/PC133/


DIMM/232A-OX1.gif

[58] https://upload.wikimedia.org/wikipedia/en/thumb/d/d3/
Samsung displays first DDR4 module.jpg/300px- Sam-
sung displays first DDR4 module.jpg

[59] http://www.informationq.com/wp-content/uploads/2012/
10/computer-Motherboard.jpg

[60] http://s.hswstatic.com/gif/ adding-a-hard-disk-1-1.jpg

[61] http://www.zeppelincomputers.com/data/ products/


id1162/web toshcombodvdcdrw.jpg

[62] https://upload.wikimedia.org/wikipedia/ com-


mons/7/7e/Floppy disk 300 dpi.jpg

[63] https://images-eu.ssl-images-amazon.com/ im-


ages/I/41pS7kV8G2L.jpg

[64] https://napa.i.lithium.com/t5/image/serverpage/ image-


id/30360i84422B7A2F74F977?v=v2

COPA 308 Dr.V.Nagaradjane


[65] http://ecx.images-amazon.com/images/I/ 41Yh-ta6tUL.jpg
[66] http://stevensoncaitlin.typepad.com/
.a/6a015434c258c3970c0162fd2f56bb970d-pi
[67] https://en.wikipedia.org/wiki/OS X#/ media/File:OS X
El Capitan screenshot.png
[68] https://en.wikipedia.org/wiki/Windows 10#/ me-
dia/File:Windows 10 build 14393 (Redstone).png
[69] https://en.wikipedia.org/wiki/Windows 10 Mobile# /me-
dia/File:Windows 10 Mobile homescreen.png
[70]
[71] http://allthingsd.com/files/2012/09/FXOS IconGrid.jpg
[72] https://upload.wikimedia.org/wikipedia/commons/a/ a1/ Ti-
zen screenshot en original.png
[73] https://technet.microsoft.com/en-us/library/cc940018.aspx
[74] http://networking.layer-x.com/p020000-1.html
[75] http://computernetworkingsimplified.in/physical-layer/typical-
hardware-components-physical-layer-2/
[76] https://btsadvancedcommunications. files.wordpress.com/
2011/11/stputp.jpg
[77] https://fcit.usf.edu/network/chap4/pics/coaxial.gif
[78] https://fcit.usf.edu/network/chap4/pics/fiberop.gif
[79] https://www.techpluto.com/wp-content/uploads/2009/10/tutorial-
osi-7-layer-model.gif
[80] http://cdn.ttgtmedia.com/rms/onlineImages/networking-
osi vs tcp-ip model table desktop.jpg
[81] https://www.ibm.com/docs/en/zos-basic-skills?topic=zos-
application-development-life-cycle-overview
[82] https://www.w3schools.com/js/js htmldom.asp
[83] https://www.javatpoint.com/document-object-model
[84] https://en.wikipedia.org/wiki/Visual Basic for Applications

COPA 309 Dr.V.Nagaradjane


Index

Abstract, 265, 294, 295 OOPS, 203, 204

cat, 56 Polymorphism, 265, 299, 301


Chart, 112, 223, 224 Powerpoint, 60, 110
Processor, 6, 8
Date, 83, 84, 112, 131, 179, 205,
208, 263 Query, 118, 120, 124, 132
DIR, 45
DOS, 27, 43–46 RAM, 5, 9, 11, 37, 41

Software, 26, 105, 238, 244


Excel, 43, 60, 65, 75, 79, 80, 100,
Switch, 8, 16, 25, 42, 149, 193,
101, 122, 217, 218, 221–
278, 280, 281
225
Ternary, 195, 278, 282
Hardware, 6, 7, 41
Word, 43, 59–62, 71–74, 76, 80,
Inheritance, 265, 293
112
Interface, 27, 32, 296

Java, 182, 265–271, 273, 278, 283,


292, 297, 300, 301, 303

Linux, 28, 32, 49, 50, 54, 55, 58,


122, 182, 268, 301
Loop, 265

Math, 83, 90, 179, 205, 209, 263,


264
mysql, 126, 133

Object, 112, 118, 121, 179, 183–


185, 203, 211, 212, 214,
248, 265, 266
Office, 43, 49, 52, 60–62, 103, 109,
110, 153, 157

310

You might also like