Informatics Practices XII
Informatics Practices XII
Informatics Practices XII
Class XII
INFORMATICS PRACTICES
Session 2016-17
(i)
INFORMATICS PRACTICES
(ii)
INFORMATICS PRACTICES
FOREWORD
U.N. Khaware
Additional Commissioner (Acad.)
(iii)
INFORMATICS PRACTICES
Shri Santosh Kumar Mall, IAS, Commissioner, KVS (HQ) New Delhi
Mr. P.V. Sai Ranga Rao, Deputy Commissioner (Acad), KVS (HQ)
CONTENT TEAM
Mr. Madan Mohan, PGT (Comp. Sc.), KV Sector 5, Dwarka, New Delhi
REVIEW TEAM
(iv)
TABLE OF CONTENTS
UNIT /CHAPTERS PAGE NO.
Unit-1: Networking and Open Standards 4-15
Unit-2 : Programming(Java IDE NetBeans ) 16-52
Unit-3 : Relational Database Management Systems 53-70
Unit-4 : IT Applications 71-73
CBSE Previous Year Paper 74-101
MARKS DISTRIBUTION
S.NO. TOPIC/UNIT MARKS
1 Networking & Open Software Standard 10
2 Java Programming 25
3 RDBMS (MYSQL) 30
4 IT Application 05
Total 70
BLUE PRINT
QUESTION PAPER DESIGN AS PER CBSE
Very
Short Short Short Long
Total
Typology of Answer Answer Answer Answer %
S.No. Marks
Question (VSA) (SA) (SA) (LA) Weightage
(1 (2 Marks) (4 Marks) 6 Marks
Mark)
Knowledge
1 4 3 2 --- 18 26
Based
Conceptual
2 4 5 1 --- 18 26
Understanding
3 Reasoning 4 --- 2 1 18 26
1
IMPORTANT ABBREVIATIONS USED IN IP
2
UNIT- 1 (NETWORKING AND OPEN STANDARDS)
CHAPTER- 1: COMPUTER NETWORKING
MIND MAP COMPUTER NETWORKING
3
CHAPTER- 1: COMPUTER NETWORKING
Network: A computer network is a collection of interconnected computers. Two computers are
said to be interconnected if they are capable of sharing hardware, software and exchanging
information.
Need or advantages for Networking :
1. Resource sharing
2. Reliability
3. Cost factor
4. Communication medium.
5. Central Storage of data
Application of Network:
1. Sharing
2. Access to remote database
3. Communication facilities
Terminology of Network:
Nodes: Nodes refer to the computers that are attached to a network that can share resources of
the network.
Server: A computer that facilitates the sharing of data, hardware and software on the network is
known as server. Each server has unique name on the network. A server can be of two types:
(i) Dedicated server (ii) Non dedicated server
Domain Name Vs URL: Domain name is unique name assigned to a web site. The URL is the
complete address of web page on the website. e. g. URL: http:// www.cbse.nic.in/index.html Here
http is protocol and www.cbse.nic.in is domain name.
Domain Name Resolution: Domain Name resolution is the process of getting corresponding IP
address from a domain name.
Network Interface Unit (NIU): A network interface unit is an interpreter that helps to establish a
communication between the server and the client.
MAC Address: It refers to the physical address assigned by the NIC manufacturer. A MAC address is
a 6 byte address with each byte separated by a colon. For Example: 20:B5:03:63:2E: FC (The first
three bytes refer to manufacturer ID and last three card no.)
IP address: Every machine on a TCP/IP network has a unique identifying number, called IP address:
For Example: 202.27.94.137 (also known as Internet Protocol address)
Transmission/ Communication Media
The communication channels which are used for actual physical transmission of data are known
as transmission media. The transmission media is of two types: wired and wireless.
Wired Media (Guided Media):
It consists of physical wired medium to carry signals.
Twisted pair cable: A twisted pair cable consists of minimum two insulated copper wires of
about 1 mm thickness which are twisted together in a helical form. e.g. Telephone wire. LAN
Cable.
Advantages:
1. It is easy to install and maintain
2. It is very cheap (Inexpensive)
4
Disadvantages:
1. It is not efficient in transmitting data for very long distance without a repeater.
2. Low bandwidth.
Co-Axial Cable: It is a stiff copper wire, surrounded by insulating material. E.g. cable TV wire
Advantages: 1. High band width (data transmission is better than twisted pair cable)
2. Can be used for transmitting data over long distance.
Disadvantages:
1. Expensive than twisted pair cable
2. It is not compatible with Twister pair cable.
Optical Fiber: Optical fiber cables are made up of a glass core through which data is
transmitted in the form of light signals.
Advantages:
1. Transmit data over long distance with security and high bandwidth.
2. Immune to noise/external interference.
Disadvantages:
1. Very expensive and quite fragile (breakable).
2. Connecting two optical fibers is a difficult process.
Wireless Media (Unguided Media)
It consists of electromagnetic waves which carry signals
a) Blue Tooth: Bluetooth is a wireless technology for creating personal networks operating
within a range of 10 meters.
b) Infrared: The type of transmission that uses infrared light to send the data is known as
infrared transmission. e.g.: Remote control of TV and AC.
Advantages:
1. It is a secure medium of transmitting data.
2. It is a cheap mode of transmission.
Disadvantages:
1. It can work for short distance.
2. It cannot go through walls and affected by distance, noise and heat.
c) Microwave: Microwaves are high energy radio waves that are used for line of sight
communication.
Advantages:
1. Suitable for high speed, long distance and overseas communication.
2. No need for laying cable.
Disadvantages:
1. Micro wave communication is an insecure communication.
2. Microwave propagation of waves is susceptible to weather effects like Rain, thunder
etc.
3. Only straight line transmission is possible.
d) Radio wave/Radio Link
The transmission making use of radio frequencies is termed as radio wave transmission.
Advantages:
1. It is suitable for long distance and can be used for indoors and outdoors.
2. Radio waves can travel in any direction (omnidirectional).
5
Disadvantages:
1. Radio waves communication is insecure communication.
2. Radio waves propagation is susceptible to weather effects like rain, thunderstorm.
e) Satellite Link: The satellite transmission is also a kind of line of sight transmission that is
used to transmit signals throughout the world. Services like DTH cable TV, VSAT, GPS and
Satellite phones etc. are offered by the satellite.
Advantages:
1. It can cover large area of earth.
2. Satellite proves best alternate where the laying out of cable is difficult and
expensive.
Disadvantages:
1. High cost (very expensive) and complex Installation.
2. Signals sent to the earth can be tampered by external interference.
Network devices
Modem: MOdulator-DEModulator is a device that connects telephone line to computer. It
converts digital signal to analog signal and vice versa.
Hub: Hub is a hardware device used to connect several computers together to form a Local Area
Network. Hub broadcasts the message to the entire network.
Switch: Switch is an intelligent Hub, which is used to segment networks into different sub network
called subnets. Switch is faster and efficient over Hub due to good traffic management capability.
Repeater: A repeater is a device that amplifies signals transmitted on the network. It is used to
extend a network beyond the segment length of the wire used.
Router: The device which connects two similar networks and can handle different protocols.
Gateway: It is a device that connects dissimilar networks.
Bridge: A device that connects two similar networks.
Types of Network
There are mainly four types of network:
Local area Network (LAN): Small computer network that is confined to a local area, office or within
a building are known as LAN. E.g. network within school campus.
Metropolitan Area Network (MAN): Metropolitan area network is the network spread over a city
or nearby corporate offices. For example, a cable TV network.
Wide Area Network (WAN): This type of network spreads over large geographical area across
countries and continents. WANs are generally used to interconnect several other types of
networks such as LANs, MANs etc.
Personal Area Network (PAN): The PANs are small network, used to establish communication
between computer and other hand-held devices in small proximity up to 10 meters using wired
USB connectivity or wireless system like Bluetooth or Infrared.
Difference between LAN and WAN
LAN WAN
1. Diameter is in a few kilometers 1. Span across countries
2. Very low error rate. 2. High error rate as compare to LAN, MAN, PAN
3. Complete ownership by a single 3. Run by multiple organization
organization 4. Normal speed 1-2 Mbps
4. Speed in MBPS (10-100 Mbps)
6
Network Topologies
Network topologies refer to the way in which the nodes are interconnected in a network.
Star Topology: In star topology each node is directly connected to the central node (server/hub) by
a single path.
Advantages:
1. Easy to install and Low cost.
2. A single node failure does not affect the entire network.
3. Problem diagnosis is easy due to central control.
Disadvantages:
1. Central node dependency, i.e. in case central node fails, the entire network fails.
2. Long cable is required because each node is directly attached to the server/central
node.
BUS or Linear Topology: In this topology, a single length of the transmission medium is used on
which various nodes are attached. It can transmit data in both directions.
Advantages:
1. Short cable length required
2. Easy to extend the network
Disadvantages:
1. Nodes must be intelligent.
2. Fault diagnosis is very difficult
Tree Topology: It is a variation of bus topology and has the shape of an inverted tree.
Advantages:
1. It is most suitable in networking multiple departments of a university where each unit
works separately.
2. Fault identification is easy.
Disadvantages
1. As multiple segments are connected to a central hub, if central hub fails, it affects the
entire network
2. Maintenance cost is high
Network Protocol
1. Hypertext Transfer Protocol (HTTP): HTTP is a communication protocol that is used to transfer
information on the internet and WWW. HTTP is a request/response standard between a client
and a server. A client is the end user and the server is the web site.
2. Transmission Control Protocol (TCP): TCP is responsible for verifying the correct delivery of data
from client to server. Data can be lost in intermediate network. TCP adds support to detect
errors or loss of data.
3. Internet Protocol (IP): IP is responsible for assigning 4 byte IP address to each packet.
4. Point to Point Protocol (PPP): It is a protocol used to establish a direct connection between
two computers using Telephone lines.
Remote Access Software:
Today there are some softwares that provide you facility of accessing the computer remotely.
Remote desktop software lets you access your computer and all its application over the Internet.
Example: Team Viewer, Window Remote Desktop, Ammyy Admin etc.
7
Team Viewer: TeamViewer is a popular piece of software used for Internet-based remote
access and support. Team Viewer Software can connect to any PC or server, so you can remotely
control your partner's PC as if you were sitting right in front of it.
Network Security Concept:
Cyber Law: Cyber law is a generic terms which refers to all the legal and regulatory aspects of
internet and World Wide Web.
Firewall: It prevents unauthorized access to or from a private network. A firewall is used to control
the traffic between computer networks.
Cookies: Cookies are the text messages sent by a web server to the web browser so that web server
can keep track of the users activity on a specific web site.
Hackers: Gaining knowledge about someones private and sensitive information by getting
accessibility of his computer system illegally. Hackers are more interested in gaining knowledge
about computer system and possibly using this knowledge for playful planks.
Crackers: Crackers are the malicious programs who break into the secure system for some illegal or
destructive purpose.
Network security threats:
Denial of Services (DoS): DoS attacks are those attacks that prevent the legitimate users from
accessing or using the resources and information. These types of attacks may eat up all the
resources of the system and computer become to a halt state.
Intrusion problem:
Snooping: It refers to unauthorized access of someone else data, e-mail, computer activity or
data communication. It may comprise monitoring of Keystrokes pressed, Capturing of passwords
and login information and interception of e-mails and other private information.
Eavesdropping: It the act of secretly listening / interpreting someone elses private
communication or information while data is on its way on the network.
Spyware: Spy ware is a program designed to spy on your activities and reports this data to people
willing to pay it either for legal or illegal purposes. It is getting installed in your system without
your consent as a file or gets downloaded from websites on Internet.
Spamming: Spamming refers to the sending of bulk-mail (junk-mail) by identified or unidentified
sources.
Phishing: Phishing is a process of attempting to acquire sensitive information such as user name,
passwords, credit card number, bank account details etc. using a trap-mail in which user himself
discloses their private details.
Malicious Programs
Virus: Computer viruses are malicious and self-replicating codes/programs that cause damage to
data and files on the computer system.
Worm: It is also a self-replicating program which eats entire disk space or memory. It copies itself
until all the disk space or memory is filled.
Trojan Horse: It is a program that appears harmless (like utility program) but actually performs
malicious functions such as deleting or damaging files.
Internet application:
SMS (Short Message Services): SMS is the transmission of short text message from one mobile to
other mobile phone.
Voice Mail: Transfer of recorded message is known as voice mail.
8
E-Mail: E-mail allows a user to send or receive message electronically across the world on the
computer.
Chat: Online textual talk in real time is called chatting.
Video Conferencing: A two way videophone conversation among multiple participants is called
video conferencing
Wireless/Mobile Communication:
GSM: It is a wireless communication medium that provides the user with roaming facility, good
voice quality, SMS etc. through digital signals.
CDMA: It is a digital cellular technology that uses spread spectrum technique where the entire
bandwidth is divided among several users for transmission of data. This allows multiple people
on multiple cell phones over the same channel to share a bandwidth of frequencies.
WLL: Wireless local loop (WLL) technology simply means that the subscriber is connected to the
nearest telephone exchange through a radio link instead of copper wires.
3G: It is the third generation of Wireless & Mobile technology. It is high-speed transmission with
advanced multimedia access and global roaming. 3G is mostly used with mobile phones and
handsets as a means to connect the phone to the Internet.
4G: It is fourth-generation of wireless service, which refers to the next wave of high-speed mobile
technologies that will be used to replace current 3G networks.
Cloud Computing: The practice of using a network of remote servers hosted on the Internet to
store, manage, and process data, rather than a local server or a personal computer.
Characteristics: (i) On demand Self-service, (ii) Broad network access. (iii) Resource Pooling (iv)
Measured service.
REVISION: Complete the following cross word puzzle using Network concept and terminology
1
4 9
2 3
5 7
6 8
10
1. (Across) Unauthorized access of someone elses data, email, computer activity etc.
1. (Down) A computer that facilitates sharing of data, software & hardware resources on
network.
2. (Across)Term used for connecting cables or connecting media across network.
3. (Down)Name given to the computers on a network.
4. (Down)Unique name assigned to a web site.
5. (Across)A device that amplifies and restores signals for long distance transmission.
9
6. (Across)An intelligent device that is used to connect several computers in a network.
7. (Down)The pattern of interconnection of nodes in a network.
8. (Down)A person gaining knowledge about someones private and sensitive information by
getting accessibility of his computer system illegally.
9. (Down)A system prevents unauthorized access to or from private network.
10. (Across)Measures taken to protect the networking infrastructure from unauthorized access
& misuse.
11
CHAPTER- 2: OPEN SOURCE CONCEPTS
Open Source Software: Open Source Software can be freely used, changed, improved, copied and
redistributed but it may have some cost for support and further development. Source Code is also
available with OSS. It can be modified and redistributed with some guidelines of License.
FOSS/FLOSS: An OSS may come free of cost or with a payment of nominal charges that its
developers may charge in the name of development and support of software. FLOSS (Free Livre and
OSS) is both free software as well as OSS.
Proprietary software: Proprietary software is the software that is neither open nor free available.
Its use requires special permission by the supplier or vendor. They must have some cost and Source
code is also not given. It is the property of the developer organization. No change, copy and
distribution is allowed.
Free software: Free Software are those which are freely accessible, freely used, changed,
improved, copied and distributed. It provides all types of freedom. It has no cost and Source Code is
also available with Free Software.
Free ware: Free ware is software which is available freely and can be copied and distributed but no
modification is allowed as source code is not available.
Shareware: These software are freely used, copied and distributed for a certain period of time.
After expiry, you have to purchase or uninstall them. Modification is not possible due to non-
availability of the source code. These are the Demo version and freely distributed for trial purpose.
Free Software Foundation (FSF): FSF is a non-profit organization established to support free
software movement. It has funded many software developers to develop free software under GNU
GPL. It also works on legal and structural issues for the free software community.
Open Source Initiative (OSI): It specifies the criteria and defines the terms and specifications for
Open Software.
Free & Open Source Products:
GNU: GNU refer to GNUs not UNIX. It offers a wide range of free and open source software
including application apart from operating system.
LINUX: Linux is a popular Open source operating system and can be downloaded from
www.linux.org.
Mozilla Firefox: Freeware, free web browser, it can be download from www.mozilla.org.
Open Office: It is an office applications suite. It is intended to be compatible with most Operating
Systems like Windows, Mac OS, UNIX and Linux and directly compete with Microsoft Office. It
includes Write (Word Processor), Calc (Spread Sheets), Draw (Graphics program), Impress
(Presentation), Math (Mathematical Formula editor) etc.
MYSQL: MySQL is most popular open source database system. MYSQL is a multi-user. It can work
on many different platforms like Linux, Microsoft Windows, SUN OS etc. It can be downloaded from
www.mysql.com.
JAVA NetBeans: Java NetBeans is a free open source, cross platform IDE with built in support for
Java programming language. In fact Net beans run anywhere where there is JVM. It offers many
features for application development.
APACHE: Apache web server (or HTTP server) is an open source web server available for many
platform such ad Linux, Microsoft windows and other platform. Apache is designed as a set of
12
modules, enabling administrators to choose which features they wish to use and making it easy to
add features to meet specific needs including handling protocols other than the web-standard HTTP. It
is component of LAMP (Linux, apache, MySQL and PHP).
PHP: It is known as Hypertext Preprocessor. It is an OSS used for server side applications and
developing dynamic web content. PHP allows easy interaction with large number of relational
database systems such MySQL, Oracle, DB2, PostgreSQL etc. PHP runs on most major OS including
windows, Mac OS X, UNIX, Linux
W3C: The World Wide Web consortium exists to realize the full potential of the web.
Advantages of Open Source Software
Application and platform independence.
Making the data accessible to all.
Disadvantages of Open Source Software
Open source development process may not be well defined and the stages in the development
process, such as system testing and documentation may be ignored.
Not all OSS initiatives have been successful.
Types of Standards:
Proprietary standards: it is closed standard and users have to buy license to use them.
Open standards: Open standards are internationally accepted technical standards that guarantee
that data can be exchanged or accessible across platforms and applications, even as technologies
changes, It is freely available to all.
Some common open standard formats are:
HTML: HTML format is the standard language for the web.
XML: XML is open standard which is used to describe the data. It is text based markup language
that allows storing data in structured format
Open document Format (ODF): Open document is an open, XML based file format. It is an open
standard, supported by the IBM, Sun etc.
Ogg Vorbis: It is a new audio compression format. It is roughly comparable to other formats used
to store and play digital music such as MP3 and mpeg-4 format. It is open, free, unpatented and
loosely compression project from Xiph.org foundation.
15
UNIT-2
CHAPTER 3: JAVA GUI PROGRAMMING REVISION TOUR-I
Rapid Application Development: It describes a method of developing software through the
use of pre-programmed tools or wizards. The pre-programmed tools or controls are simply dropped
on a screen to visually design the interface of application. It enables program development in
shorter time.
NetBeans Java IDE: It is a free, open-source, cross-platform IDE with built-in support for Java
programming language. It has more advanced GUI building tools available in any open-source Java
IDE.
Event: Occurrence of an activity.
Message: Information sent to the application or received from the application.
Types of Swing Components:
(a) Component: It is a self-contained graphic entity like JLabel, JTextField etc.
(b) Container: It can hold other components. It is of two types:
(i) Top Level Container: Can be displayed directly on a desktop. Every swing application
must have at least one top level container, i.e. JApplet, JDialog, JFrame.
(ii) Non Top Level Container: Can be displayed within another top level container, i.e.
JPanel, JScrollPane, JInternalFrame, JLayeredPane etc.
Child controls are controls inside a container control.
Java Character Set: It is the set of valid character set that a language can recognise. Java uses
Unicode character set.
Data Types: Data Types are means to identify the type of data and associated operations of
handling it.
16
Variables: It is a named memory location which holds a data value of a particular data type.
Variable declaration & Initialisation:
A variable with declared first value is said to be initialized variable. e.g. int rollno = 1;
Text Interaction:
(i) getText() Method : String name = nametf.getText();
(ii) setText() method: Stores or changes text in text based controls e.g. ranktf.setText(1);
(iii) Parse() Methods: Used to convert a string value into numeric value.
(iv) JOptionPane.showMessageDialog (): Displays a Message Box.
System.out.print (): It prints the desired output on output window.
System.out.println():It prints the desired output on output window and also changes the line.
Variable Scope: Program region within which a variable is accessible. It is accessible within the set
of braces it is declared in.
if (..)
{
int x = 5;
.
}
System.out.println(The result is : + x); //error
Constant: Named memory locations whose value cant be changed in the program. It makes
program easy to read, check & modify. e.g. final int rateofinterest = 10;
Operator: It represents particular task and the objects of the operation is called operands. It may
be Unary (working on one operand, eg. unary -), binary (working on two operands, e.g. subtract -)
or ternary (working on three operands, e.g. ?:).
Type Conversion: It is the process of converting one predefined data type into another. It has two
forms:
Implicit (Coercion): Compiler automatically performs conversion to the type of the largest
operand in mixed mode expression.
Explicit (Type casting): Done by programmer. Converting to or from Boolean is not
permitted. : (type) expression e.g. (float) (x/5 * y + 5)
Programming Constructs: Flow of Control
17
Selection:
If statement; if else if
if (expression) if (expression)
statement ; body ;
if . . . else statement else if (expression)
if (expression) statement 1 ; body;
else statement 2; .
Nested if: else body;
if (expression) { Dangling else Problem:
if (expression) if (expression)
statement 1 ; if (expression) statement 1 ;
[else else statement 2;
statement 2;] } (Indentation indicates else for outer if but it actually
else matches with preceding If.)
body of else;
The Switch Statement:
switch (expression)
{ case constant 1 : statement sequence 1;
break; // value of expression must be byte, short, int or a
char.
case constant 2 : statement sequence 2;
break;
.
[default : statement sequence n]; //default can be anywhere need not to be in
last.
}
In absence of break in switch statement, Java will start executing all statements after the correct
case. This phenomenon is called Fall-Through.
Jump statement
Return: To return from a function.
Break: It is used to terminate the body of while, do-while, for or switch statement and
transfers control to the statement following the body.
Continue: It skips the rest of the loop (while, do-while or for) and starts the next iteration.
Solved Questions:
1. Write a java code to find out whether a year (4 digit number stored in a variable) is a leap
year.
private void lybutActionPerformed(java.awt.event.ActionEvent evt) {
long i = Long.parseLong(lytf.getText());
if (i%100 ==0)
if (i%400 ==0)
System.out.println(i + is Leap Year");
else System.out.println(i + " is Normal Century Year");
else if (i%4==0)
System.out.println(i + " is Leap Year");
else System.out.println(i + " is not a Leap Year"); }
2. Write a java program to find the greatest out of three numbers.
int a = Integer.parseInt(tf1.getText()), b = Integer.parseInt(tf2.getText());
int c = Integer.parseInt(tf3.getText());
if (a>b && a>c)
System.out.println( a + is greater);
elseif (b>c) System.out.println( b + is greater);
else System.out.println( c + is greater);
19
Sample Questions:
1. What will be content of the jTextArea1 after executing the following code:
for (int i=2;i<=5;i++)
{ jTextArea1.setText(jTextArea1.getText()+ + Integer.toString(i*i)); }
2. Write java code that takes value for side of a square in jTextField1 and calculate area of it
which is to be displayed in jTextField2.
3. Item code consisting of 5 digits is stored in a integer type variable intItemCode. Write the
code for keeping this itemcode in a String type variable called strItemCode.
4. What message will be displayed after the execution of the following code?
int age =64, relaxation = 4; modiage= age relaxation;
if (modiage < 60) jOptionPane.showMessageDialog(null, Not Eligible);
else jOptionPane.showMessageDialog(null, Eligible);
5. Rewrite the following program code using if statement:
int c = jComboBox1.getSelectedIndex();
switch(c)
{ case 0 : amount = bill; break;
case 1 : amount = 0.9 * bill; break;
case 2 : amount = 0.8 * bill; break;
default : amount = bill;
}
20
CHAPTER 4: JAVA GUI PROGRAMMING REVISION TOUR-II
FRAME
It is a top level window with title and border. It is created through JFrame component. It has title
and boarder. Each project must have at least one frame.
Swing controls Methods Properties
JButton getText() Background
setText() Enabled
Font
Foreground
Text
Label
JLabel getText() Background
Enabled
Font
Foreground
Text
JText Field getText() Background
isEditable() Enabled
isEnabled() Editable
setText() Foreground
Text
jTextArea getText() Background
setText() Enabled
append() Editable
lineWrap
Text
JRadioButton getText() Background
setText() Enabled
isSelected() Font
setSelected() Foreground
Buttongroup
Selected
Label
JCheckBox getText() Buttongroup
setText() Font
isSelected() Foreground
setSelected() Label
Selected
Text
21
jList getSelectedValue() Foreground
getSelectedValues() Model
getSelectedIndex() SelectionMode
getSelectedIndices() SelectedIndex
setSelectedIndex() SelectedIndices
setSelectedValue()
JComboBox getSelectedItem() Background
getSelectedIndex() Buttongroup
setModel() Editable
setSelectedIndex() Enabled
setSelectedItem() Font
Foreground
Model
SelectedIndex
SelectedItem
SelectionMode
Text
JTable getText() Model
addRow()
getModel()
JOptionPane showMesageDialog() getRowCount()
removeRow()
addRow()
Sample Questions:
1. What is a button group? What all controls can you put in it?
2. Write a statement to make jTextArea1 as un-editable.
3. Which control is to be used to select a country from the list of given countries?
4. What will be displayed in jTextArea1: jTextArea1.setText("cbse\nFinal_Exam\tIP")
5. In a Recreation Park when a group arrives, the number of people in the group and whether the
group wants to enjoy the Water Park or not is entered. Entry fees is 500 per person. The person
can choose to play at Water Park by selecting the checkbox. Rides of Water Park will cost 250
extra per person.
Write code for the following:
23
Sample Questions:
1. Define Object Oriented Programming (OOP).
2. Define a class with respect to OOP.
3. Define data encapsulation with reference to OOP.
24
CHAPTER 6: COMMONLY USED LIBRARIES
Libraries: It is a set of ready-made software routines that can be reused in new programs.
Libraries are made available in a program using import statement e.g. import java.io.*;
String Library: It is a part of java language library java.lang, which is by default imported to the
program. There are 3 classes to work with characters:
(i) Character Class whose instances can hold single character data.
(ii) String Class whose instances can hold unchanging string. Every time we change, a new
object is created automatically.
String s = Excellent ; or String s = new String(Excellent);
(iii) StringBuffer Class whose instances can hold mutable strings.
StringBuffer sb = new StringBuffer(); or StringBuffer sb = new StringBuffer(First); or
StringBuffer sb = new StringBuffer(10); // to hold 10 characters
String s = "crack", r = "rack";
25
Math Functions: It is found in Math library and used as Math.sqrt(a*a + b*c)
Function Action Function Action Function Action
y
pow(x,y) X ceil(x) Round up floor(x) Round down
sqrt(x) Root abs(a) Absolute max(a,b), min(a,b) Max, min
round(x): Rounds off a number to its nearest integer. It argument is double then it returns long
and for float it returns int. If the argument is NaN, then the result is zero. Round(-4.5) is -4.
Round(4.5) is 5. (NaN means Not a Number).
Sample Questions:
1. What will be display in a jTextField1 after executing the following code?
int m= 16; m=m+1;
if (m<15) jTextField. setText(Integer.toString(m)); else
jTextField1.setText(Integer.toString(m+15));
2. What does round() return if a negative float value is passed to it?
3.Write code to display IP 12 CBSE in a dialog box (JOptionPane).
4. What will be the output of the following code: (i) Math.round(1.5) (ii) Welcome.toUpperCase().
5. What will be the value X1 after the execution of the following code ?
String X1= "Graduate" ,X2="Post" ; X1=X2. concat (X1) ;
26
CHAPTER 7: CONCEPT OF INHERITANCE
Inheritance: It is the capability of one class to derive properties from another class.
Need for Inheritance:
1. It ensures closeness with real-world models.
2. Reusability
3. Transitive nature of inheritance
Subclass & Super Class: The class being inherited is called super class or base class and the
inheriting class is called sub class or inherited class. Thus subclass derives some features (data
members and methods) from its super class.
Forms of Inheritance
Single Inheritance: A Subclass inherits from only one base class.
Multiple Inheritance: A subclass inherits from multiple base classes (not supported by Java).
Hierarchical Inheritance: Many subclasses inherit from a single base class.
Multilevel Inheritance: A subclass inherits from a class that itself inherits from another class.
This shows transitive nature of inheritance.
Hybrid Inheritance: Here a sub class inherits from multiple base classes and all of its base
classes inherit from a single base class.
Defining Derived class:
Class <sub class name> extends <super class name> {
: // members of sub class}
Function Overloading: A function name having several definitions in the same scope that are
differentiable by the number or types of their arguments (i.e. same name but different signature),
is said to be an overloaded function. Functions with same name and same signature but different
return type are not allowed. Functions with same name and signature are treated as re-declaration
of first.
Need for Function Overloading: To cope with the changing behavior in different situations.
Declaration and Definition:
double a =0.0, b = 5.4, c = 8.9;
int d = 0, e = 5, f = 8;
a = sum(b,c);
d = sum(e,f);
System.out.println(a + "," + d);
int sum( int a, int b){ //func 1
return (a+b); }
double sum( double x, double y){ //func 2
return (x+y); }
Example of Inheritance and constructors
package a;
class person {
int j = 4;
private int i = 5;
27
protected String name;
public String address;
person (String name, String address) {
this.name = name ;
this.address = address ; }
}
class student extends person { //cant access i
int rolno ; int j = 1;
student (String name, String address, int rolno){
super(name, address);
this. rolno = rolno ; }
public void display () {System.out.println(j + , + super.j);} }
// j of class person is hidden
package b;
class q { }
Sample Questions:
1. What is inheritance? Discuss its various forms.
2. Define base class and derived class. How are these related?
3. How does the visibility mode control the access of members in the derived class? Explain with
examples.
28
CHAPTER 8: DATABASE CONNECTIVITY TO MYSQL
MYSQL provides connectivity for client applications developed in the Java programming language
via JDBC driver, which is called MYSQL Connector/J.
There are four main classes in the JDBC API for database connectivity:
(i) Driver Manager Class: It locates and logs on to the database and returns a connection object.
(ii) Connection Class: It manages the communication between Java & MySQL.
(iii) Statement Class: It contains SQL string that is submitted to the database. An SQL Select
statement returns a ResultSet object that contains the data retrieved as the result of SQL
statement.
(iv) ResultSet Class: A result set is the logical set of records that are fetched from the database by
executing a query and made available to the application program. It accesses, analyzes and
converts data values returned by the SQL select statement.
(iv) Execute a query: Create an object of type Statement using createStatement() method. Then
execute the SQL statement using executeQuery( ) method, in case of SELECT query, or
executeUpdate() method, in case of UPDATE, INSERT or DELETE or Create Table query. It returns an
object of resultSet type.
OR
29
sql = delete from employee;
ResultSet rs = stmt.executeUpdate(sql);
ResultSet Cursor: When a ResultSet object is created, the cursor is placed just before the first row.
To move the cursor to first row use rs.next() or rs.first(). rs.next() forwards the cursor by one row
since Initially cursor is before the first row, first rs.next() will move the cursor to first row. Any
following rs.next() commands forward the cursor by one row.
(v) Extract data from result set: This step is required if data is fetched from the database i.e., in
case of SELECT query. To retrieve the data ResultSet.get<Type>() method is used. i.e., getInt(),
getLong(), getString(), getFloat(), getDate() etc. All these method takes parameter as Column Name
or Column Index. Column Index is the order of the column.
int id = rs.getInt(id); // if more than one column exists in result set with same
Column Name then the first one is returned.
or int id = rs.getInt(1); // If id is first field of table.
String name = rs.getString(name);
Sample Questions:
1. What is a connection and a result set?
2. What does Driver Manager do?
3. Write a statement to open a connection object namely myconn for a MySQL database namely
school.
4. What are the steps to connect to a database from the Java application?
32
Programming Problems
1. How many times, the following loop gets executed? i=0; while(i>20) {//Statements }
Ans: 0 times
2. Write a java program to calculate the sum of all the No. divisible by 5 in the range 1 to 50.
Ans: int sum=0; for(int i=1;i<=50;++i) { if(i%5==0) sum=sum+i; } jLabel1.setText(""+sum);
3. Write method in java that takes a number returns the sum of its digits.
Ans: int sumdig(int n)
{ int sum=0, r;
while(n!=0)
{ int r=n%10;
n=n/10;
sum=sum+r; }
return (sum); }
4. How many times, the following loop gets executed? int i=0; do { //Statements }while(i>20);
Ans: 1 time.
5. Find the output of the code:
int f=2, i=1; do {f*=i; }while(++i<5); jTextField1.setText (""+f);
Ans: 48
6. Write the output :
(i) jTextField1.setText("Hello".charAt(1));
Ans: e
(ii) jTextField1.setText(Pranam.substring(3));
Ans: nam
7. Write the value stored in variable y after executing the following code:
int x , y = 0; for(x=1;x<5;++x) y=x++;
Ans: 3
8. What will be the contents of jTextield after executing the following statement:
int mynum=3; mynum=mynum-1; if(mynum>5) jTextField1.setText(Integer.toString(mynum));
else jTextField1.setText(Integer.toString(mynum*4));
Ans: 8
9. Find the output of the following code:
int First=11; int Second=50; First++; if(First+Second>60) jLabel1.setText("Qualified");
else jLabel1.setText("Not Qualified");
Ans: Qualified
10. What will be the value of j and k after execution of the following code:
int j=5,k=15; if(k>=j) {k=j; j=k;}
Ans: j= 5 k= 5
11. Find the output
int fnum=6, snum=9; if(fnum>1||snum>6) if(fnum>6) jTextField1.setText("Code Worked");
else jTextField1.setText("Code Might Work"); else jTextField1.setText("Code will not Work");
Ans: Code Might Work
12. What will be the content of the jTextArea1 after executing the following code?
int Num =2; do { jTextArea1.setText(Integer.toString(++Num)+"\n"); Num= Num + 1;
}while(Num<=10);
33
Ans: 9
13. String s ="Kendriya Vidyalaya"; jTextField1.setText(s.length()+"");
jTextField2.setText(Math.round(2.54)+"");
Ans: 18 , 3
14. Give the value of a after executing following Java code.
int p=9,q=11,a=6,b=4; while(p<=q) { if(p%2==0) a=a+b; else a=a-b; p=p+1; }
Ans: 2
15. What will be the output produced by following code fragment?
float x=5, y=2; int z=(int)(x/y); switch(z) { case 1: x=x+2; case 2: x=x+3; default: x=x+1; }
System.out.println("value of x:"+x);
Ans: value of x: 9.0
16. Give the output of the following code:
int m=50; while(m>0) { if(m<10)break; m=m-10; } System.out.println("m is"+m);
Ans: m is 0
17. What will be the contents of jTextField1 and jTextField2 after executing the following code:
String s = "Big Brother"; jTextField1.setText(s.length()+"");
jTextField2.setText(s.toLowerCase());
Ans: switch(num1) {
case 1 : jTextField1.setText("Number is one"); break;
case 2 : jTextField1.setText("Number is two"); break;
case 3 : jTextField1.setText("Number is three"); break;
default : jTextField1.setText("Number is more than three"); }
Ans:
(a) if (jRadioButton1.isSelected())
jLabel2.setText(625);
if (jRadioButton2.isSelected()) jLabel2.setText(750);
if (jRadioButton3.isSelected()) jLabel2.setText(850);
if (jRadioButton4.isSelected()) jLabel2.setText(1000);
37
Rate is calculated based on the time according to the following table:
Account Time Rate
Fixed Deposit <=2 8%
>2 and <=5 9%
>5 10%
Recurring Deposit <=2 9%
>2 and <=7 10%
>7 12%
An additional rate of 2% is given to the senior citizens i.e. if the Senior citizen (chkSR checkbox) is
checked.
Ans:
(a) jTextField1.setText();
jTextField2.setText();
jTextField3.setText();
jRadioButton1.setSelected(true);
jCheckBox1.setSelected(false);
The grading criteria for the two streams are given below:
a) Write code for Calculate Percentage button to calculate the Percentage after finding the
total marks of I term and II term. Also ensure that NCC cadet gets an increment of 3% in
their percentages.
b) Write code for Calculate grade button to calculate the grade depending up on the stream
selected according to the given criteria.
Ans:
(a) int f= Integer.parseInt(jTextField1.getText());
int s= Integer.parseInt(jTextField2.getText());
int tot = f + s;
float p= tot / 2;
if (jCheckBox1.isSelected()) p = p + 3;
jLabelp.setText( + p);
(b) String g;
If (jRadioButton1.isSelected())
{ if(p >= 80) g = A;
else if(p >= 60 && p<80) g = B;
else g = C; }
39
else { if(p >= 75) g = A;
else if(p >= 50 && p<75) g = B;
else g = C; }
jLabelp.setText( + p);
jLabelg.setText( + g);
4. Mrs. Anju works in a Manufacturing company. To calculate total wages he has developed the
following GUI in NetBeans. Male and female workers are respectively paid Rs. 350/- per day and
Rs. 400/- per day. Skilled workers are paid extra at the rate of Rs. 200/- day. Male and female
workers from rural areas are paid 20% less per day.
a. When Calculate Wage button is clicked, the total wages is calculated as per the given criteria
and displayed in total wage textbox.
b. When Clear button is clicked, all the textboxes should be cleared and radio button, checkbox
should be selected.
c. Close the application when Quit button is pressed.
Ans:
(a) int w = 0;
int d = Integer.parseInt(jTextField2.setText());
if (jRadioButton1.isSelected())
w = 350;
else w = 400;
if (jCheckBox1.isSelected())
w = w + 200;
if (jRadioButton3.isSelected())
w = w - (w * 20) / 100;
int cw = d * w;
jLabel6.setText( + cw);
(b) jTextField1.setText();
jTextField2.setText();
jRadioButton1.setSelected(false);
jRadioButton2.setSelected(false);
40
jRadioButton3.setSelected(false);
jRadioButton4.setSelected(false);
jCheckBox.setSelected(false);
(c) System.exit(0);
5. The following interface has been built for an Ice-Cream Parlor using Netbeans. The parlor offers
three varieties of ice-cream - vanilla, strawberry, chocolate. Vanilla ice- cream costs Rs. 40,
Strawberry Rs. 45 and Chocolate Rs. 55. A customer can choose one or more ice-creams, with
quantities more than one for each of the variety chosen. To calculate the bill, parlor manager
selects the appropriate check boxes according to the varieties of ice-cream chosen by the
customer and enter their respective quantities.
6. Ms. Radha works in a shopping mall. To calculate net payable amount she has developed the
following GUI in NetBeans.
The shop accepts payments in three modes-
Cash, Debit Card, Credit Cards.
The discount given as per mode of payment
is as follows-
If the Member check box is checked then the customer gets an additional discount of 5% on net
payable amount.
I. Write the code to make the textfields for Discount( txtDiscount ) and Net Payable
(txtNetPayable) uneditable.
II. Write code to do the following-
a) When Calculate button is clicked the discount and net payable amount is calculated as
per the given criteria and displayed in discount and net payable text boxes.
b) When Clear button is clicked all the text boxes should be clear.
42
III. Close the application when Exit button is pressed.
Ans: I. txtDiscount.setEditable(false);
txtNetPayable.setEditable(false);
IV. System.exit(0);
7. Alpha Chemicals PVT ltd has asked his programmer to develop the following GUI application in
Netbeans:
43
a. To calculate service charges depending on the selection of radio button. This code will execute after
click on the calculate service charges?
b. To calculate net price when Calculate Net price button will be clicked.
c. When exit button will be clicked application should be automatically closed.
Ans:
(b) float q = Float.parseFloat(jTextField2.getText());
float p = Float.parseFloat(jTextField3.getText());
float sp = q * p;
jLabelsp.setText( + sp);
float sc;
if (jRadioButton1.isSelected())
sc = (5 * sp) / 100;
else if (jRadioButton2.isSelected())
sc = (10 * sp) / 100;
else
sc = (15 * sp) / 100;
jLabelsc.setText( + sc);
(b) float sp = Float.parseFloat(jLabelsp.getText());
float sc = Float.parseFloat(jLabelsc.getText());
float np = sp + sc;
jLabelnp.setText(+np);
(c) System.exit(0);
44
Answers:
1. Button Group 2. RAD 3. Final 4. DoClick 5. Statement
6. Echochar 7. Model 8. Equals 9. JDBC 10. LineWrap
45
CHAPTER 9: WEB APPLICATION DEVELOPMENT
Web Application: A web application refers to an application which sends and receives information
through WWW over internet. It may include hypertext, multimedia, GUI etc.
Web Browser: A client program that enables the user to browse, search and collect information
from the web is known as a web browser. It sends the request from the client/user to server for a
specific resource and the server then responds with the content of that resource. e.g. Internet
explorer, Mozilla Firefox, Google chrome, Opera.
Web server: Web servers are computers on internet on which web pages are stored. Web server
stores the web pages and responds to the request made by web browser. e.g.: Apache web server,
Microsoft Internet Information Server (IIS), Netscape Enterprise Web server.
URL: The unique address of the website is known as uniform Resource Locator (URL). E.g. the web
site of KVS has an address or URL called http://www.kvsangathan.nic.in. It has following parts:-
Protocol: It specifies the type of protocol (set of rules) to be followed by server. Exam: http,
https etc.
Domain Name: It specifies the name of the web server on the internet including domain
name like .com, .org, .edu or country domain like .in, .ca etc.
Directory path: It specifies Location of file/web page on the server.
Object Name: It specifies the name of specific web page or file like index.html.
Example: http://cbse.nic.in/welcome.aspx
Communication with Web server: The internet on WWW works on client server computing model.
In this model client has web browser which works as web client and other machine (remote
machine) which request the pages from web server. A web server follows some protocols like HTTP,
HTTPS, FTP etc.
Client Server Computing: Client server computing refer to a network setup in which program,
documents and information reside on the server and client can connect with the server using
network to access the information. It is of two types:
1. Static Web Pages: Static Web pages display the exact information whenever anyone visits it,
until you alter that page's source code.
2. Dynamic Web pages: Dynamic Web pages are capable of producing different content for
different visitors from the same source code file. The website can display different content
based on what operating system or browser the visitor is using, whether user is using a PC
or a mobile device, or even the source that referred the visitor.
Examples:
Client side computing: Java script, VB Script.
Server side computing: ASP (Active Server Page), PHP (Personal Home Page), JSP (Java
Server Page.
Some commonly used internet protocols:
Protocol: A protocol is a set of rules to govern communication between two computers in a
network.
HTTP (Hyper Text Protocol): It is used on WWW for transferring web pages and files
contained in web pages such as images.
FTP (File Transfer Protocol): It is used for transferring files from one machine to the other.
SMTP (Simple Mail Transfer Protocol): It is used for email.
Telnet: It is used to open remote machine access (telnet) session.
46
Very Short Answer Type Question (1 Marks)
1. What is URL?
2. Explain WWW.
3. Identify the client side and server side technologies.
Java Script, ASP (Active Server Pages), PHP (Hypertext Pre Processor), JSP(Java
Server Pages)
4. In the URL http://kvsangathan.nic.in/Circulars.aspx What is the http component?
5. A program that serves requested web pages or documents are known as:
(I) Web page (ii) URL (iii) Web server (iv) None of these.
6. The address of a web site/ resources on the internet is known as:
(I) HTTP (ii) URL (iii) WWW (iv) None of these.
7. Identify from the following which is not a web browser:
(I) Mozilla Firefox (ii) Opera (iii) Netscape Navigator (iv) MS Word
8. Identify web server software from the following:
(I) Apache (ii) MS Word (iii) Mozilla Firefox (iv) HTML
47
CHAPTER 10: HTML-1 BASIC HTML ELEMENTS
HTML
Hyper Text markup language (HTML) is used to create web pages or web documents. It tells the
web browser how to display text, pictures and links on the screen. HTML provides various markup
elements. Using these elements we can specify various parts of a web page and formatting of web
page. Basically HTML is used to design the layout of a document with hyperlink.
Elements of HTML:
HTML is made up of elements called Tags and Attributes.
Tags: A tag is coded HTML command within angular <> bracket. It is not case sensitive. There are
two types of tags Empty tags and Container tags.
Attribute: An Attribute is a special word used inside tag to specify additional information of tag
such as color, alignment etc.
50
Short Answer Type Question (2 Marks)
1. What is use of comments? Which tag is used for comments?
2. Differentiate between container and empty elements.
3. What are logical and Physical Text Styles?
4. Differentiate between <BR> and <P> tag.
5. What is the use of <IMG>tag? Also write its properties.
51
CHAPTER 11: HTML-II : LISTS, TABLES AND FORMS
Lists in HTML
There are three basic types of lists in HTML. The lists may be nested as well.
i) Unnumbered or Unordered List
ii) Numbered List or Ordered List
iii) Definition List
Unordered lists <UL> - are indented lists with a special bullet symbol in front of each item.
<LI> - denotes the beginning of each new list item.
<UL>
Output
<LI> Apples
Apples
<LI> Bananas
Bananas
<LI> Grapefruit Grapefruit
</UL>
An ordered numbered list are indented list with numbers in front of each item.<LI> denotes the
beginning of each new list item.
<OL>
<LI> Apples Output
<LI> Bananas 1. Apples
2. Bananas
<LI> Grapefruit
3. Grapefruit
</OL>
TYPE Attributes Value Description Sample sequence CODE & OUTPUT
/example
Container TYPE A Capital letters A, B, C, D <OL start = 6 type =
element i>
a Lowercase letters a, b, c, d
<LI> JAVA
I Capital roman I, II, III, IV <LI> SQL
numerals <LI> C++
i Lowercase roman i, ii, iii, iv </OL>
numerals
1 Arabic numerals 1, 2, 3, 4 Output
52
Definition Lists <DL> - A definition Lists are indented lists without any bullet symbol or any
number in front of each item.
<DT> stands for definition term.
<DD> stands for definition description.
Tables in HTML :-
The HTML table model allows you to arrange data text, preformatted text, images, links, forms,
form fields, other tables etc. into rows and columns of cells.
<Table> ..</Table> defines a table object.
<TR> ..</TR> defines a table row.
<THEAD>..</THEAD> defines header section of table.
<TFOOT>..</TFOOT> defines footer section of table.
<TBODY>..</TBODY> defines body section of table.
<TD>..</TD> defines a table data (cell value).
<TH>..</TH> defines column header.
<CAPTION>..</CAPTION> defines caption of table.
Cell spacing & cell padding: Space between cells is cellspacing & space between cell border & cell
data is cell pading
Row span vs cols span: Span of a cell in respect of columns is row span . Colspan is span of a cell in
respect of columns
HTML Forms
HTML forms are means to collect information / data from the site-visitor or client. It is done with
the help of controls that collect the information and send it over. Forms contain some GUI controls
to interact with users.
Some of the important controls are:-
Button
Submit button
Reset button
Push button
Checkboxes
Radio Button
Combo boxes
Password
53
Text Input (Text field, Text area etc.)
CREATING FORM:-
Attributes Value Description
Name String Specifies the name of the form
Action Script or URL It specifies the script or email-ID or URL which will receive
data.
Method Get Specifies how the form-data is submitted.
Post Get form data is submitted as URL variables.
Form Post form data is submitted as HTTP post.
Form opens a new form as per specified URL.
1. What is HTML?
2. What is XML? What do you mean by extensible in XML?
3. What is XML? Write 02 differences between XML and HTML?
4. Write down the difference between HTML and XML.
5. Write down the four features of XML?
6. What is role of style sheet in XML?
7. What is CSS? Also write types of CSS.
55
UNIT 3
CHAPTER 13: DATABASE FUNDAMENTALS - MYSQL REVISION TOUR
Database: Collection of logically related data stored in a structure format.
DBMS: Software used to manage databases is called Data Base Management System (DBMS).
RDBMS: A DBMS used to manage Relational Databases is called an RDBMS (Relational Data
Base Management System). Some popular RDBMS software available are: Oracle, MySQL,
Sybase, and Ingress.
Benefits of using a DBMS are:
a. Redundancy can be controlled b. Inconsistency can be avoided
c. Data can be shared d. Security restrictions can be applied.
MySQL: It is an Open Source RDBMS Software. It is available free of cost.
Relation/Table: A table refers to a two dimensional representation of data arranged in columns
(also called fields or attributes) and rows (also called records or tuples).
Key: A column or a combination of columns which have some specific characteristics in a relation
e.g. are Primary Key, Candidate Key and Foreign Key etc.
Primary Key: The group of one or more attribute(s) used to uniquely identify each row/tuple of a
relation/table is called its Primary Key.
Candidate Key: A group of columns which can be set as the primary key of a relation is called a
candidate key because it is one of the candidates available to be the primary key of the relation.
Alternate Key: A candidate key of a table which is not set as primary key is called its Alternate Key.
Degree is the number of columns/attributes in the table.
Cardinality is the number of rows/tuples in a table.
SQL (Structured Query Language): It is the language used to manipulate and manage databases
and tables within them using an RDBMS. There are following four types of SQL commands:
1. DDL (Data Definition Language): Deals with the Structure (create, remove, or modify) of
databases and tables e.g. CREATE, DROP, ALTER.
2. DML (Data Manipulation Language): Used to manipulate data/ values within tables e.g.
INSERT, UPDATE, DELETE.
3. DCL (Data Control Language): Used to control the access to the databases and tables e.g.
GRANT, REVOKE.
4. TCL(Transaction Control Language): used to manage and control the transaction e.g.
COMMIT , ROLLBACK, SAVEPOINT
Some Commonly used DDL Command are as follows:-
SNo Command, Syntax and Purpose
1 Command : Create Database
Syntax: Create database <Database Name>;
Purpose: Creates a database with specified name
56
3 Command : Alter Table
Syntax: Alter Table <Table Name> Add <Column Name> Data Type1;
Alter Table <Table Name> Drop <Column Name>;
Alter Table <Table Name> Modify <Column Name> <new_defintion>;
Purpose: Modify the strcture of a table
4 Command : Use
Syntax: Use <Database Name>;
Purpose: Open the specified database for use
5 Command : Select Database( )
Syntax: : Select Database( );
Purpose: Show the name of current Database
6 Command : Show tables;
Syntax: : Show tables ;
Purpose: Show a list of tables in the current database
7 Command : Show databases;
Syntax: : Show databases;
Purpose: Show a list of databases
8 Command : Insert
Syntax : Insert Into <Table Name> ( <Column Name1>,<Column Name2>.,values
(<value1, value 2.);
Purpose: Insert Data into the table
9 Command : Select
Syntax: Select * Column name, Expression,Column name From table Name Where
Condition Order by Column Name Asc/Desc ;
Purpose: To reterive selected data from the table
10 Command : Describe
Syntax: : Desc <Table Name> ;
Purpose: Show structure of table
11 Command : Update
Syntax: : Update <table name>
Set <Column name >=Value
Where <condition>;
Purpose: Update or Modify the data in tables
Following are the clauses which can be used with select command
SNo CLAUSE EXPLANATION
1 DISTINCT Used to display distinct values from a column of a table
2 WHERE Used to specify the condition based on which rows of a table are dispalyed
3 BETWEEN Used to define the range of values within which the column values must fall to
make a condition true. It include both upper and lower values.
4 IN Used to select values that natch any values in a lsit of specified values
5 LIKE Used for pattern matching of string data using wildcard characters % and _
6 IS NULL/ NOT Used to select rows in which the specified column is NULL (or is NOT NULL)
57
NULL
7 ORDER BY Used to display the selected rows in ascending or desending order of the
specified column
String Functions:
SN Name & syntax Description
1 LENGTH() Returns the length of a column or a string in bytes
2 CONCAT(Str1, Str2) Returns a string that result from concatenating the arguments.
3 INSTR(Str, Substr) Returns the position of the first occurance of substring (substr) in the
string(str)
4 Lower(str) or Returns the argument <str> in lowercase
LCASE(Str)
5 Upper(str) UCASE(Str) Returns the argument <str> in uppercase
6 LEFT(Str, n) Returns the first n character from the string
7 RIGHT(Str,n) Returns the last n character from the string
Numeric Functions:
SN Name & syntax Description
1 POWER(X,Y) or POW(X,Y) Returns the values raised to the power of y
2 ROUND(X) Rounds the argument X to the nearest Integer
3 ROUND(x,d) Rounds the argument X to d decimal places
4 Truncate(x,d) Truncate the argunment x to d decimal places
58
Date and Time Functions:
SN Name & syntax Description
1 CURDATE() Returns the current date in YYYY-MM-DD format YYYYMMDD format,
depending on whether the function is used in a string or numeric
context
2 NOW () Returns the current date and time in YYYY-MM-DD HH:MM:SS
3 SYSDATE() Returns the current date and time in YYYYMMDD HHMMSS.uuuuuuu
format
4 DATE(expr) Extracts the date part of date or datetime <exp>
5 MONTH(date) Returns the numeric month from the specified date in the range 0 to
12. it returns 0 for dates such as 0000-00-00 or 2010-00-00 that have
a zero month part
6 YEAR(date) Returns the year for specified date in the range 0 to 9999. it returns 0
for the Zero date. Returns values like 1998, 2016 etc.
7 DAYNAME(date) Returns the name of the weekday for specified date
8 DAYOFMONTH(date) Returns the day of month in the range 0-31
9 DAYOFWEEK(date) Returns the day of week in number as 1 for Sunday, 2 for Monday and
so on
10 DAYOFYEAR(date) Returns the day of the year for given date in numeric format in the
range 1 to 366.
CALCULATOR FUNCTIONALITY USING SELECT STATEMENT
SELECT 5+68;
SELECT 5+68 FROM DUAL;
SELECT ECODE, SAL_AMT*12 FROM SALARY;
TO KNOW CURRENT DATE
SELECT CURDATE();
DISPLAY DATA WITH OTHER HEADING
SELECT SAL_AMT*12 AS ANNUAL SALARY FROM SALARY
SELECT 22/7 AS PI;
HANDLING NULLS
SELECT NAME, BIRTH, DEATH FROM ABC;
SELECT NAME, BIRTH, IFNULL(DEATH, ALIVE) FROM ABC;
PUTTING TEXT IN SELECT QUERY
SELECT EMPNAME, GETS THE SALARY PER MONTH SAL_AMT FROM SALARY;
USE OF RELATIONAL OPERATORS: = , > , < , >= , <= , <>
SELECT * FROM EMPLOYEE WHERE ECODE<>2001;
USE OF LOGICAL OPERATORS: OR / || , AND / && , NOT / !
SELECT * FROM EMPLOYEE WHERE ECODE=2001 OR EMPNAME=RAVI KUMAR;
SELECT * FROM EMPLOYEE WHERE ECODE=2001 AND EMPNAME=RAVI KUMAR;
SELECT * FROM EMPLOYEE WHERE (NOT ECODE=2001);
BETWEEN
SELECT ECODE, EMPNAME FROM SALARY WHERE SAL_AMT BETWEEN 20000 AND 50000;
SELECT ECODE, EMPNAME FROM SALARY WHERE SAL_AMT NOT BETWEEN 20000 AND 50000;
59
IN
SELECT * FROM EMPLOYEE WHERE CITY IN (DELHI,MUMBAI,BANGALORE);
LIKE
SELECT * FROM EMPLOYEE WHERE EMPNAME LIKE A%; -- Starts with A.
SELECT * FROM EMPLOYEE WHERE EMPNAME LIKE ----; -- Exact four characters.
SELECT * FROM EMPLOYEE WHERE EMPNAME LIKE ---%; -- At least three characters.
NULL
SELECT * FROM EMPLOYEE WHERE EMPNAME IS NULL;
ORDER BY
SELECT * FROM EMPLOYEE ORDER BY EMPNAME;
SELECT * FROM SALARY WHERE SAL_AMT >50000 ORDER BY ECODE DESC;
USING ALIAS
SELECT ECODE SAL_AMT*12 ANNUAL SALARY FROM SALARY ORDER BY ANNUAL SALARY
STRING FUNCTION
SELECT CHAR(65); -- To display the character against ASCII CODE 65.
SELECT CONCAT(ECODE, EMPNAME) AS CODENAME FROM EMPLOYEE; -- To merge two
columns.
SELECT RTRIM(EMPNAME) FROM EMPLOYEE; -- Removes space from right side of empname.
SELECT LTRIM(EMPNAME) FROM EMPLOYEE; -- Removes space from left side of empname.
SELECT TRIM(EMPNAME) FROM EMPLOYEE; -- Removes space from both sides of empname.
NUMERIC FUNCTION
SELECT ECODE, MOD(15,6) FROM DUAL; -- display remainder 3.
SELECT MOD(SAL_AMT,1000) FROM SALARY;
SELECT POWER(5,3) FROM DUAL; -- Calculate 5 raise to power 3. i.e.125.
SELECT ROUND(15.193, 1) FROM DUAL; --- Display 15.2 (Round off)
DATE/TIME FUNCTION
CURDATE()/CURRENT)DATE()
SELECT CURDATE(); -- Display system date.
SELECT DATE(2010-04-13 01:02:33); -- Display 2010-04-13 (date only).
SELECT MONTH(2010-04-13); --- Display month only i.e. 04.
SELECT YEAR(2010-04-13); --- Display year only i.e. 2010.
PRACTICE EXERCISES
Consider a database LOANS with the following table:
Table: LoanAccounts
AccNo CustName LoanAmount Installment Intrate StartDate Interest
1 R K Gupta 300000 36 12.00 19-07-2009
2 S P Sharma 500000 48 10.00 22-03-2008
3 K P Jain 300000 36 NULL 08-03-2007
4 M P Yadav 800000 60 10.00 06-12-2008
5 S P Sinha 200000 36 12.50 03-01-2010
6 P Sharma 700000 60 12.50 05-06-2008
7 K S Dhall 500000 48 NULL 05-03-2008
60
Write SQL commands for the tasks 1 to 35 and write the output for the SQL commands 36 to 40:
Create Database and use it
1. Create the database LOANS.
2. Use the database LOANS.
Create Table / Insert Into
3. Create the table LoanAccounts and insert tuples in it.
Simple Select
4. Display the details of all the loans.
5. Display the AccNo, CustName, and LoanAmount of all the loans.
Conditional Select using Where Clause
6. Display the details of all the loans with less than 40 instalments.
7. Display the AccNo and LoanAmount of all the loans started before 01-04-2009.
8. Display the IntRate of all the loans started after 01-04-2009.
Using NULL
9. Display the details of all the loans whose rate of interest is NULL.
10. Display the details of all the loans whose rate of interest is not NULL.
Using DISTINCT Clause
11. Display the amounts of various loans from the table LoanAccounts. A loan amount should
appear only once.
12. Display the number of instalments of various loans from the table LoanAccounts. An instalment
should appear only once.
Using Logical Operators (NOT, AND, OR)
13. Display the details of all the loans started after 31-12-2008 for which the number of instalments
are more than 36.
14. Display the CustName and LoanAmount for all the loans which do not have number of
instalments 36.
15. Display the CustName and LoanAmount for all the loans for which the loan amount is less than
500000 or intrate is more than 12.
16. Display the details of all the loans which started in the year 2009.
17. Display the details of all the loans whose LoanAmount is in the range 400000 to 500000.
18. Display the details of all the loans whose rate of interest is in the range 11% to 12%.
Using IN Operator
19. Display the CustName and LoanAmount for all the loans for which the number of instalments
are 24, 36, or 48.
Database transaction - A database transaction is a logical unit of work that must either succeed
or fail in its entirety.
ACID properties of database transaction
Atomicity- Atomicity ensures either all-or-none operations of a transaction are carried out.
Consistency-This property ensures that database remains in a consistent state before the start
of transaction and after the transaction is over.
Isolation-Isolation ensures that executing transaction execution in isolation i.e. is unaware of
other transactions executing concurrently in the system.
Durability-This property ensures that after the successful completion of a transaction i. e when
a transaction COMMITs, the changes made by it to the database persist i.e. remain in the
database irrespective of other failures.
TCL commands supported by SQL:-
SQL supports following TCL commands
BEGIN |START TRANSACTION-Marks the beginning of a transaction
COMMIT - Ends the current transaction by saving database changes and starts a new transaction.
Syntax : COMMIT ;
COMMIT WORK;
ROLLBACK - Ends the current transaction by discarding changes and starts a new transaction.
Syntax : ROLLBACK ;
ROLLBACK WORK;
SAVEPOINT - Defines breakpoints for the transactions to allow partial rollbacks.
Syntax : SAVEPOINT <savepoint-name> ; e.g. SAVEPOINT MARK1;
To rollback the transaction till the bookmark named MARK1, we can write the following:-
ROLLBACK TO SAVEPOINT MARK1;
SET AUTOCOMMIT-Enables or disable the default auto commit mode. By default the autocommit
mode is true or 1.
@@autocommit- This command is used to check the status of autocommit.
63
CHAPTER 15: MORE ON SQL-GROUPING RECORDS AND TABLE JOINS
SQL Aggregate (Group) Function: These function operates on group of rows instead of single
row that is why these functions are known as group or aggregate functions. Some important group
functions are as follows:
TABLE:Student
Rollno Sname Subject Marks grade
001 SUMIT MATHS 95 A
002 SHERRY IP 96 A
003 SUMAN IP 75
004 LALIT HINDI 84 B
005 RAHUL MATHS 88 B
TYPES OF FUNCTIONS:
Single Row Function: It works with a single row at a time. A single row function returns a result for
every row of the queried table
Multiple Row or Group Function: It works with data of multiple rows at a time and returns
aggregate values.
The main difference between these two functions is in the number of rows they act upon.
Grouping Result by using Group By: The GROUP BY clause is used in a select statement in
conjunction with aggregate functions to group the result based on DISTINCT or ALL values in a
column. Grouping can be done by column name, or with aggregate functions in which case the
aggregate produces a value for each group. Example:
Mysql> select count (marks) from student Group By subject;
OUTPUT:
HINDI 1
MATHS 2
IP 2
Mysql> select SUM (marks) from student Group by Subject;
OUTPUT:
HINDI 84
64
MATHS 183
IP 171
Conditions on Group-Having Clause: We can use any condition on group, if required. HAVING
clause is used to apply a condition on a group.
Mysql> select SUM (marks) from student Group By subject having MAX(marks)>80;
OUTPUT:
HINDI 84
MATHS 183
IP 96
Mysql> Select SUM (marks) from student Group By subject having COUNT (*)>1;
OUTPUT:
MATHS 2
IP 2
JOINS: A join is a query that combines rows from two or more tables. In a query involving join,
more than one table is listed in FROM clause separated by comma (,).
EXAMPLE: SELECT * FROM EMP1, DEPT;
CROSS JOIN (Cartesian product): Cartesian product of two tables is a table obtained by pairing each
row of one table with each row of the other. It contains all the columns of both tables.
e.g. mysql > SELECT * FROM Order, product ;
Note:-In final table cardinality will be multiplication of rows of both tables and degree will be
addition of columns of both tables.
Order Product
SN Pcode scode code Name qty
1 P101 S002 P101 SOAP 20
2 P102 S003 P102 OIL 10
(After Cross Join following output will be produced)
SN Pcode scode code Name qty
1 P101 S002 P101 SOAP 20
2 P102 S003 P101 SOAP 20
1 P101 S002 P102 OIL 10
2 P102 S003 P102 OIL 10
This table will contain (2*2=4) rows and (3+3=6) Columns.
EQUI JOINS:
The Joins, in which a column is compared for equality, is called Equi-Join. The Join Column is a
column which is common in both tables.
SQL Statement: mysql> SELECT * FROM Order, product where order.pcode=product.pcode;
(After Equi Join following output will be produced)
SN Pcode scode Pcode Name qty
1 P101 S002 P101 SOAP 20
2 P102 S003 P102 OIL 10
MySQL creates a Cartesian product of the tables; from this Cartesian product MySQL select only
those records for which Pcode of order table matches with code of product table.
65
NON EQUI JOINS:
Non equi join is a query that specifies some relationship other than equality between the columns.
It means that records are joined on the condition other than Equal operator (<,>,<>,>=,<=) for
joining column.
NATURAL JOINS: The join in which one of the identical columns exist, is called Natural Join. The
natural join is much similar to Equi-Join, records are joined on the equality condition of joining
column except that the common column appears one time.
(After Natural Join following output will be produced)
Joining Tables Using Join Clause of SQL Statement: MySQL offer two ways by which you may join
two or more tables. One is using multiple tables with FROM clause and using JOIN keyword with
FROM clause.
Using multiple tables with FROM clause
Select * from Student, Stream where student.scode= stream.scode;
Table: Student Table: Stream
RNO Name Subject Fee Scode
Scode Stream
101 RAM MATHS 1000 S101
S101 Science
102 SHAM ECO 800 C102
C102 Commerce
103 RITU ENG 500 H103
H103 Humanities
104 SHERRY PHY 1200 S101
OUTPUT
RNO Name Subject Fee Scode Stream
101 RAM MATHS 1000 S101 Science
102 SHAM ECO 800 C102 Commerce
103 RITU ENG 500 H103 Humanities
104 SHERRY PHY 1200 S101 Science
66
UNION:-The UNION operator is used to combine the result-set of two or more SELECT statements.
Notice that each SELECT statement within the UNION must have the same number of columns. The
columns must also have similar data types. Also, the columns in each SELECT statement must be in
the same order.
Syntax : UNION
Note: The UNION operator selects only distinct values by default. To allow duplicate values, use the
ALL keyword with UNION.
Note: The column names in the result-set of a UNION are usually equal to the column names in the
first SELECT statement in the UNION. The number of Columns must be same In both the tables.
SELECT * FROM a;
+------+------+
|x|y|
+------+------+
|1|A|
|2|B|
|3|C|
|4|D|
+------+------+
SELECT * FROM b;
+------+------+
|x|y|
+------+------+
|1|A|
|3|C|
+------+------+
Union:
SELECT * FROM a UNION SELECT * FROM b;
+------+------+
|x|y|
+------+------+
|1|A|
67
|2|B|
|3|C|
|4|D|
+------+------+
INTERSECTION
First, let's explain what an INTERSECT query is. An INTERSECT query returns the intersection of 2 or
more data sets. If a record exists in both data sets, it will be included in the INTERSECT results.
However, if a record exists in one data set and not in the other, it will be omitted from the
INTERSECT results.
Intersect Query
Explanation: The INTERSECT query will return the records in the shaded area. These are the records
that exist in both Dataset1 and Dataset2.
68
Although there is no INTERSECT operator in MySQL, you can easily simulate this type of query using
either the IN clause or the EXISTS clause, depending on the complexity of the INTERSECT query.
69
Short Answer Type Question (2 Marks)
1. Difference between WHERE and HAVING clause in MySQL? Explain with the help of an example.
2. Consider the tables Doctors and Patient given below:
TABLE: DOCTORS
DocID DocName Department OPDdays
101 K.K.Mathur ENT TTS
102 Ashish Sharma Paed MWF
201 Vivek Khurana Ortho MWF
TABLE: PATIENT
PatNo PatName Department DocID
1 AKASH ENT 101
2 NEHA Ortho 102
3 SUNITA ENT 101
3. With reference to these two tables, write a SQL query for (i) and (ii) and output for (iii).
(1) Display Patient Name, Patient No and corresponding doctor name for each patient.
(2) Display the list of all patients whos OPDdays are TTS.
(3) SELECT OPDdays, count(*) FROM Doctors, Patients WHERE
Doctors.Department=Patients.Department GROUP BY OPDdays;
4. In a database there are two table BOOKS and ISSUES.
Table: BOOKS
Book_ID Book_Name Author_Name Publisher Price Qty
L01 Maths Raman ABC 70 20
L02 Science Agarkar DEF 90 15
L03 Social Suresh XYZ 85 30
L04 Computer Sumita ABC 75 7
L05 Telugu Nannayya DEF 60 25
L06 English Wordsworth DEF 55 12
Table: ISSUES
ISSUE_ID Book_ID Qty_Issued
14 L02 13
19 L04 5
3 L05 21
i. How many rows and how many columns will be there in the Cartesian product of these two
tables?
ii. Which column in the 'ISSUES' table is the foreign key?
5. Consider the table staff and salary given below:-
Table: staff Table: Salary
6. With reference to these tables, Write commands in SQL for (i) and (ii) and output for (iii) below:
i. Display NAME, BASIC, ALLOWANCE of all staff who are in SALES department
ii. Display the average salary of all the staff working in FINANCE department
using the table staff and salary. SALARY=BASIC+ALLOWANCE.
iii. SELECT NAME, COMM FROM staff, salary where (staff.ID=salary.ID);
71
Lesson 16: Table and Integrity Constraints
Integrity Constraints are the rules that a database must follow at all times. Various Integrity
constraints are as follows:-
1. Not Null: It ensures that we cannot leave a column as null i.e. a value has to be supplied for
that column.
2. Unique: Ensures that each row for a column must have a unique value. A column(s) can have
null value but the values cannot be duplicated.
3. Primary key: - Primary key is used to identify the record uniquely in the table. A combination
of a NOT NULL and UNIQUE means that a column cannot have duplicated values and not even
a null value.
4. Default: Specifies a default value for a column. If no value is specified while inserting records
then default value will be inserted.
5. Check: Ensures that the value in a column meets a specific condition. It is used to limit the range
of values that can be inputted in to a column
6. Foreign Key: Ensure the referential integrity of the data in one table to match values in another
table
DEFAULT
Create Table with Constraints: You can create table with constraints using create table.
Constraints can be added at the time of table creation or can be added later on. For example:
CREATE TABLE Student
(
RollNo Integer Primary Key,
Regno Integer Unique,
NAME Char(20), Not Null,
Gender Char(1),
Age Integer Check age>=5,
Admfee integer Default 5000
);
Alter Table
The purpose of alter table are as follows:-
72
1. Adding Column to a table: To add a new column to a table, you can use ALTER TABLE
command as per syntax given below:-
ALTER TABLE <Table Name>
ADD [COLUMN] <Column data Type> ;
ALTER TABLE EMPLOYEE
ADD MOBILE_NO INTEGER;
A new column by the name Mobile_No will be added to the table
2. Deleting Column: To delete a column from the table, the DROP command as per syntax
given below:-
ALTER TABLE <Table Name>
DROP [COLUMN]<Column Name> ;
ALTER TABLE EMPLOYEE
DROP [COLUMN] MOBILE_NO;
It will delete the column MOBILE_NO from the table EMPLOYEE
3. Modifying Data Type(s) of a column(s): To modify a column of a table, you can use MODIFY
command as per syntax given below:-
ALTER TABLE <Table Name>
MODIFY <Column Name> <Column Definition>;
ALTER TABLE EMPLOYEE
MODIFY SALARY INTEGER(8);
It will change the width of a salary field from 5 to 8
To modify a column of a table with constraints:
ALTER TABLE <Table Name>
MODIFY <Column Name>
<Column Definition> constraints
ALTER TABLE EMPLOYEE
MODIFY EMP_NO INTEGER (10) PRIMARY KEY;
It will modify the EMP_NO and EMP_NO is now working as primary key
4. Adding Constraints: You can also use ALTER TABLE command to add constraints to your
existing table.
Syntax:
ALTER TABLE <Table Name>
ADD <Constraint name>(column name)
ALTER TABLE EMPLOYEE
ADD PRIMARY KEY (EMP_ID);
It will define the EMP_ID as primary key
Removing Constraints: You can also use ALTER TABLE command to delete or remove constraints
from your existing table
Syntax:
ALTER TABLE <Table Name>
DROP <Constraint Name>
ALTER TABLE EMPLOYEE
DROP PRIMARY KEY;
It will delete the primary key constraint of a table
73
Enabling/Disabling Constraints: You can enable or disable constraints, but only primary key
constraint cannot be disabled, it can only be deleted. Other constraints like Foreign Key, Not Null
etc. can de enabled or disabled.
Syntax TO ENABLE:
SET FOREIGN_KEY_CHECKS=1;
Syntax TO DISABLE:
SET FOREIGN_KEY_CHECKS=0;
Dropping Tables: To delete or drop tables from database, you can use DROP TABLE COMMAND.
With Drop Table command, My SQL also removes the description of the table along with all
constraints.
Syntax:
DROP TABLE TABLE NAME
DROP TABLE EMPLOYEE;
It will DROP table employee from the database
74
3. What are different constraints? Explain any two with example.
4. Ms. Shilpa created two tables with Deptno as Primary key in Table1 and Foreign Key in
Table2, while inserting a row in Table2, Ms. Shilpa is not able to enter a value in the column
Deptno. What could be the possible reason there for it?
5. Write a MySQL command for creating a table "CLUB" whose structure is given below:
Field Name Datatype Size Constraint
MEMBER_No Integer 10 Primary key
Member_Name Varchar 20
Join_Date Date
Member_Type char 1 Not Null
Charges Decimal 10,2
75
6. Answer the question based on the table VOTER given below:
Column Name Data type Size Constraints Description
V_id INT 8 Primary key Voter identification
Vname VARCHAR 25 Not null Name of the voter
Age INT 3 Check>17 Age should not be less than 17
Address VARCHAR 30 Address of voter
Phone VARCHAR 10 Phone number of the voter
REVISION: Complete the following crossword puzzle using RDBMS (MySQL) concept and
commands:-
2 7
3
6
1
8
10
5
76
UNIT 4
CHAPTER 17: IT APPLICATIONS
Front End: The front end application interacts with the user and collects input from the user. For
example: E-mail sign up form or any application where a user enters data.
Back End: The backend is an application or program that is not visible to the user but that processes
the user requests as received from the front end. The back end handles all database accesses
through one or more servers. For Example: MYSQL, Oracle, MS-Access etc.
Impact of ICT on Society:
ICT stands for (Information and communication Technology). ICT has impacted the society in a
much wider way than any other technologies. The social and economic impacts are as follows:-
Social Impact of ICT on Society:
Social Benefits:
1. Employment Generation
2. Social Networking
3. Education Sector
Economic Benefits:
1. Faster Growth of Economy
2. Global Market
3. Net Banking
4. Ease and Availability
E-Governance: E-governance refers to the application of electronic means in governance with an
aim of fulfilling the requirements of common man at affordable costs and in fastest possible time.
All government services are accessible to common man in his/her locality and ensure efficiency,
transparency and reliability of such services at affordable cost to realize the basic needs of the
common man.
Some popular E-Governance sites in India:-
http:// www. Incometaxindia.gov.in
http:// www.passport.gov.in
http:// www. India.gov.in
Social impact of E-Governance:
1. E-governance improves the efficiency and transparency of administration and service.
2. E-governance reduces waiting time before the work is done.
3. E-governance controls the corruption to some extent.
Some issues that have impacted the Society in a not so positive manner:
1. People living in rural area could not benefit from the E-Governance because of lack of
computerization in these areas.
2. Lack of awareness about E-Governance program among the people.
3. All government services are not online. So manual method cannot be avoided.
E-Commerce/E-Business: E-Commerce describes the process of buying, selling of products,
information and services via computer network using internet
Some popular E-Business sites in India:-
http:// www.irctc.co.in
http:// www.licindia.in
77
http:// www.Amazon.com
Advantages of E-Business to customers:
1. It reduces the cost of the products.
2. Customers can access international market.
3. Improves the customer service by offering 24X7 access to market
Social impact of E- Business:
1. Online availability of various options at remote places also.
2. Increase in online shopping habits.
3. Increase in online payments.
Some issues that have impacted the Society in a not so positive manner
1. Poor telecom, Internet services and infrastructure for reliable connectivity.
2. Lack of trust. Sometimes customers do not receive goods even after online payments up to
their expectations.
E-learning: E-Learning describes as a means of teaching and learning through computer or e-
technology like Internet, CD-ROM, DVD, Audio etc. It provides an opportunity to learn almost
anytime, anywhere.
Some popular E-Learning sites:-
http:// www.w3schools.com
http:// www.exelearning.org
http:// www.cbsecsnip.in
Advantages:
1. Study can be done anytime (24 X 7 hours available) and anywhere
2. It reduces the cost of study.
3. Self-paced and self-motivational learning
Social impact:
1. Boon for working class.
2. It helps the students to continue their studies, who has left out the school for any reason.
3. Availability of the same course to millions.
79
Ans 1. Netbanking 2. e-business 3. GUI 4. List box 5. IRCTC
6. Moodle 7. e-learning 8. e- commerce 9. Frontend 10.Backend
80
CBSE ANNUAL PAPER-2013
INFORMATICS PRACTICES (065)
i) All questions are compulsory
ii) Answer the questions after carefully reading the text.
1 (a) Which wireless communication channel is most appropriate in each of the following 1
situations?
i Communication in a hilly area.
ii Very fast communication between two offices in two different countries.
(b) With what aim UNICODE was developed? 1
(C) Expand the following file extensions: 1
(i) ODF (ii) XML
(d) Give one example of URL and one example of domain name. 1
(e) What is the use of repeater in a Network? How is it different from Hub? 2
(f) Give two characteristics of Star Topology. Also, show it using a diagram with 2
interconnection of 5 computers.
(g) What is Snooping? 2
2 (a) Name method is used to extract value of Index while using ListBox in Java. 1
(b) What is the difference between the use of isSelected() and setSelected() methods 1
used with JCheckBox in Java?
(c) Name any two commonly used methods of jComboBox control. 1
(d) Name any two attributes used in <img> tag of HTML 1
(e) How many times the following loops will execute? Which one of them is Entry 2
Controlled and which one is Exit Controlled?
Loop 1 Loop 2
int j=8, total=0; int j=8,total=0;
while(j>1) do
{ {
total+=j ; total+=j;
j -=2; j-=2;
} }While (j>1);
(f) What will be displayed in jTextField1 and jTextField2 after the execution of the 2
following loop?
int Total =0 ,End=10;
for (int Turn=1,Turn<=End; Turn+=2)
Total++;
jTextField1.setText(Integer.toString(Total));
jTextField2.setText (Integer.toString(Turn));
(g) Differentiate between the <BR> and <HR> tags of HTML with suitable example. 2
3 (a) Write a command to add a NOT NULL constraint on FEES column of a student table 1
(b) Write SQL command to create a SAVEPOINT called AI. 1
(c) Define Foreign Key with reference to RDBMS. 1
(d) Table BANK has 2 rows and 3 columns .Table CUSTOMER has 4 rows and 3 columns. 1
What will be the cardinality and degree of the Cartesian product of them?
81
(e) There is column HOBBY in a Table CONTACTS .The following two statements are 2
giving different outputs. What may be the possible reason?
SELECT COUNT (*) FROM CONTACTS;
SELECT COUNT (HOBBY) FROM CONTACTS;
(f) Name the methods used to convert one type of data to another in the following 2
statement of java.
int Num= Integer.parseInt (jTextField1.getText () );
jTextField2.setText(Integer.toString(Num));
(g) Mr. Tandon is using table EMP with the following columns. 2
ECODE,DEPT,ENAME,SALARY
He wants to display all information of employees (from EMP table) in ascending order
of ENAME and within it in ascending order of DEPT. He wrote the following
command, which did not show the desired output.
SELECT * FROM EMP ORDER BY NAME DESC,DEPT;
Rewrite the above query to get the desired output.
4 (a) What will be the content of jTextArea1 and TextField1 after the execution of the following 2
statements?
i jTextArea1.setText( Go\t Green\n INDIA) ;
ii String Message = All The Best ;
jTextField1.setText(Message.length () -6)+ );
(b) Rewrite the following program code using a while loop statement: 2
int Last= Integer .parseInt(jTextField1.getText ( ) ) ;
for (int C=1; C<=Last; C++)
jTextArea1.setText(Integer.toString (C) ) ;
(c) Observe the following code carefully and find which statement will never get 1
executed in the code.
int Count=1; // Statement 1
do // Statement2
{ // Statement3
If (Count <15) // Statement4
jTextField1.setText (Jump) ; // Statement5
else // Statement6
jTextField1.setText (STOP); // Statement7
Count+=4; // Statement8
} // Statement9
while(t<=15); // Statement10
(d) Write java statement to make jButton1 disabled. 1
(e) What will be displayed in jTextField1 after the execution of the following code? 2
int Sum, One=3,Two=5;
Sum =One + Two ++;
jTextField1. setText (Integer.toString(Sum) ) ;
jTextField2.setText (Integer.toString(Two) ) ;
(f) What will be the contents of Text1 and Text2 after the following code is executed? 2
String Text2,Text1 ;
82
Text1= Good Morning ;
Text2 = India ;
Text1=Text2.concat(Text1) ;
(g) Shekhar is a junior programmer at Ducom Enterprises .He created the following GUI
in Netbeans.
84
name of one popular e-Commerce site.
(b) Give two addresses of most commonly used e-learning sites. 1
(c) Shobhit is creating a form for his company .Help her to choose most appropriate
controls from ListBox, Combobox, TextField, TextArea, RadioButton, CheckBox, Label 2
and Command Button for the following entries
S.No Function Control
1 To select citizenship from a list of countries
2 To allow to input grade out of A to D
3 To allow selecting one or many food items
4 To allow entering feedback in the form of a paragraph
85
CBSE ANNUAL PAPER-2014
INFORMATICS PRACTICES
Time allowed: 3 hours Maximum Marks: 70
Instructions:
(i) All questions are compulsory.
(ii) Answer the questions after carefully reading the text
1 (a) Why is switch called an intelligent hub? 1
(b) What was the objective behind developing UNICODE? 1
(c) Expand the following terms : 1
i OSS
ii ODF
(d) What is the use of repeater in a Network? 1
(e) Identify the following device : 2
i A device that is used to connect different types of networks. It performs the
necessary translation so that the connected networks can communicate properly.
ii A device that converts data from digital bit stream into an analog signal and vice
versa
(f) Write one advantage and one disadvantage of using Optical fibre cable. 2
(g) Distinguish between Open Source Software and Proprietary Software. 2
2 (a) Is a string containing a single character same as a char? 1
(b) Write a statement in Java to declare a String type variable with a name City. 1
(c) Distinguish between / and % operators. 1
(d) Which tag / attributes of HTML are used to 1
i Insert a picture in the web page.
ii Insert an empty line in the web page.
(e) What will be the values of variables agg and agg1 after the execution of the following 2
loops?
Loop 1 Loop 2
int a=9,agg=9; int b=9,agg1=0;
while(a>10) do
{ {
agg+=a; agg1+=b;
a=2; b=2;
} } while(b>10);
(f) What will be displayed in jTextArea1 after the execution of the following loop?
for (int I=5;I>=2;I ) 2
jTextArea1.setText(jTextArea1.getText()+ "+Integer.toString(I*I));
(g) Give two attributes of Table element of HTML. 2
3 (a) Distinguish between ALTER TABLE and UPDATE commands of MySQL. 1
(b) Mention two categories in which MySQL commands are broadly classified. 1
( c) Give two characteristics of Primary Key. 1
(d) A table FUNFOOD has 13 rows and 17 columns. What is the cardinality and degree of 1
86
this table?
(e) A numeric column MONEY contains 34567.7896. Write a command to truncate 2
MONEY
i Up to 2 decimal places. (i.e. expected result 34567.78)
ii Up to -3 places. (i.e. expected result 34000)
(f) What happens when ROLLBACK command is issued in a transaction process? 2
(g) Shanya Khanna is using a table Employee. It has the following columns. 2
Admno, Name, Agg, Stream
[column Agg contains Aggregate marks]
She wants to display highest Agg obtained in each Stream.
She wrote the following statement :
SELECT Stream, MAX(Agg) FROM Employee;
But she did not get the desired result. Rewrite the above query with necessary
changes to help her get the desired output.
4 (a) Define Object Oriented Programming. 2
(b) Rewrite the following Java code using a Switch Case statement : 2
int option=Integer.parseInt(jTextField1.getText());
if (option==1)
jTextField2.setText("Regular employee");
else if (option==2)
jTextField2.setText("On Probation");
else if (option==3)
jTextField2.setText("Visiting faculty");
else if (option==4)
jTextField2.setText("On Contract");
else
jTextField2.setText("Invalid option!");
(c) What will be the value X1 after the execution of the following code : 1
String X1="Spread",X2="PEACE";
X1=X2.concat(X1);
(d) Write Java statement to make a jTextfield1 disabled 1
(e) What will be displayed in jTextArea1 after the execution of the following code : 2
int G=1;
do
{
jTextArea1.setText(Integer.toString(G++));
G=G+1;
} while(G<=5);
(f) Give the output of the following Java code : 2
String name="Chennai Express";
int TM=name.length(),TN;
TN=80TM;
87
jTextField2.setText(Integer.toString(TM));
jTextField3.setText(Integer.toString(TN));
(g) Mr. Rangaswami works at a Recreation Park as a system analyst. He has created the
following GUI. When a group arrives at the Recreation Park, the number of people in
the group and whether the group wants to enjoy the Water Park or not is entered.
Entry fees is Rs.500 per person. The person can choose to play at Water Park by
selecting the checkbox. Rides of Water Park will cost Rs. 250 extra per person.
(b) In a Database SAMS and VENDOR are two tables with the following information.
Write MySQL queries for (i) to (iii), based on tables SAMS and VENDOR :
Table : SAMS
ICode IName Price Colour VCode
S001 Refrigerator 20000 Blue P01
S002 Mobile Phone 45000 Black P02
S003 LCD 60000 Silver P03
S004 Washing Machine 12500 Smoke P01
S005 Air Conditioner 16000 White P03
Table : VENDOR
VCode VName
P01 Satish
P02 Manoj
P03 Subodh
P04 Jacob
i To display ICode, IName and VName of all the vendors, who manufacture 2
Refrigerator.
Ii To display IName, ICode, VName and Price of all the products whose price is more 2
than 20000.
iii To display vendor names and names of all items manufactured by vendor whose 2
89
code is P03.
(c) With reference to SAMS table, which column should be set as the Primary key? 2
Which column is the foreign key? Give reasons.
7 (a) Define e-Business. Name one popularly used e-Business website. 1
(b) How does e-governance help in reducing corruption? Write two points. 2
(c) Suruchi works for a Shopping Mart. She wants to create controls on a form for the 2
following operations: Choose most appropriate controls out of TextBox, Label, Radio
Button, List box, Combo box, Check box and Command button.
S.No. Function
1. Enter the Item Code
2. Select Item Size (from a list of sizes)
3. Enter Quantity
4. Submit the Form
90
CBSE ANNUAL PAPER -2015
INFORMATICS PRACTICES
Time allowed: 3 hours Maximum Marks: 70
Instructions:
(i) All questions are compulsory.
(ii) Answer the questions after carefully reading the text.
Outreach
93
(b) Consider the following table named SOFTDRINK. Write commands of SQL for (i) to (iv)
and output for (v) to (vii).
Table : SOFTDRINK
DRINKCODE DNAME PRICE CALORIES
101 Lime and Lemon 20.00 120
102 Apple Drink 18.00 120
103 Nature Nectar 15.00 115
104 Green Mango 15.00 140
105 Aam Panna 20.00 135
106 Mango Juice Bahaar 12.00 150
i To display names and drink codes of those drinks that have more than 120 calories. 1
ii To display drink codes, names and calories of all drinks, in descending order of calories 1
iii To display names and price of drinks that have price in the range 12 to 18 (both 12 and 18 1
included).
iv Increase the price of all drinks in the given table by 10%. 1
v SELECT COUNT(DISTINCT(PRICE)) FROM SOFTDRINK; 1
vi SELECT MAX (CALORIES) FROM SOFTDRINK; 1
vii SELECT DNAME FROM SOFTDRINK WHERE DNAME LIKE %Mango%; 1
(c) What is the degree and cardinality of SOFTDRINK TABLE? 1
6. Write MySQL command to create the Table LIBRARY with given constraints. 2
(a) Table : LIBRARY
COLUMN_NAME DATATYPE CONSTRAINT
(SIZE)
BookId Int(10) Primary Key
BookName Varchar(40) Not Null
Type Char(4)
Author Varchar(40)
No_Copies Int(6)
Price Decimal(8,2)
(b) In a Database Company, there are two tables given below :
Table : SALES
SALESMANID NAME SALES LOCATIONID
S1 ANITA SINGH ARORA 250000 102
S2 Y.P. SINGH 1300000 101
S3 TINA JAISWAL 1400000 103
S4 GURDEEP SINGH 1250000 102
S5 SIMI FAIZAL 1450000 103
Table : LOCATION
LOCATIONID LOCATIONNAME
94
101 Delhi
102 Mumbai
103 Kolkata
104 Chennai
7. 2
(a) How does e-learning allow students to study at their own pace?
(b) How does e-governance empower citizens? Write one point. 1
(c) Sabeena is creating a form for the hotel where she works. Help her to choose most 2
appropriate controls from ListBox, ComboBox, TextField, TextArea, RadioButton,
Checkbox, Label, and Command Button for the following entries :
S.No. Function
1 To input name
2 To allow enter gender out of M or F
3 To allow selecting type of room out of Deluxe, SemiDeluxe,
General
95
CBSE BOARD PAPER- 2016
INFORMATICS PRACTICES (065)
Time allowed: 3 hours Maximum Marks: 70
1. (a) Two doctors have connected their mobile phones to transfer a picture file of a 2
person suffering from a skin disease. What type of network is formed? Which
communication media out of Coaxial cable, Optical fiber, Bluetooth, Satellite link
should be used to transfer the file ?
(b) State reason why Star topology requires more cable length than Bus topology. 2
(c) Open Source Software developers work for the good of community. Is this 2
statement true? Give reason.
(d) What happens during Domain Name Resolution? 2
(e) How is Denial of service attack, a threat to Network security? 2
2. (a) Identify the odd one out of the following statements. State reason for your choice. 1
(i) switch (ii) do while (iii) while (iv) for
(b) What is the difference between setVisible() and setEnabled() methods? 1
(c) What is the difference between the following statements (i) and (ii)? 1
i a=5;
ii if(a = = 5)
x=3;
(d) Write the output in jTextField1 if depcode is 3. 1
switch (depcode)
{ case 1 : allowance=4000;
break;
case 2 : allowance=3200;
break;
default : allowance=1000;
}
jTextFieldl.setText( " " +allowance);
(e) Sandhya is creating a webpage. She is entering HTML code on her computer. In 2
between, she keeps pressing Refresh / Reload button on her browser. What is the
purpose?
(f) What does XML stand for? How is the purpose of HTML different from XML? 2
(g) Write Java code (statements) to declare Y as integer variable. Then, assign the value 2
30 to a variable Y. Increase the value of Y by 5 and store the increased value in Z.
3. (a) What is MySQL? 1
(b) Charvi is inserting Sharma in the LastName column of the Emp table but an 1
error is being displayed. Write the correct SQL statement.
INSERT INTO Emp(Sharma)VALUES(LastName) ;
(c) Kunal created the following table with the name Friends : 1
Table : Friends
FriendCode Name Hobbies
F101 Bijoy Swimming
96
F102 Abhinav Reading books
F103 Jyotsna Dancing
Now, Kunal wants to delete the Hobbies column. Write the MySQL statement.
(d) Mrs. Sen entered the following SQL statement to display all Salespersons of the 1
cities Chennai and Mumbai from the table Sales.
Table : Sales
Scode Name City
101 Aakriti Mumbai
102 Aman Chennai
103 Banit Delhi
104 Fauzia Mumbai
SELECT * FROM Sales WHERE City=Chennai AND City=Mumbai;
Rewrite the correct statement, if wrong or write statement is correct.
(e) i Name two Aggregate (Group) functions of SQL. 1
ii Consider the table : Table : Company 1
SID SALES
S101 20000
S103 NULL
S104 10000
S105 15000
What output will be displayed by the following SQL statement?
SELECT AVG(SALES) FROM Company;
(f) Given below is the Stu table: 2
RNO NAME
1 Amit
2 Bhishm
The following statements are entered :
SET AUTOCOMMIT = 0;
INSERT INTO Stu VALUES(5, Rahul);
COMMIT;
UPDATE Stu set name=Rahuliya where Rno= 5;
SAVEPOINT A;
INSERT INTO Stu VALUES(6, Cristina);
SAVEPOINT B;
INSERT INTO Stu VALUES(7, Fauzia);
SAVEPOINT C;
ROLLBACK TO B;
Now what will be the output of the following statement?
SELECT * FROM Stu;
(g) Consider the table Hotel given below : 2
97
Table : Hotel
EMPID Category Salary
E101 MANAGER 60000
E102 EXECUTIVE 65000
E103 CLERK 40000
E104 MANAGER 62000
E105 EXECUTIVE 50000
E106 CLERK 35000
Mr. Vinay wanted to display average salary of each Category. He entered the
following SQL statement. Identify error(s) and Rewrite the correct SQL statement.
SELECT Category, Salary FROM Hotel GROUP BY Category;
4. (a) When is if-else if statement preferred over switch statement? 1
(b) What is the purpose of break statement? 1
(c) What will be displayed in jTextField1 and jTextField2 after the following code is 2
executed:
int t;
int s;
s = 2;
t = (4*s++)/2;
jTextField1.setText( +t);
jTextField2.setText( +s);
(d) Write the contents of jTextField1, jTextField2, jTextField3 and jTextField4 when the 2
following statements are executed:
String x;
String str = Java;
x = str.concat (study);
double a = 7.8765;
jTextField1.setText (x.length()+ );
jTextField2.setText (x.toUpperCase () );
jTextField3.setText (x.substring (2,5));
jTextField4.setText (Math.round(7.8765)+ );
(e) Rewrite the following code using WHILE loop : 2
int sum = 0;
for(int i=9; i>=1; i--)
{
if(i%3==0)
sum=sum+i;
else
sum=sum i;
}
(f) The following code has error(s). Rewrite the correct code underlining all the 2
corrections made :
98
int x=10;
int y=50;
do;
{
x+5=x;
y5=y;
while(x<=y);
(g) Vijay has developed software for planning personal budget. A screenshot of the same
is shown below :
Total Income, Expenses of Bills (Water/Electricity), Groceries, Entertainment, other
expenses and whether money is to be sent to Hostel are entered by the user. Sum of
Expenses, Grand Total of Expenses and Savings are calculated and displayed by the
program. Write the code to do the following :
i When CALCULATE button is clicked, Sum of Expenses, Total Expenses and Savings 3
should be calculated and displayed in appropriate text fields.
Sum of Expenses is calculated by adding expenses on Bills (Water/Electricity),
Groceries, entertainment and other expenses.
Grand Total of Expenses is calculated according to the following criteria :
If Money to be sent to Hostel checkbox is selected, 3000.00 is to be added to the
sum of expenses. If it is not selected, Grand Total of Expenses is the same as sum
of expenses.
Savings = Total Income Grand Total of Expenses.
ii When CLEAR button is clicked, all text fields and checkbox should be cleared. 1
iii When CLOSE button is clicked, the application should close. 1
5. (a) Anita has created the following table with the name Order.
Table : Order
Column Name Constraint
OrderId Primary Key
OrderDate Not Null
99
OrderAmount
StoreId
One of the rows inserted is as follows :
OrderId OrderDate OrderAmount StoreId
O101 2015-02-12 34000 S104
i What is the data type of columns OrderId and OrderDate in the table Order? 1
ii Anita is now trying to insert the following row : 1
OrderId OrderDate OrderAmount StoreId
O102 NULL 59000 S105
Will she be able to successfully insert it? Give reason.
(b) Write the output of the following SQL queries: 2
i SELECT MID(BoardExamination,2,4);
ii SELECT ROUND(67.246,2);
iii SELECT INSTR(INFORMATION FORM,FOR);
iv SELECT DAYOFYEAR(2015-01-10);
(c) Write commands in SQL for (i) to (iv) and output for (v) and (vi).
Table : Store
StoreId Name Location City NoOfEmp DateOpened SalesAm
loyees ount
S101 Planetfashion KarolBagh Delhi 7 2015-10-16 300000
S102 Trends Nehru Nagar Mumbai 11 2015-08-09 400000
S103 Vogue Vikas Vihar Delhi 10 2015-06-27 200000
S104 Superfashion Defence Colony Delhi 8 2015-02-18 450000
S105 Rage Bandra Mumbai 5 2015-09-22 600000
100
EventDate Date
101
(c) Ms. Arora is creating a form for accepting Visa applications. Help her to choose 2
most appropriate controls out of ListBox, ComboBox, TextField, TextArea,
RadioButton, CheckBox, Label and CommandButton for the following entries:
S. NO. Function
1. To enter EMAIL ID
2. To choose GENDER
3. To enter NATIONALITY from countries given as options.
4. To enter REMARKS in the form of a paragraph about the purpose of visit.
102
Solved Sample Paper
SUB: INFORMATICS PRACTICES (065)
Q1
(a) Ms. Pooja is interested in transferring song. Suggest two suitable wireless options she 1
may use for doing the same.
(b) Surjit wants to upload/download files from/to a remote internet server. Write the name of 1
the relevant communication protocol, which will let him do the same
(c) It is technology on computer networks whose purpose is to prevent unwanted networking 1
connection according to some filtering/blocking rules. What is it?
(d) Which of the following are open standards? 1
1) .ogg (2) .doc (3) .ttf (4) . jpeg
(e) What is DoS (Denial of Service)? Explain briefly. 2
(f) Differentiate between Dedicated and Non-dedicated server. 2
(g) List out any four advantages of Open Standards. 2
Q2
(a) Which property of jLabel swing control is used to specify the image during design time? 1
(b) Which statement is used to terminate the loop before its maturity? 1
(c) Which HTML tag and corresponding attributes are used to establish default font size for 1
entire page?
(d) What is the difference between <UL> and <OL> tag? 1
Write the output of:
int a=1,b=2;
if( + + b <5)
(e) { 2
a*=b;
}
System.out.println("a="+a+"b="+b);
(f) Write a program in java that reads 2 integers and displays their sum in JOptionPane. 2
(g) Write 4 features of XML. 2
Q3
(a) Mr. Ganesh wants to give moderation of 5 marks to all students those have below 30 marks. 1
Name the command for this purpose.
Correct the following SQL command
(b) SELECT stdname FROM STUDENT 1
WHERE stdname=NULL;
(c) Which commands in MySql is used to make any Database current Database and see the list 1
of tables in that data base?
103
(d) A table ACCOUNT has 5 columns and 3 rows. 3 more rows are inserting into the table and 2 1
columns get deleted. What is the degree and cardinality of the table?
(e)
ItemName Price Qty
Bat 500 5
Chair 2000 10
Table 5000 6
Based on the given information find the output of the following Queries
i Select count (*) from ITEM where price >=2000. 1
ii Select avg( price * Qty) from ITEM 1
f) Differentiate between Primary key and Unique key? 2
g) What are important transaction properties? 2
Q4
(a) ABC Sales Enterprise wants developed software to make the bill for their customer.
GUI for the application given below.
104
Sales Amount Discount
>=5000 5
>=3000` 3
>=1000 1
iii Write the statement to clear all text fields when clicking the clear button 1
iv Write the java statement for the exit button to close the application. 1
105
(a) Explain the purpose of DDL and DML statement. Give two examples of each. 2
(b) Write the output of the following SQL queries. 2
i SELECT INSTR(CORPORATE FLOOR,OR);
ii SELECT MID(Welcome,3,4);
iii SELECT SIGN(-15);
iv SELECT ROUND(15.193,1);
c) Write the SQL command for the following on the basis of given table 6
Table : Company
Table : Model
With reference to these two tables, write a SQL query for (i) and (ii) and output for (iii).
I Display Patient Name, Patient No and corresponding doctor name for each patient 2
107
Ii Display the list of all patients whos OPD_days are TTS. 2
iii SELECT OPD_days,count(*) FROM Doctors,Patients 2
WHERE Doctors.Department=Patients.Department GROUP BY OPD_days;
Q7
(a) What is Back end? Explain its functions. 1
(b) How has our society benefited from E-commerce? Mention any two points? 2
(c) What controls would you suggest for following types of inputs? 2
I To display some information
Ii Enter password
Iii To choose more than one subject from a set of subjects
iv To enter multiline text
108
MARKING SCHEME
1.
b) 9,5
8,6 mark each line of correct output.
(c) What will be the content of jTextField1 after executing the following
110
statement? jTextField1.setText(Informatics.subString(2,5));
Output: forma 1 mark for correct output.
(d) Rewrite the following program code using if else if
if (ch==a)
System.out.println(It is a.);
else if (ch==b)
System.out.println(It is b.);
else if (ch==c)
System.out.println(It is c.); 2 mark for correct conversion
(e) Find the error in the following code and correct it. Underline the
correction.
do {
System.out.println
(i++); }
while (i=<10)
Initial value of i missing
System.out.println(i++);
while (i<=10)
semicolon missing mark for each error
f) Rewrite the following program code using do while loop
int i=1, sum=0;
while(i<15)
{ sum+=i;
i+=2;
}
Ans: int i=1, sum=0;
do
{ sum+=i;
i+=2;
}while(i<5);
g. What will be the contents of JTextField1 and JTextField2 after executing the
following code
jTextField1.setText(Math.round(2.5)+"");
jTextField2.setText("Micro".concat("System"));
Output: 3, MicroSystem
1 mark for each correct answer.
5
a) DDL Data Definition Language , Create table, Alter table etc ( ( 1
Mark) DML Data Manipulation Language, Delete, Insert, Update
( 1 Mark)
b) (i) 2
(ii) lcom
(iii) -1
(iv) 15.2
111
( Mark for each correct answer)
c) i) Select * from TEACHER where Department =History;
(ii) Select Name from TEACHER where Sex=F and department =Maths;
(iii) Select name from TEACHER ORDER BY DateOfAdm ASC;
iv) Insert into TEACHER values(17,Harish,26,History,13/05/95,23000,M)
( 1 Mark for each correct statement )
v) a) 3
b) 35
c) 23600
d) NULL or no output
( Mark for each correct answer)
Que :6
a) CREATE TABLE COACH
(PCode integer primary key, Name varchar(20) NOT NULL, ACode
integer , Foreign Key(Acode) references Activity(Acode) );
( FOR CORRECT QUERY SYNTAX 1 MARK & CONDITION 1 MARK )
b) (1) ModelID primary in Model table & CompId primary in Company table {
each correct one mark}
(2) In CompId column of Model table consists a row value 4 which is not in
defined in company table
(Parent table) ( 1 mark)
c) (1) SELECT PatName, PatNo, DocName FROM DOCTORS,PATIENTS
WHERE DOCTOR.DOCID=PATIENT.DOCID;
(2) SELECT * FROM PATIENTS
WHERE DOCTOR.DOCID=PATIENT.DOCID
AND OPD_Days=TTS;
(3) Output :
OPD_days Count(*)
TTS 2
MWF 3
7. a) What is Back end? Explain its functions
Software used for storing huge amount of data. It can manipulate the data inside the
database in an efficient manner. Ex. MySql
1 mark for each valid point
b) How has our society benefited from E-Commerce? Mention any two points.
1 marks each for writing any 2 benefits of E-Commerce.
(c ) What controls would you suggest for following types of inputs ?
(i) To display some information - Text Field
(ii) Enter password - Password field
(iii)To choose more than one subject from a set of subjects. List box
(iv)To enter multiline text Text Area 1/2 mark each for correct control
112
PREPARATION FOR EXAMINATION
1. Write down how many exams you have and the days on which you have to sit them. Then
organize your study accordingly.
2. Organize your study space and make sure you feel as comfortable and able to focus as
possible.
3. Use flowcharts and Diagrams and condense your revision notes into one-page diagrams.
4. One of the most effective ways to prepare for exams is to practice on old papers.
5. Explain your answers with peer group and clear your doubts with the help of teachers.
6. Students should let go off the cramming part as it is not a good method of studying. Instead
of this, they should make short notes while studying.
7. Studies have shown that for long-term retention of knowledge, taking regular breaks really
helps.
8. Plan your exam well in advance and make sure you get everything ready well in advance of
the exam - don't leave it to the day before to suddenly realize you don't know the way, or
what you're supposed to bring. Check all the rules and requirements, and plan your route
and journey time. If possible, do a test run of the trip; if not, write down clear directions.
9. What you eat can really have an impact on energy levels and focus. Keep your body and
brain well-fueled by choosing nutritious foods. Drink a lot of water.
10. When students write neatly and present their answer sheet in a proper way, they have
more chances of securing high marks.
113