Вы находитесь на странице: 1из 124

Class - XII: INFORMATICS PRACTICES

MYSQL
&

JAVA
ASSIGNMENTS & PROPER NOTES
(Class - XII: INFORMATICS PRACTICES)

SYLL ABUS
Chapter:
Computer Networking
Open Source Concepts
My SQL Revision Tour
Database Transactions
More on SQL – Grouping Records and Table Joins
Tables and Integrity Constraints
IT Applications
Java GUI Programming Revision Tour – I
Java GUI Programming Revision Tour – II
Mid Term Syllabus
Java GUI Programming Revision Tour – III
More About Classes and Libraries
Concept of Inheritance
GUI Dialogs and Tables
Database Connectivity of My SQL
Web Application Development
HTML- I Basic HTML Elements
HTML 2 – Lists, Tables and Forms
Pre Board 1 Syllabus
XML-eXtensible Markup language.
Theory
Unit No. Name Marks
1. Networking and Open Standards 10
2. Programming 25
3. Relational Database Management System 30
4. IT Applications 05
Total 70

Practical :
(i) Hands on experience 15
(ii) Records / Practical File 5
(iii) Project 5
(iv) Viva 5
Total 30

Suggested Reading :
Informatics Practices by Sumitra Arora
Informatics Practices by Reeta Sahoo and Gagan Sahoo

2
(Class - XII: INFORMATICS PRACTICES)

I N FO R MATI CS P RACT I CES MO DU L ES

Module 12 (IP) – 01 (March)


Chapter: Computer Networking, Open Source Concepts.
Contents: What is a Network? Need for Networking, Elementary Terminology of
Networks, Domain Name Resolution, Network Topologies, Type of
Networks, Transmission Media, Network Devices, Network Security,
Introduction to Open Source Based Software, Types of Standards, Common
Open Standard Formats.

Learning Objectives: Student will learn about computer networks briefly, associated
terminology and related concepts along with a brief discussion
on network security.

Keywords:- Resource Sharing, Nodes, Domain Name, topologies, MAN, WAN, LAN,
PAN, Modem, Switch, Router, Firewall, OSS, FLOSS, GNU, Freeware.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Module 12 (IP)
Chapter: My SQL Revision Tour, Database Transactions, More on SQL – Grouping
Records and Table Joins.

Contents: Different Data Models, Relational Model Terminology, Introduction to My


SQL, Starting MySQL, MySQL and SQL, Accessing Database in MySQL,
Creating Tables in MySQL, Inserting Data into Table, Concept of Database
Transaction, Aggregate Function, Types of SQL Functions, Group By, Joins.

Learning Objective: Students will revise the concept of SQL. They will learn about
various database transaction. To write SQL programs to
interact with database.

Keywords: Relation, Table, Domain, Create, Alter, Delete, Drop, Rollback, Begin,
Commit, Savepoint, Having, Group By, Join, Change.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Module 12 (IP) -03 (May)
Chapter: IT Applications, Java GUI programming Revision Tour I, Java GUI
programming Revision Tour – II, Java GUI programming Revision Tour – III.

3
(Class - XII: INFORMATICS PRACTICES)

Contents: E-Governance, E-Business, E-learning, GUI and Its Importance, Front–End


Interface, Backend Database, Front–End and Database Connectivity, Rapid
Application Development, IDE Environment Basics of GUI, Java GUI
Toolkit, Java Character Set, Tokens, Data Types, Variables, Operators in
Java, Expressions, Java Statements, Programming Constructs,
Understanding Swing Components, Starting GUI programming Classes and
Objects, Methods, Scope, Constructors, The this object, OO Terminology.

Learning Objective: Students will learn about various features of IT application such
as front end, back end along with briefly revising the concepts
of IT applications, students will also revise the concepts of Java
GUI Programming using IDE, classes, objects and methods.

Keywords: Class, Object, Scope, this, Formal Parameter, Constructor, Combo Box, List
Box, Radio Buttons.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Module 12 (IP) -04 (July)
Chapter: More About Classes and Libraries, Concept Of Inheritance.

Contents: Controlling Access to Members of a Class – Access Specifies, Java Libraries,


Working with Strings, Using Math Library, Packages, Need and Form of
Inheritance, Derived and Base Classes, Function Overloading, Contructors,
Interfaces.

Learning Objective: Students will be learning about the way access of members of a
class is controlled in Java i.e. about specifiers. They will even
learn about packages and library classes. Students will also
learn about inheritance – the capability of one class to derive
properties from another class.

Keywords: Private, Public, Protected, Default, Abstract Class, Base Class, Derived Class,
Access Specifier, Java Package, Java Language.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Module 12 (IP) -05 (August)
Chapter: GUI Dialogs and Tables, Database connectivity to MySQL.

Contents: Dialogs in Java, Tables, Classes used for Database Connectivity, Prequisities
for connecting to MySQL from Java, Connecting to MySQL from Java.
Learning Objective: Students will learn about how to create dialogs in Java swing
through Net Beans IDE and how to use GUI Table control

4
(Class - XII: INFORMATICS PRACTICES)

JTable. They will also learn how to connect database in a Java


based application.

Keywords: JDialog, JOptionPane, JFileChooser, ShowInputDialog(),


ShowconfirmDialog(), ShowoptionDialog(), ODBC, ExecuteQuery, Close().

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Module 12 (IP) -06 (September)
Chapter: Web Application Development, HTML – I : Basic HTML Elements.

Contents: Web Browsers and Web Servers, Communicating with Web Servers, HTML
and its Capabilities, Writing HTML Documents, Container and Empty
Elements, HTML Tag Structures, Basic HTML Tags, Logical and Physical
Text Styles, Special Characters.

Learning Objective: Students will learn about some basics related to web –
application development and client – server architecture. They
will also learn about basics of HTML.

Keywords: Hypertext, HTTP, Server, URL, Web Browser, Website, WWW, Tag,
Attribute, Container Element, Empty Element.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(October – November)
Chapter: HTML – II : Lists, Tables and Forms.

Contents: Lists in HTML, Table, HTML Forms, Controls, Form Submission.

Learning Objective: Students will learn how to create HTML lists, tables and forms
using HTML tags.

Keywords: Definition Lists, HTML Table, Numbered Lists, Ordered Lists, Unnumbered
Lists, Unordered Lists, Forms.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(December)
Chapter: XML – eXtensible Markup Language.

Contents: What is XML? XML versus other Technologies, Features of DML, Working in
XML, Logical Structure of XML Document, XML Document Categories,
Validating XML Documents.

5
(Class - XII: INFORMATICS PRACTICES)

Learning Objective: Students will learn about what XML is? How it is beneficial and
how one can work in it.

Keywords: Attribute, Document Element, DTD Document Type Definition, Element,


Markup – Language, Prolog, Root Element, Valid Documents, Well-Formed
Document.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
=============================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

6
(Class - XII: INFORMATICS PRACTICES)

ASSIGNMENTS
COMPUTER NE T WORKING

Q.1. Define the following terms :


(i) Node
(ii) Workstation
(iii) Server
Q.2. What are the uses of microwave signals?
Q.3. Define the following :

(i) Bandwidth (iii) Switch


(ii) Hub (iv) Modem
Q.4. What is the difference between LAN and MAN?
Q.5. What is a communication channel? What choices do you have while choosing a
communication channel for a network?

Q.6. Why do we need to network our systems?


Q.7. Write the two advantages and two disadvantages of the following topologies in a
network
(i) Bus Topology (iii) Ring Topology
(ii) Star Topology (iv) Tree Topology
Q.8. Differentiate between :
(i) Gateway and Bridge (ii) Repeater and Routers

Q.9. A company want to form a network on their six computers to a server within the
company premises. Represent STAR and RING topologies diagrammatically for the
above network.

Q.10. A school would like to go in for network of all the computers, which topology
would you recommend and why?

Q.11. Name the network topology in which there are bi-directional links between each
possible node?

Q.12. Give two major reasons to have network security.

Q.13. What is the use IP over data transmission?

Q.14. Compare coaxial and optical fibre cable.


Q.15. What is snooping?

Q.16. ABC organization has set up its new center Mangalore for its office and web based
activities. It has 4 blocks of building as shown in the diagram below.

7
(Class - XII: INFORMATICS PRACTICES)

A B

C D

Centre to centre distances between various blocks :

C to D 25 m
A to D 170 m
B to D 125 m
A to D 90 m
Number of computers
A 25
B 50
C 125
D 10
(i) Suggest a cable layout of connections between the centres.
(ii) Suggest the most suitable place (i.e. block) to house the server of this
organization with suitable reasons.
(iii) Suggest the placement of the following devices with justification.
(a) Repeater (b) Hub/Switch
(iv) The organization is planning to link its front office situated in the city in a
hilly region where cable connection is not feasible, suggest an economic way
to connect it with reasonable high speed.

O PE N SO URCE CO NCE PT S
Q.1. Differentiate between :
(i) Free Software and Open Source Software
(ii) OSS and FLOSS
(iii) FSF and OSI
(iv) Freeware and Shareware
(v) Proprietary Standards and Open Standards
(vi) True Type Font and Open Type Font
Q.2. Write the components of Mozilla software suite.
Q.3. Name the platform on which MySQL can work.
Q.4. What is UNICODE?

8
(Class - XII: INFORMATICS PRACTICES)

Q.5. List few sites supporting open source software.


Q.6. Name few application software which are free software.
Q.7. What is W3C?
Q.8. What is GNU operating System?
Q.9. Write the purpose of the PHP.
Q.10. Specify the usage of following softwares :
(i) Mozilla
(ii) Apache
(iii) Linux
(iv) Tomcat
Java GUI Programming Revision Tour - I
Q.1. Write a single line declaration for the following:
(i) Declare X and Y as an integer.
(ii) Declare Student Name as string variable.
(iii) Declare Fact as single–precision constant whose value is 1.89.
(iv) Declare city as a string variable whose value is “Delhi”.
(v) Explicitly declare the variables j and num of type integer.
(vi) Assign “Hello” to the Label Greeting.
(vii) Calculate the remainder after total is divided by count and assign the result
to r.

Q.2. Identify the errors in the following statement:


(i) Int x; y; z;
(ii) System.out(“Hello World”)
(iii) It.passeInteger(strclass);
(iv) Age int;
(v) Result set.Text(res);
Q.3. Write the statement for the following :
(i) Calculate the area of rectangle.
(ii) Print the message “Printing the result”.
(iii) Compute the Integer average of the three Integers contained in variable x, y
and z, and assign the result to the Integer variable avg.
(iv) Print on the frame “The sum is” followed by the value of the Integer variable
sum.

Q.4. State the order of evaluation of the operators in each of the following statements,
and show the value result after each statement is performed. Assume result to be
an integer variable.

9
(Class - XII: INFORMATICS PRACTICES)

(i) Result = 7 + 3 * 6 / 2 – 1
(ii) Result = 2 % 2 + 2 * 2 – 2 / 2
(iii) Result = 10 % 3 ^ 1 ^ 2 – 8

Q.5. If the length and breadth of a rectangle is 12 and 20, write a program to find the
area using Print statement.
Q.6. Write program statements to assign four marks and print total and percentage using
Print statement.
Q.7. Suppose, in your class there are 60 students out of which 20 are girls. What
percentage of students are girls & what percentage is of boys?
Q.8. A water tank contains 400 litres of water. You take 120 litres of water out of it.
Write a program to calculate the percentage decrease in the amount of water.
Note: Decrease % = (Decrease / Original value) * 100%
Q.9. Answer the following:
(i) Suppose a print statement includes six output values, separated by commas.
How can the statement be rewritten so the outputs values appear on the
same line?
(ii) Assign the value of the variable „number 1‟ to variable „total‟.
(iii) Assign the sum of the two variables loop_count and petrol_cost to the
variable sum.
(iv) Divide the variable total by the value 10 and leave the result in the variable
discount.
(v) Assign the character W to the char variable letter.
(vi) Assign the result of dividing the integer variable sum by 3 into the float
variable costing.
(vii) Use a statement to print out the value of the integer variable sum.
(viii) Use a statement to print out the character variable letter.
Q.10. What value will be stored in different variable when the following JAVA statements
are executed?
int I = 10;
int J, K, m;
J = I + 5;
K = I J/5;
I = L + I;
m = I + I – I;
n = L + m * I;
Q.11. Is the line given below is a valid comment?
„This is a‟ valid comment
Q.12. Write a GUI application to display first 12 numbers into JText Area using while
condition.

10
(Class - XII: INFORMATICS PRACTICES)

Q.13. Write a GUI application to list natural numbers till N using for loop. Notice that the
numbers will be added into a JText Area control.
Q.14. Write a GUI application to assign two numbers and find their sum and difference
using switch statement with JRadioButton and Button Group controls.
Q.15. What is a variable?
Q.16. What will be the output of the following statement? System.out.println(“1”+3);
Q.17. What are expressions?
Q.18. State the difference between = and = =.
Q.19. What is Boolean Variable?
Q.20. Why is Java platform independent?
Q.21. Write a statement for each of the following :
(i) Store a number 275 as a string.
(ii) Convert the string to a numeric value.
(iii) Add it to the existing total of 500 to update the total.
Q.22. If a=5, b=9, calculate the value of :
X=a++-++b+a
Q.23. Write an equivalent Java Statement for the given expression :
A= 0.06-2y2
x-y
Q.24. Identify and correct the errors in each of the following :
if (Gender==1)
jLabel1.settext(“Woman”);
else;
jLable1.settext(“Man”).
Q.25. Convert the following segment into equivalent for loop :
int I=0;
white(I<= 20){
System.out.Println(“Hello”):
I++;
}
}

Q.26. Consider the following program code and tell how many time the loop will execute:
int x=5, y=50;
While(x<=y)
{
y=y/x;

11
(Class - XII: INFORMATICS PRACTICES)

x=x+5;
}

Q.27. Evaluate the following C++ expressions where a,b,c are integers and d,f are
floating point numbers.
The values are a=5, b=3, d=1.5
(i) c=a(b++)*(--a)
(ii) f=(++b)*b-a
Q.28. What is the difference between selection and repetition?
Q.29. Write a Java Desktop Application to swap two numbers using third variable.
Q.30. Write a program in Java to generate the sum of „n‟ numbers entered by the user.
Q.31. Accept age of twenty students and arrange them in ascending and descending
order on the click event of these respective buttons.
Q.32. Write a program in Java to generate the n multiples of the number entered by the
user.
Q.33. Using nested loops make following patterns:
(i) * (ii) *****
** ****
*** ***
**** **
***** *
(iii) 1 (iv) A
12 AB
123 ABC
1234 ABCD
12345 ABCDE
Q.34. Find the errors and rewrite the corrected code.
(i) A=5
while A<=20{
If A % 2 = 0
Print A
A=A+1
}

(ii) if text.1text<>“Info” then


label1.caption=“wrong”

Q.35. Predict the output:


(i) int I=1

12
(Class - XII: INFORMATICS PRACTICES)

while I<20 {
System.out.println (I*I);
}

(ii) int S = 0
for (I = 1; I<20; I = I + 5)
{
S = S+ I * 2;
I = 1 + I;
}
System.out.println (S, I);

Java GUI Programming Revision Tour - II


Q.1. Write a program to display a message “Welcome to IP” using two buttons Print
and Exit. Note. The user should press the Exit button to exit from the program.
Q.2. Write a program to enter any number of integer values and find their sum, Note.
On every input integer value press the Add command button to find the sum.
Q.3. Write a program to do mathematical operations like addition, subtraction,
multiplication and division of two number and display the result with appropriate
JTextField using JLabel, JTextfield and JButton controls.
Q.4. Write a program displaying Indian states with respective capitals, area (sq. kms)
and languages using JListBox control.
Q.5. Write a program Indian states with respective capitals, area (sq. kms) and
languages using JComboBox control.
Q.6. Write a program to input three different integers using field and print the sum,
average and the product of these numbers. Provide an Exit button to terminate the
program.
Q.7. Write a program that reads the radius of a circle as an integer and prints the circle‟s
diameter, circumference and area on the form.
Q.8. Write a temperature conversion program that converts Fahrenheit temperature to a
Celsius temperature.
Q.9. Write a program to enter the name, roll no and marks of 3 subjects. Calculate the
total and percentage of marks and print a message “You are passed” if percentage
is greater than 40, otherwise print “You are failed”.
Q.10. Create an application in Java, which will combine the message of three JTextField.
Q.11. Create an application using Java with a JTextField control to accept a name from
the user and print “Hello <name>” in a JLabel.
Q.12. Create a JListBox with the following values :

13
(Class - XII: INFORMATICS PRACTICES)

Class Name Class Teacher‟s Name


Class – XIA Ms. Jhulka
Class – XIB Ms. Shastri
Class – XIC Mr. Jain
Class – XID Mr. Tiwari
Write a program to print the class teacher‟s name according to the class, which is
selected from a list box.
Q.13. Create a JComboBox with the following values :
Bus Services Bus Fair
Charted Rs. 15/- for all routes
White Line Rs. 12/- for all routes
Blue Line Rs. 2/- for 5 Kms, Rs. 4/- for 8 kms and Rs. 8 /- for above 8
Kms,
Green Line Rs. 10/- for all routes
State Transport Rs. 0.50/- per Km
Q.14. Write a program to enter the time in minutes and convert it into hours and
minutes.
Q.15. Write a program that inputs three different integers using functions InputBox and
prints the sum, the average, the product, the smallest and the largest of these
numbers on the form using Print. Use only the single-selection version of the
If/Then statement. Provide an exit button to terminate program execution.
Q.16. Write a program to design a form for calculating Addition, Subtraction,
Multiplication and Division using JRadioButtons.
Q.17. Write a Java Program to enter width and height of a rectangle and find the
perimeter and area using JTextField, Label and button control.
Q.18. Create an application in Java having two JTextField on the window. Get the first
name and the last name in the JTextField. On clicking the Show Full name button
the name should be printed in the following format “Mr. First name + Last name”.
Note. Create four options for Mr., Mrs., Miss and Ms.
Q.19. Create an Edit menu with following menu control captions and its property settings
respond to the corresponding keys.
Menu Control Caption Caption Property Access Keys
Cut Cu & t t
Copy C & opy o
Paste & Paste p
Delete De & lete l
Select All Select & All a
Time / Date Time / & Date d

14
(Class - XII: INFORMATICS PRACTICES)

Q.20. Create an application using JButton component to print “Hello Java” in a message
box.
Q.21. Create GUI Application to find sum of two numbers using show message dialog ().
Q.22. Create an application which takes input of first name and last name and on clicking
concatenate button a message should appear by joining first name and last name.
Q.23. What is a container? Name few examples of container.
Q.24. If a string ABC holds a value “456”, then how will you convert it into integer type.
Write the command.
Q.25. What action will happen when we press Enter Key on a JTextField control?
Q.26. Explain getpassword() method.
Q.27. What are the limitation of JTextfield.
Q.28. What does the system exit(0) do when it is attached with a JButton Control?
Q.29. Create a Java application to enter your name and address using two textfield
controls. Using a JButtons click event handler, display both name and address in
another JTextField control.
Q.30. Create a GUI application to calculate the simple interest using four JLabel, for
JTextField and two JButton controls input the principlel amount, interest rate and
time periods. Find the interest amount using calculate button
Java GUI Programming Revision Tour – III and More About Classes &
Libraries
Q.1. Create an application to find the volume of a cube using class concept.
Q.2. What are methods?
Q.3. What do you mean by return statement?
Q.4. What is a class?
Q.5. Where can you declare a global variable in an application?
Q.6. Which keyword is used to declare Java Class?
Q.7. How many objects are created in the following piece of code?
Myobject 01,02,03;
01=New Myobject();
02=New Myobject();
Q.8. Declare the method definition line for each of the following :
(i) Method Small_Num which takes three integers a,b,c and return as integer
data type.

15
(Class - XII: INFORMATICS PRACTICES)

(ii) Method Info which does not take any arguments and does not return a
value.
Q.9. What is the difference between a constructor and a method?
Q.10. What does it mean that a method or fields is “Static”?
Q.11. Can a Java file contain more than one java classes?
Q.12. What is the difference between static and non-static variables?
Q.13. How are this() and super() used with constructors?
Q.14.State the significance of public, private, protected, default modifiers in Java
Programming.
Q.15. Differentiate between Call by Value and Call by Reference.
Q.16. What is the role of a return statement in a method?
Q.17. What is a composite data type?
Q.18. Develop a desktop application to test all string manipulation methods using a
JButton click event procedure. Note that the result of string manipulation methods
will be placed in a JTextArea control.

CONCEPT OF INHERITANCE
Q.1. What do you understand by inheritance?
Q.2. Describe the relationship between a parent class and a child class.
Q.3. Why would a child class override one or more of the methods of its parent class?
Q.4. What is a superclass?
Q.5. What is an abstract class?
Q.6. Illustrate the concept of Inheritance with the help of an example.
Q.7. Consider the following declarations and answer the questions given below :
class Teacher
{
int roll;
protected String name[20];
public void inputdata(int, int){
. . .
}
public void optputdata(){
. . .
};
class Student extends Teacher
{
int class;

16
(Class - XII: INFORMATICS PRACTICES)

protected int add;


public void readdata(int, int){
. . .
}
public void writedata(){
. . .
}
};
(i) Name the base class and derived class of the class Student.
(ii) Name the data member(s) that can be accessed from function writedata().
(iii) Name the member function(s), which can be accessed by an object of
Student class.
(iv) Is the member function(s), outputdata() accessible by the objects of Student
class?
Q.8. A baseball team‟s winning percentage is equal to the number of wins divided by
the number of games played, rounded to three decimal places, Write a program
that takes a team‟s wins and losses as inputs and displays its winning percentage
implementing inheritance technique.
Q.9. Consider the following declarations and answer the questions given below :
Class parent
{
private String name;
protected int son;
public void inputdata(char,int){
. . .
}
public void outputdata(){
. . .
}
};
class father extends parent
{
private int daughter;
protected int baby;
public void readdata(int, int){
. . .
}
public void writedata() {
. . .
}
};
(i) Name the base class and derived class of the class father.

17
(Class - XII: INFORMATICS PRACTICES)

(ii) Name of data member(s) that can be accessed from function writedata().
(iii) Name the member function(s), which can be accessed by an object of
mother class.
(iv) Is the member function outputdata() accessible to the objects of father class?
Q.10. Compare concrete class v/s abstract class v/s interface with an example.
Q.11. Calculate the factorial of a number using child class and base class.
Q.12. Develop a Java desktop application to find the area of a circle and cylinder using
Java overriding method.
Q.13. Consider the following class declaration and answer the question (i) and (ii)
Class Mydata {
Protected int data;
Void Get_Mydata(int);
Void Manip_data(int);
Void Show_data(int);
}
Class Mydata {
Protected int data1;
void Get_Mydata(int);
void show_data(int);
}
Class person extends Mydata{
Void show_data(void)}
}
(i) Name the derived class and base class.
(ii) List the data and functions inherited by the class person.
Q.14. Demonstrate the declaration for the base class and derived class
diagrammatically.
Q.15. Create a generic base class called BI that stores the numbers of floors in a
building, the number of rooms and its total square footage. Create a derived
class called HI that inherits B1 and also store no. of rooms. Next, create a
derived class called O1 that inherits B1.

Q.16. What is Overriding?


Q.17. Name the modifiers that are allowed for methods in an Interface.
Q.18. Write the import statement required for using Joption Pane class.
Q.19. What is the difference between a dialog created with JDialog and a Dialog created
with JoptionPane.

18
(Class - XII: INFORMATICS PRACTICES)

Q.20. Create a Java GUI application that lets you create a marksheet. The details to be
added in marksheet are : Name, Total marks, Grade.
Q.21. Add a search facility in previous problem, that is, ask the user which column he/she
wants to search in and then obtain search value. If found in the marksheet then
report is otherwise report “not found”.
Q.22. What is a dialog?
Q.23. Design an application that obtain input without using textfield and display a thank
you message.

Java Database Connectivity


(JDBC) using MySQL.
Q.1. What is the difference between error and an exception?
Q.2. Is it necessary that each try block must be followed by a catch block?
Q.3. How does a try statement determine which catch clause should be used to handle
an exception?
Q.4. What is JMenu?
Q.5. What‟s the default port for MySQL Server?
Q.6. What is a ResultSet?
Q.7. What is connection?
Q.8. What type of parameter that used in execute Query() method?
Q.9. What is the use of next() method with a Resultset object?
Q.10. List advantages of JDBC.
Q.11. Describe with example how to send SQL statements to databases for execution.

Q.12. What are the steps in the JDBC Connection?


Q.13. Consider the MySQL table.
Library : Title, year-pub, ISBN, Subject, Author, price, publisher.
Create an application using the menu to add, search, delete and modify the data in
the given table.

Q.14. Create a Java NetBeans GUI application to add modify and delete the record in
the lable given below :
Directory : No, Fname, Lname, Phone, Address.
Q.15. Create a Java Net Beans GUI application to add, modify and delete the data into
MySQL Voter table.
Voter : VNo, VName, Age, Address, Phone.

19
(Class - XII: INFORMATICS PRACTICES)

Q.16.Let us consider the two MySQL tables with following structure :


Table : DETAILS
Field Name Field Type and Width Description
EMPNO INT(4) Employee number
ENAME CARCHAR(25) Name
DOB DATE Date of birth
ADDRESS VARCHAR(25) Address
PHONE VARCHAR(10) Phone number
CITY VARCHAR(15) City
STATE VARCHAR(15) State
PINCODE BIGINT(8) City pin number
DEPTNO CHAR(5) Department number

Table : PROFILE
Field Name Field Type and Width Description
EMPNO INT(4) Employee number
DESIG VARCHAR(15) Designation
DOJ DATE Date of joining
SALARY DOUBLE(9,2) Basic salary
GRADE CHAR(1) Grade
EMPPF CHAR(1) Provident fund number (Y/N)
PFNO VARCHAR(10) Provident fund number
EMPESI CHAR(1) ESI(Y/N)
ESINO VARCHAR2(10) ESI No.
EMPDA CHAR(1) DA(Y/N)
EMPHRA CHAR(1) HRA(Y/N)
EMPCON CHAR(1) Conveyance (Y/N)
Write an application which will create a console updation Java Project to add,
modify and delete into the two MySQL tables DETAILS and PROFILE. The
application will operate both the tables simultaneously in one form.
Q.17. Answer the question based on the table Patient give below :
Table : Patient
Column Name Data Type and Size Description
P_code INT(4) Patient Number Primary key
Patient_name VARCHAR(30) Name of the patient
Department VARCHAR(20) Department to which patient is admitted
Fees FLOAT Fees given
Using MySQL JDBC Driver data connection, write Java code for Save, Edit and
Exit command buttons to insert record, modify record and exit application into
Patient table. Notice that the modification operation will only occur when you
search a patient from existing table.

20
(Class - XII: INFORMATICS PRACTICES)

Q.18. Let us consider a MySQL STUDENT table with following structure :


Column Name Data Type and Size Description
ROLLNO INT(4) Roll number of student
NAME VARCHAR(25) Name
ENGM INT(3) English mark
ECOM INT(3) Economics mark
ACCNT INT(3) Accounts mark
BST INT(3) Business Study mark
IP INT(3) Informatics Mark
Using MySQL JDBC Driver data connection, write Java code to display a student‟s
total mark, percentage and grade as given below :
Total = ENGM + ECOM + ACCNT + BST +IP
Percentage = Total / 4
Grade will be calculated as follows :
Percentage Grade
>=80 A
>=70&<80 B
>=60&<70 C
>=50&<60 D
<50 F
Note. The student will list in a JList control.
Q.19. A Nath enterprises is a company, which deals with garments (ANthUI). The
company has three departmentscotton, silk and synthetic.

The company accepts payments in three modes – by cheque, cash and by credit card.
The company offers the discount scheme on each purchase for customer as follows :
 For cotton
Purchase above 5000 and avail discount 10%

21
(Class - XII: INFORMATICS PRACTICES)

Purchase above 7500 and avail discount 15%


 For silk
Purchase above 5000 and avail discount 5%
Purchase above 7500 and avail discount 10%
 For synthetic
Purchase above 5000 and avail discount 15%
Purchase above 7500 and avail discount 20%
Now, if the customer is paying by cash an additional 2% discount, if by cheque
no discount, if by credit card 2.5% tax to be paid by the customer.
(i) Write the code to clear all the JTextField control.
(ii) Write a button click action event procedure (text:Calculate and Vriable name
:btnCalDiscount) to calculate the discount after selecting the type of cloth.
Also it will display the net amount in respective JTextField control.
(iii) Write the code to exit from the application.
WEB APPLICATION DEVELOPMENT
(HTML 1, HTML 2, XML)
Q.1. Write an HTML code line to set the background image as ABC.gif.

Q.2. Write the HTML code to set the BGCOLOR as purple and a text “Hypertext
Markup language”.

Q.3. What is the method of using comment line in HTML code?


Q.4. What is the use of <FONT> tag in HTML code?
Q.5. Which tag is used to insert first level heading on a web page?
Q.6. How <BR> tag is different from <P> tag?
Q.7. How would you display text in the title bar of browser?
Q.8. What is the HTML command to display the following in your web page?
X 2-Y4+Z 2.
Q.9. Name two common graphics file formats that most browsers recognize.
Q.10. What is the purpose of using Type attribute in lists?
Q.11. What is the purpose of using START attribute in lists?
Q.12. Write the expansion of the following tags used in HTML :
(i) <BR > (ii) <TABLE> (iii) <A>
(iv) < B > (v) <I> (vi) <P>

22
(Class - XII: INFORMATICS PRACTICES)

Q.13. What are the different forms of list used in HTML? Name them.
Q.14. How can an image be inserted in a web page?
Q.15. What are the different forms of list used in HTML?
Q.16. Identify error() in the following HTML code Also write the correct code.
<OL>type= “a”start=“d”>
Q.17. What is a <OL>_ _ _ </OL> tag? Name any two attributes used with this tag.
Q.18. Differentiate between Cellpadding and Cellspacing.
Q.19. How is External linking different from internal linking.
Q.20. What is the real use of XML?
Q.21. Differentiate between <SUP> and <SUB> tags with example.
Q.22. How is <OL> different from <UL>?
Q.23. What is table? What are the basic commands for creating a table?
Q.24. Which tag and attribute are used to jump to
(i) a new page (ii) another location in the same page
Q.25. What is input tag? Explain its attributes?
Q.26. What is the purpose of select tag?
Q.27. State the major difference between radio buttons and a list of check boxes.
Q.28. Create a page about your hobbies and interest. On the page include links to
different web pages.
Q.29. How is the XML formed and what is the benefit of using it?
Q.30. Differentiate between HTML and XML.
Q.31. Differentiate between static page and dynamic web page.
Q.32. What do you understand by a well-formed document?
Q.33. What is root element? What is its significance? What is its alternate name?
Q.34. What is declared empty tag?
=============================================

23
(Class - XII: INFORMATICS PRACTICES)

My SQL Revision Tour


Q.1 State differences between the following:
(i) CHAR and VARCHAR.
(ii) Single row sub-query and multiple rows sub-query.
(iii) Primary key and Foreign key
(iv) Degree and Cardinality
(v) All and Distinct
(vi) DROP TABLE and DROP VIEW.
(vii) Column constraint and Table constraint.
(viii) DDL and DML
Q.2 Write a SQL (DDL) query to create the following table Employee.
Column Name Data Type Size Constraint
EmpID Number 6 Primary Key
EmpName Varchar2 20 Not Null
EmpAddr Varchar2 30
EmpPhone Varchar2 10
EmpSal Number 9.2

Q.3 Use the following structure of customer table to answer the following questions:

Column Name Data Type Size Constraint


Cust_ID Number 7 Primary Key
Cust_Name Varchar2 30
Cust_Add1 Varchar2 20
Cust_Add2 Varchar2 20
Pin_Code Number 6
Cust_Phone Varchar2 10

Write the SQL command to create the above table including its constraints.
Q.4 Consider the table EMP with following structure. Write SQL commands for the
following conditions.

ENo. EName Job Mgr Hiredate Sal Comn DeptNo


(i) To Select all the columns of the above table.
(ii) To list the name and employee number from the above table.
(iii) To list all names, hire date and salary of all employees.
(iv) To display the employee name and the incremented value of SAL as SAL +
300.
(v) To list the employee name and his annual salary (Annual salary = 12*sal
+100).
(vi) Display the ename and sal where comm is NULL.

24
(Class - XII: INFORMATICS PRACTICES)

(vii) To list the distinct department numbers from the table.


(viii) To list the unique jobs from the table.
(ix) To list the salary where salary is less than the commission.
(x) To list salary between 3,000 and 4,000.
(xi) To list the manager which are IN (7902, 7566, 7788).
(xii) To list the ename starting with „S‟.
(xiii) To list all the columns where salary is greater than 4,100.
(xiv) To list all the columns in the ascending order of hire date.
(xv) To list all the columns in the ascending order of deptno and descending
order of salary.
(xvi) To display the employee name and job of employees hired between
Feb20,1981 and May1,1981.
(xvii) Display the ename and deptno of all employees in department 20 and 30 in
alphabetical order by name.
(xviii) To list the name and salary of all the employees who earn more than 1200
and are in department 10 or 40.
(xix) To list name and hire date of all the employees who are hired in 1981.
(xx) To list all the employees who do not have manager.
(xxi) To list name and salary of all employees who earn commissions.
(xxii) To list the names of all employees where the second letter of their name is
„a‟
(xxiii) To list the names and job of all the employees who work in department 20
and their manager is 7788.
(xxiv) To list the deptno, job and sum of salary group by deptno and job.
(xxv) To convert the job into lower case.
(xxvi) To list the name and employee number by converting the name into
uppercase.
(xxvii) To list all names, hire date and confirmation date as the hire date + 6
months.
(xxviii) To list position of character „a‟ in the name of the employees.
(xxix) Display first three characters of the field JOB.
(xxx) Write the output of the following :
(a) SELECT ENAME, 12*SAL + COMM FROM EMP WHERE ENAME
= „Ashok Singhal‟;
(b) SELECT ENAME|| JOB AS “Employee” FROM EMP;
(c) SELECT ENAME FROM EMP WHERE ENAME LIKE „_a%‟;
(d) SELECT ENAME MGR FROM EMP WHERE MGR IS NULL;
(e) SELECT AVG(SAL), MAX(SAL), MIN(SAL) SUM(SAL) FROM EMP
WHERE JOB LIKE „SALES%‟;
(f) SELECT DEPTNO, AVG(SAL) FROM EMP GROUP BY DEPTNO;
(g) SELECT COUNT(*)FROM EMP WHERE DEPTNO=20;
(h) SELECT COUNT(COMM) FROM EMP WHERE DEPTNO=20;
(i) SELECTENAME,HIREDATE,SYSDATE,ROUND(MONTHS_BETWE
EN(SYSDATE,HIREDATE),0) AS “No. of Months” FROM EMP;

25
(Class - XII: INFORMATICS PRACTICES)

( j) SELECT ENAME, INSTR(ENAME,‟a‟,1,2)FROM EMP;


(k) SELECTR SUBSTR(ENAME,1,5) FROM EMP;
(l) SELECT CONCAT(ENAME,JOB)FROM EMP;
Q.5 What are integrity constraints? Describe two types of constraints.
DATABASE TRANSACTION AND MORE ON SQL GROUPIN G RECORDS
AND TA BLE JOI N S
Q.1 Considering table „EMP‟ and „DEPT‟ in My SQL, write SQL commands for the
following situations.
(i) To display the employee name, department name and department number.
(ii) To display ename, dname and loc of all employee who earn commission.
(iii) To display the name and dname of all the employees whose name start with
„A‟.
(iv) To display the name, job, department number and department name for all
employees who work in DELHI.
(v) To display the employee number and employee name along with their
manager‟s name and manager number.
(vi) To display the name and hire date of all the employees hired after employee
„Divaker Sehgal‟.
(vii) To display the employee name whose salary is greater than the salary of
employee number 7,900.
(viii) To display the name of the employees whose job is same as that of
employee number 7369.
(ix) To display the name of the employees who are earning more than the
average salary.
(x) To display the name and salary of all the employees having minimum salary
in their department.
(xi) To display the name and salary of all the employees who are in SALES
department.
(xii) To create a view having the field ename and job where comm is NULL.
(xiii) To create a view with all the field of emp table in the ascending order of the
field ename.
(xiv) To create a view with the fields ename and salary having salary more than
8,000.
(xv) To grant the select and insert Privilege on emp table to the user „Demo‟.
(xvi) Revoke the privilege given to the user „Demo‟.
(xvii) To create a synonym of the views created.
(xviii) To drop the synonyms created for the view.
Q.2 How will you remove the leading and trailing blanks from a character string?
Q.3 Write the command to convert the text “INFORMATICS PRACTICES OF CLASS
XII” into lower case letters.

26
(Class - XII: INFORMATICS PRACTICES)

Q.4 Differentiate between SUBSTR and INSTR function in SQL.


Q.5 What will be the output of :
(i) SELECT SQRT(345) + SQRT(15) ;
(ii) SELECT MONTHS_BETWEEN(‟12-OCT-01‟.‟25-JUN-02‟);
(iii) SELECT MOD (ROUND (120. 60, 1), 5) ;
(iv) SELECT POWER (5, 5) ;
Q.6 Define the following terms:
Relation, Tuple, Primary Key, Domain, Attributes, Foreign Key
Q.7 What is the difference between TRUNCATE and DELETE.
Q.8 Compare the two computing models.
Q.9 Consider table GRADUATE, with the following structure, and write SQL
commands for the following conditions:
S.NO. NAME STIPEND SUBJECT AVG DIVISION
(i) List the names of those students who have obtained Div I sorted by name.
(ii) Display the report, listing name, stipend, subject and amount of stipend
received in a year assuming that the stipend is paid every month.
(iii) To count the number of students who are either physics or computer science
graduates.
(iv) To insert a new row in the GRADUATE table.
11,‟SHAILESH‟, 300, „Physics‟,75,1
Q.10. Explain the term transaction with the help of example.
Q.11. Differentiate between the following
(i) COMMT and ROLLBACK
(ii) Atomicity and consistency
(iii) ROLLBACK AND SAVE POINT
Q.12. Explain all the properties of transaction.
Q.13. Given a table ABC (S.NO., NAME, FEES)
(i) RAM 500
(ii) MOHAN 600
(iii) SHYAM 500.

Considering table ABC, for the following series of statements, determine which
changes will become permanent and what will be the content of the table ABC
after statement. Justify your answer.
(i) START TRANSACTION;
(ii) INSERT INTO ABC values (4, „ABHAY‟,400);
(iii) DELETE FROM ABC where S.No. =2;

27
(Class - XII: INFORMATICS PRACTICES)

(iv) ROLLBACK WORK;


(v) BEGIN;
(vi) UPDATE ABC SET FEES = 1000 where code = 3;
(vii) ROLLBACK WORK;
(viii) INSERT INTO ABC VALUES (5, „DIVA‟,1000);
(ix) DELETE FROM ABC where code =1;
(x) ROLLBACK WORK;
(xi) UPDATE ABC SET value = 1500 where code=1;
(xii) COMMIT WORK;
Q.14. Explain Equi-Join and Non Equi-Join.
Q.15. Using IN with a subject select, find the names of all employees who belong to the
departments having maximum number of employees.
Q.16. Given following tables
Orders(OrdId, Ord-date, Qty, ProdId)
Product(ProdId, Descp, Price)
Write a query to select all those records from table orders whose product Id is 10.
Q.17. Add a constraint (Grade) in table emp that declares column Grade not null.
Q.18. Add one column Email of data type Varchar2 and size 30 to the table customer.
Q.19. What is difference between Truncate and Delete Commands?
Q.20. What is a Non-Equi Join? Give examples.
Q.21. Find out number of employees having “Manager” as Job.
Q.22. Find the average salary and average total remuneration for each job type.
Remember salesman earn commission.
Q.23. Write a suitable SQL statement to display all employees working in New York in
the following format. Emp, Name, Salary, Location.
TABLES AND INTEGRITY CONSTRAINTS
Q.1. Give the commands to perform the following :
(i) Create the table structure Tour (Tour No., Bus No., Ticket Price)
(ii) Define the combination of Tour No and Bus No. the primary key.
(iii) Create the table structure. Tourist (Tour No., Bus No., Seat No., Name)
where the combination of Tour No., Bus No. and Seat No. is the primary
key.
(iv) Define the combination of Tour No. and Bus No. a foreign key that refers to
the corresponding combination of Tour Table.
Q.2. Discuss the role of Foreign Key constraints.

28
(Class - XII: INFORMATICS PRACTICES)

Q.3. Write SQL statement to create Employee relation which contain Emp No., Name,
Skill, Pay Rate.
IT APPLICATIONS
Q1. Give one major difference between Front-End technology and Back-End
technology in terms of software projects. Give one example of each.
Q2. Explain in brief an entity, relationship and attribute with the help of one example.
Q3. Identify the type of relationship represented by the following statements and draw
an entity relationship diagram to show it.
“One student is taught by many teachers. One teacher teach one student.”
Q4. Identify the type of relationship represented by the following statements and draw
an entity relationship diagram to show it.
“Each garment must have one and only one price. Each price may be for one or
more garments”.
Q5. What are the different types of relationships that can be depicted through an E/R
model? Explain the concept of ER Model using the case study of a Ticket
Reservation System that has three entries – Ticket, Passenger and rain. Assume
that each passenger can buy more than one ticket.
Q6. Write one example each of “one to many” and “many to many” relationships
between two entity sets.
Q7. Identity the type of relationship represented in the following statement and draw in
Entity Relationship Diagram to show it : “A customer can buy many items”.
Q8. What do you understand by a many to one relationship? Explain with examples.
Q9. Expand the following terms:
(i) ER (ii) UML
Q10. Define DDLC.
Q11. Define weak and strong entities. How are these otherwise known as?
Q12. What is a composite attribute?
Q13. What are sub entities and super entities?
Q14. Identify the dependent and independent entities out of the following :
(i) Student and Grade
(ii) Customer and Phone
(iii) Supplier and address
Q15. What are the societal impacts of (i) e-governance (ii) e-business (iii) e-learning

29
(Class - XII: INFORMATICS PRACTICES)

MID TERM EXAMINATION


Time Allowed : 3 hours Maximum Marks 70
Note :
(i) This question paper is divided into three sections.
(ii) Section A and Section B are of 25 marks each.
(iii) Section C consists of 20 marks.
(iv) Answer the questions after carefully reading the text.
=============================================
SECTION – A
Q.1. Answer the following questions :
(i) Write the purpose of the following : [2]
(a) Gateway (b) Hub
(ii) Write the advantages of Radio Wave. [2]
(iii) Explain any two techniques used for network security. [2]
(iv) Differentiate between tree topology and bus topology. [2]
(v) Compare static and dynamic fonts. [2]
Q.2. Answer the following questions :
(i) Define e-learning. [1]
(ii) Write two usage of backend [1]
(iii) What benefits does e-business offer to the customer? [1]
(iv) XYZ School wants to conduct an online survey of school students time
spending habbits and their subject choices. Choose appropriate controls from
text field, label, option button, checkbox, list box, combo box, command
button and write in the third column. [2]
S.No. Control used to Control used
1. Enter Name
2. Select Age group
3. Select subject from available list
4. Select different hobby options
Q.3. Answer the following questions :
(i) What is a datatype? Name some datatypes available im MySQL. [2]
(ii) Define a transaction. [2]
(iii) What are different types of SQL function? [2]
(iv) Differentiate between referencing table and referenced table? [2]
(v) Explain the concept of self-referencing with example. [2]
(vi) Write a query to display the number of employees with same job. [1]

30
(Class - XII: INFORMATICS PRACTICES)

SECTION – B
Q.4. Read the following case study and answer the questions that follow :
Manager of XYZ Infotech Solution Ltd. Decided to develop a application to
manage employee information. He asked his subordinate to make a form in Java.
The form presented by the subordinate is shown below.

Object Type Object Name Description


Frame JFrame Name of the Form
Label Header Company Name
Name Employee Name
Sex Sex
Dept Department
Desig Designation
Text Field Name To enter name of employee
Basic To enter basic salary of employee
DA To calculate DA of employee
HRA To calculate HRA of employee
PF To calculate PF of employee
Gross To calculate Gross salary of employee
Net Salary To calculate Net Salary of employee
Radio Button Male Gender Male
Female Gender Female
List Box Dept List of department
Desig List of designations
Display To show the entered value
Command Button Add To add details of employee to the list
Delete To remove details of employee from the list
Calculatesal To calculate salary of employee

31
(Class - XII: INFORMATICS PRACTICES)

(i) Write a code in the form load event to disable the textfield Basic, Da, HRA,
Gross, PF and Netsalary and take the dept, design and Radio buttons to
their default state as shown in the form. [2]
(ii) Write a code to add record of an employee to the list when cmdAdd is
clicked and delete record from the list when cmdDelete is clicked. [3]
(iii) When CalculateSal is clicked, the salary details must be automatically
calculated and displayed in their respective textboxes. [5]
Designation Basic
Manager 15,000
Supervisor 12,000
Accountant 9,000
Clerk 6,000
DA = 10% of basic
HRA = 30% of basic
PF = 12% of basic
Gross Salary = basic + DA + HRA
Net Salary = Gross salary - PF

Q.5. Answer the following questions : [2]


(i) Find the output of the following
int v=1, a=1, b=2, c, d;
c=++b;
d=a++;
c++;
System.out.println(v==1? “A” : “B”);
v++;
System.out.println(v==1? “A” : “B”);
System.out.println (“a=”+a);
System.out.println (“b=”+b);
System.out.println (“c=”+c);
System.out.println (“d=”+d);

(ii) How many times are the following loops executed? [2]
x=5 ; y=50 ;
while (x<=y) {
x=y/x;
}
(iii) Identify and correct the errors in each of the following statement : [2]
(a) if (C<7) ;
JOptionPane. Show Message Dialog (null, “C is less than 7”);

32
(Class - XII: INFORMATICS PRACTICES)

(b) if (C>7) ;
JOptionPane. Show Message Dialog (null, “C is equal to or
greater than 7”);

(iv) What is the difference between JListBox and JComboBox? [2]


(v) Explain parse …. ( ) method with example. [1]
(vi) Explain with syntax. ShowmessageDialog ( ) method of JOption Pane? [2]
(vii) Write the code to display [4]
(a) 1 (b) 4
22 43
333 432
4444 4321
SECTION – C

Q.6. (i) Write the difference between SAVEPOINT AND ROLLBACK. [2]
Consider the following supplier table and answer the following questions
S.No. PName SName Qty Price City
S1 Bread Britannia 150 80 Delhi
S2 Cake Britannia 250 20 Mumbai
S3 Coffee Nescafe 170 45 Delhi
S4 Chocolate Amul 350 10 Mumbai
S5 Sauce Maggi 300 36 Jaipur

(ii) Write MySQL commands for the following statements : [6]


(a) To display the names of all suppliers which are in Delhi.
(b) To display product namd and Qty having price > 30.
(c) To display all the details in ascending order of price.
(d) To display productname, supplier name of all the suppliers located in
Delhi, Mumbai.
(e) Count the number of product supplied in each city.
(f) To insert details of a new shop in the table supplier with the following
data :
(S6, “Jam”, “Kissan”,400,52, “Delhi”).
(iii) Give the output of the following My SQL queries. [4]
(a) Select Min(Price) from Supplier;
(b) Select Sum(Price) from Supplier where Sname= „Britania‟
(c) Select Avg(Qty) from SHOP where City = “Delhi”,
(d) Select Count (Distinct City) from supplier;

Q.7. Answer the following questions :


(i) Study the following tables Department and Teacher tables and write SQL
commands.

33
(Class - XII: INFORMATICS PRACTICES)

Department
Dept. No. Dept. Name
D01 Physics
D02 Chemistry
D03 Maths
D04 Computer IP
D04 Biology
Teacher
TNo Tname Salary Dept. No.
T01 Rakesh Sharma 25,600 DO5
T02 Jugal Mittal 22,000 DO2
T03 Sharmila Kaur 21,000 DO1
T04 Sandeep Kaushik 15,000 DO3
T05 Sangeeta Vats 18,900 DO5
T06 Ramesh Kumar 24,000 DO3
T07 Shyam Arora 12,000 DO2
T08 Shiv Om 13,000 DO2
T09 Vivek Rawat 17,000 DO1
T10 Ashok Singhal 15,600 DO4
(a) Display TName of all teachers who are in “DO5” having salary more
than 20,000. [1]
(b) Display average salary of all teachers working in “DO2” department.
[1]
(c) Display TName and Deptname and order the rows by Dept No. [1]
(d) Display equi-join of both tables? [2]
(e) Select TName, TNo, DNo, DName from techers, department where
DName = „Chemistry‟ and Teachers.DNO = Department. DNO; [1]
(ii) Create table department as per the following Instance Chart. [2]
Column Name DeptID DeptName
Keytype Primary
Nulls/Unique NOTNULL
Datatype Number VARCHAR
Length 2 20

34
(Class - XII: INFORMATICS PRACTICES)

SAMPLE PAPER
Time Allowed : 3 hours Maximum Marks 70
Note :
(i) This question paper is divided into three sections.
(ii) Section A and Section B are of 25 marks each.
(iii) Section C consists of 20 marks.
(iv) Answer the questions after carefully reading the text.
=============================================
Q.1. Answer the following questions :
(i) Write the purpose of the following : [2]
(a) Repeater
(b) Router
(ii) Write the advantages of optic fibre cable. [2]
(iii) Write two snooping methods used by hackers / crackers. [2]
(iv) Mr. Ram is interested in transferring songs from her mobile to Mr. Shyam
mobile. Suggest two suitable wireless options he may opt for doing the
same. [2]
(v) What is the difference between open source software and proprietary
software. [2]
Q.2. Answer the following questions :
(i) Define e-governance. [1]
(ii) Write two characteristics of front end. [1]
(iii) How is e-learning useful to trainer? [1]
(iv) Mr Das is working as a Manager in the Shivam Enterprises. He wants to
create the forms with the following functions. Choose appropriate controls
from Text field, Label, Option button, Check box, List box, Combo box,
command button and write in the third column. [2]
S.No. Control used to Control used
1. Enter the name, Address,
Basic Salary
2. Select the gender (M/F)
3. Select the department
From the available list
4. Choose type of employee
(Permanent / Regular)
Q.3. Answer the following questions :
(i) When entering a multiple line query in MySQL, what does the
mysql>prompt change to? [2]
(ii) After creating the “student‟ database, you want to use it. Write the command
that you should give. [1]
(iii) What is the purpose of ALTER TABLE command? [2]

35
(Class - XII: INFORMATICS PRACTICES)

(iv) Explain the two wildcard character_and % used with the LIKE clause. [2]
(v) Explain two group functions in MySQL. [2]
(vi) Rama is not able to change a value in a column to NULL. What did she
specify when she created the table? [1]
SECTION – B
Q.4. Answer the following questions :
Read the following case study and answer the questions that follows :
Mr. Vidyarthi works in Blossoms Public School as a programmer. He is required to
develop a student record. The school offers two different streams, medical and
non-medical, with different grading criteria. The school also offers incentive to the
NCC cadets. The grading criteria for the two streams is given below :
Stream Percentage Grade
Medical >=80 A
60-80 B
<60 C
Non-Medical >=75 A
50-75 B
<50 C

Object Type Object Name Description


JFrame The main form object
JTextField txtFirstTerm To enter first term marks
txtSecondTerm To enter second term marks
txtPercentage To display the percentage of the student
txtGrade To display the grade of the student
JCheckBox chkBox To be checked if student is an NCC Cadet
JRadioButton optMedical To provide Stream Information
optNonMedical
JButton cmdCalcPer To calculate the percentage
cmdCalcGrade To calculate the grade
cmdClear To clear the entered values
cmdExit To close the application

36
(Class - XII: INFORMATICS PRACTICES)

(i) Write the commands for Exit button to terminate the application. [2]
(ii) Write the code for Clear Command Button to clear all the textfield. [2]
(iii) Write the code for Calculate percentage to calculate the percentage after
finding the total marks of first term and second term (assuming that both
marks are out of 100). Also ensure that NCC cadets get an increment of 3%
in their percentages. [3]
(iv) Write the code for Calculate Grade button to calculate the grade depending
on the stream selected according to the criteria given above. [3]
Q5. Answer the following questions :
(i) Give the output of the following code fragment: [2]
when (i) opn = „b‟ (ii) opn = „c‟ (iii) opn = „a‟
switch (opn)
{
case „a‟:
system.out.println(“Platform Independent”);
break;
case „b‟:
system.out.println(“Object Oriented‟);
case „c‟:
system.out.println(“Robust and Secure”);
break;
default :
system.out.println(“Wrong input”);
}
(ii) The following is a segment of a program. [2]
x = 1; y=1;
if(n>0)
{
x = x + 1;
y = y – 1;
}
What will be the value of x and y, if n assumes a value (i) 1 (ii) 0?
(iii) Find the syntax errors if any in the following program : [2]
int I; sum = 0;
I = 1;
while (i<=10)
{
sum = sum + I;
I+=3;
}
system.out.println(sum);
(iv) What is the difference between jRadioButton and jCheckBox? [2]
(v) Write the command to set the value of the textfields. [1]

37
(Class - XII: INFORMATICS PRACTICES)

(vi) What is button group? What all controls can you put in it? [2]
(vii) Which of these is an example of a nested list? [1]
(a) <DL>
<LI > Groceries<BR>
Milk<BR>
Sour<BR>
Ice Cream<BR>
<LI > Other groceries
</OL>
(b) <OL>
<LI > Groceries
<U L>
<LI>Milk
<LI>Soup
<LI>Ice Cream
</UL>
<LI>Other Groceries
</OL>
(viii) Create a page about your hobbies (At lease three hobbies). On the page,
include links to interesting sites that coincide with your description. For
instance, if you like sports, you might create a link to
http://www.cnn.com/SPORTS.html for the benefit of your users. [3]
SECTION – C
Q.6. (i) Write the difference between COMMIT and ROLLBACK. [2]
Consider the following table SHOP and answer (ii) and (iii) parts of this
question :
Relation : SHOP
No. Shop_name Sale Area Cust_Percent Rating City
1. S.M. Sons 250000 West 68.6 C Delhi
2. Dharohar 500000 South 81.8 A Mumbai
3. Kriti Art 300000 North 79.8 B Kolkata
4. Ripple 380000 North 88.0 B Mumbai
5. Biswas Stores 456000 East 92.0 A Delhi
6. Crystal 290000 South 62.7 A Kolkata

(ii) Write MySQL commands for the following statements :


(a) To display the names of all shops which are in South. [1]
(b) To display name and Customer Percentage of all the shops having
Cust_Percent>80 [1]
(c) To display list of all the shops with sale>300000 in ascending order of
Shop_Name. [1]

38
(Class - XII: INFORMATICS PRACTICES)

(d) To display a report with Shop_name, Area and Rating for each shop in
the table, for only those shops whose sale is between 350000 and
4000000 (including both 350000 and 400000). [1]
(e) To display the City and the number of shops in each city in the table
SHOP. [1]
(f) To insert details of a new shop in the table SHOP with the following
data : [1]
(7, “The shop”, 550000, “South”, 90.8, „A‟, “Ahmedabad”).
(iii) Give the output of the following MySQL queries : [Include the last inserted
values of part (vi)] [4]
(a) Select Min(Cust_percent) from SHOP;
(b) Select Sum(Sale) from SHOP where Rating = „A‟;
(c) Select Avg(Sale) from SHOP where City = „Delhi‟;
(d) Select Count(Distinct City) from SHOP;

Q.7. Answer the following questions :


(i) Study the following tables STAFF and SALARY and write MySQL
commands for the questions (a) to (d) and give outputs for (e) to (f).
TABLE : STAFF
ID NAME DEPT SE X E XPERIENCE
101 Siddharth SALES M 12
104 Raghav FINANCE M 5
107 Naman RESEARCH M 10
114 Nupur SALES F 3
109 Janvi FINANCE F 9
105 Rama RESEARCH M 10
117 James SALES F 3
111 Binoy FINANCE F 12
130 Samuel SALES M 15

TABLE : SALARY
ID BASIC ALLOWANCE E XPERIENCE
101 12000 1000 3
104 23000 2300 5
107 32000 4000 5
114 12000 5200 10
109 42000 1700 20
105 18900 1690 3
130 21700 2600 30

(a) Display NAME of all staff who are in “SALES” having more than 10
years experience from the table STAFF. [1]

39
(Class - XII: INFORMATICS PRACTICES)

(b) Display the average salary of all staff working in “FINANCE”


department using the tables STAFF and SALARY. SALARY = BASIC
+ ALLOWANCE. [1]
(c) Display the minimum ALLOWANCE of female staff. [1]
(d) Display the highest commission% among all male staff. [1]
(e) SELECT count(*) from STAFF where SEX = „F‟; [1]
(f) SELECT NAME, DEPT, BASIC from STAFF, SALARY [1]
where DEPT = „SALES‟ and STAFF.ID = SALARY.ID;
(ii) Answer the questions based on the table VOTER given below “

TABLE : VOTER
Column Name Data type Size Constraint Description
V_ID BIGIN 8 Primary Key Voter identification
Vname VARCHAR 25 NOT NULL Name of the voter
Age INT 3 CHECK > 17 Age should not less than
equal to 17
Address VARCHAR 30 Address of voter
Phone VARCHAR 10 Phone number of the voter

(a) Write a command to delete all the rows of a particular voter from
table VOTER where voter id between 10 and 20. [1]
(b) Delete the table physically. [1]

40
(Class - XII: INFORMATICS PRACTICES)

COMMUNICATION AND NET WORK CONCEPTS


=============================================
What is a Network?
Network is an interconnected collection of autonomous computers. The computers are
said to interconnected if they are capable of exchanging information.
1. NETWORK GOALS
(i) R ESO U RCE SHARING: The aim is to make all programs, data and
peripherals available to anyone on the network irrespective of the physical
location of the resources and the user.
(ii) RELIABILITY: A file can have copies on two or three different machines, so if
one of then is unavailable, the other copies could be used.
(iii) COMMUNICATION MEDIUM: It acts as a communication medium.
Messages can be sent – e.g. internal email.
2. APPLICATION OF NETWORKS
(i) Sharing: The potential advantage of network is to provide an easy and
flexible means of sharing. There are three distinct types of sharing.

(a) Peripherals: These are often expensive. It is impractical for each


computer on the network to have both its laser printer and dot matrix
printer.
(b) Users of a multi user system can share and exchange information in a
number of ways.
(c) In a traditional time sharing system, all control is performed centrally;
if the processor fails then the entire system fails. In a network system,
the failure of one node should not have domain effect on the rest.
This is called distributed control.
(ii) Access to remote database: It is easy for the average person sitting at his
PC to make reservation for airplanes, trains, hotels and so on anywhere in
the world with instant confirmation.
(iii) Communication facilities: Able to contain digitized voice, still pictures
and even moving television and video images.
3. EVOLUTION OF NETWORK
Evolution of networking started way back in 1969 by the development of first
network called ARPANET, which led to development of Internet.
(i) Arpanet
The seeds of today‟s Internet were planted in 1969, when U.S. Department
of Defence sponsored a project named ARPANET (Advance Research
Projects NETwork). The goal of this project was to connect computers at
different universities and U.S. defence. The engineers, scientists, students

41
(Class - XII: INFORMATICS PRACTICES)

and researchers who were part of this system, began exchanging data and
messages on it. In mid 80‟s, federal agency, the National Science
Foundation, created a new, high-capacity network called NSFnet.
NSFnet allowed only the academic research on its network. It was the Inter
networking i.e. linking of these two and some other networks(i.e., the
ARPANET, NSFnet and some private networks) that was named Internet.
(ii) The Internet: The Internet is a worldwide network of computer networks
that evolved from the first network ARPANET. Internet is made up of many
networks each runs by a different company and interconnected at peering
points.. The common use of Internet standards allows users connected to
one network to communicate with users on another network it allow users to
exchange information with each other. To accomplish this all the computers
on the Internet have to use a common set of rules for communication, called
Protocols. Internet uses a set of protocols called TCP/IP(Transmission
Control Protocol/Internet Protocol).
Gateway & Backbone: A Gateway is a device that connects dissimilar
networks. A Backbone is central interconnecting structure that connects one
or more networks. At the source computer, the message or the file/document
to be sent to another computer is firstly divided into very small parts called
Packets. A packet generally contains up to 1500 characters. Each packet is
given a number serial wise e.g., 1, 2, 3.These packets are then sent to the
address of destination computer. The destination computer receives the
packets in random manner. If a packet is garbled or lost, it is demanded
again. The packets are reassembled in the order of their number and the
original message/file/document is obtained.
Internet Functioning
The communication protocol used by Internet is TCP/IP. The TCP part is
responsible for dividing the file/ message into packets on the source
computer. It is also responsible for reassembling the received packets at the
destination or recipient computer. The IP part is responsible for handling the
address of destination computer so that each is routed to its proper
destination.
(iii) The Interspace
Interspace is a client/server software program that allows multiple users to
communicate online with real-time audio, video and text chat in dynamic
3D environments. The Interspace is a vision of what the Internet will
become.
4. SWITCHING TECHNIQUES
(i) Circuit Switching: In this technique, first the complete physical
connection between two computers is established and then data are
transmitted from the source computer to the destination computer. This
technique is to setup an end-to-end path between computers before any
data can be sent.

42
(Class - XII: INFORMATICS PRACTICES)

(ii) Message Switching: In this technique, the source computer sends data or
the message to the switching office first, which stores the data in its buffer. It
then looks for a free link to another switching office and then sends the data
to this office. This process is continued until the data are delivered to the
destination computers. Its working principle is also known as store and
forward.
(iii) Packet Switching: With message switching, there is no limit on block size,
in contrast, packet switching places a tight upper limit on block size. A fixed
size of packet which can be transmitted across the network is specified.
Another point of its difference from message switching is that data packet is
stored on the disk in message switching whereas in packet switching, all the
packets of fixed size are stored in main memory. This improves the
performance as the access time is reduced, thus the throughput of the
network is improved.
5. TRANSMISSION MEDIA
Transmission media or communication channels of network mean „connecting
cables‟ or „connecting media‟. The cables that connect two or more workstations
are the communication channels. The communication media are in two categories:
guided media and unguided media. The guided media include cables and
unguided media include waves through air, water or vacuum.
(i) Twisted Pair Cable: The most common form of wiring in data
communication application is the twisted pair cable. It consists of two
identical wires wrapped together in a double helix.
Main Advantages of Twisted Pair Cable are:
(a) It is simple
(b) It is easy to install and maintain
(c) It is physically flexible
(d) It has a low weight
(e) It can be easily connected
(f) It is very inexpensive
Disadvantages: Despite having such advantages, the data transmission
characteristics of twisted pair cable are not so good. Major disadvantages
are:
(a) Because of high attenuation, it is incapable of carrying a signal over
long distances without the use of repeaters.
(b) Its low bandwidth capabilities make it unsuitable for broadband
applications.
(c) It support maximum data rates 1 MBPS without conditioning and 10
MBPs with conditioning.

43
(Class - XII: INFORMATICS PRACTICES)

(ii) Coaxial Cable: This type of cable consists of a solid wire core surrounded
by one or more foil or wire shields, each separated by some kind of plastic
insulator. The inner core carries the signal, and the shield provides the
ground. The coaxial cable has high electrical properties and is suitable for
high speed communication. It is widely used for television signals. In the
form of (CATV) cable, it provides a cheap means of transporting multi-
channel television signals around metropolitan areas.
Advantages:
(a) The coaxial cables can be used for broadband transmission i.e.,
several channels can be transmitted simultaneously (as with cable
TV).
(b) Offers higher bandwidths- up to 400 MBPS.
Disadvantages
(a) Expensive compared to twisted pair cables.
(b) The coaxial cables are not compatible with twisted pair cables.
(iii) Optical Fibers: Optical fibers consist of thin strands of glass or glass like
material which are so constructed that they carry light from a source at one
end of the fiber to a detector at the other end. The light sources used are
either light emitting diodes (LEDs) or laser diodes(LDs). The data to be
transmitted is modulated onto the light beam using frequency modulation
techniques. The signals can then be picked up at the receiving end and
demodulated. The band width of the medium is potentially very high.
The fiber cable consists of three pieces: (i) The core i.e., the glass or plastic
through which the light travels.(ii) the cladding, which is a covering of the
core that reflects light back to the core, and the (iii) Protective coating,
which protects the fiber cable from hostile environment.
Advantages:
(a) It is immune to electrical and magnetic interference i.e., noise in any
form because the information is travelling on a modulated light beam.
(b) It is highly suitable for harsh industrial environments.
(c) it guarantees secure transmission and has a very high transmission
capacity.
(d) fiber optic cables can be used for broadband transmission where
several channels(i.e., bands of frequency) are handled in parallel and
where it is also possible to mix data transmission channels with
channels for telescope, graphics, TV and sound.

Disadvantages:
(a) Installation problem. Fiber optic cables are quite fragile and may need
special care to make them
(b) Sufficiently robust for an office environment.

44
(Class - XII: INFORMATICS PRACTICES)

(c) Connecting either two fibers together or a light source to a fiber is a


difficult process.
(d) Because of noise immunity, optical fibers are virtually impossible to
tap. In order to incept
(e) The signal, the fiber must be cut and a detector inserted.
(f) Light can reach the receiver out of phase.
(g) Connection losses are common problems.
(h) Fiber optic cables are more difficult to solder.
(i) They are the most expensive of all the cables.
(iv) Micro Wave: Microwave signals are used to transmit data without the use
of cables. The microwave signals are similar to radio and television signals
and are used for long distance communication. The microwave transmission
consists of a transmitter, receiver and the atmosphere.
Advantages:
(a) It proves cheaper than digging trenches for laying cables and
maintaining repeaters and cables if cables get broken by a variety of
causes.
(b) It offers freedom from land acquisition rights that are required for
laying, repairing the cables.
(c) It offers ease of communication over difficult terrain.
(d) Microwaves have the ability to communicate over oceans.
Disadvantages:
(a) Microwave communication is an insecure communication.
(b) Signals from a single antenna may split up and propagate by slightly
different paths to the receiving antenna. When these out-of-phase
signals recombine, they interfere, reducing the signal strength.
(c) Microwave propagation is susceptible to weather effects like rains,
thunder storms etc.
(d) Bandwidth allocation is extremely limited in case of microwaves.
(e) The cost of design, implementation, and maintenance of microwave
links is high.
(v) Radio Wave: The transmission making use of radio frequencies is termed
as radio-wave transmission.
(a) Any radio setup has two parts:
(b) The Transmitter
(c) The receiver
(d) The transmitter takes some sort of message, encodes it onto a sine
wave and transmits it with radio waves. The receiver receives the
radio waves and decodes the message from the sine wave it receives.
Both the transmitter and receiver use antennas to radiate and capture
the radio signal.

45
(Class - XII: INFORMATICS PRACTICES)

Advantages:
(a) Radio-wave transmission offers mobility.
(b) It proves cheaper than digging trenches for laying cables and
maintaining repeaters and cables if cables get broken by a variety of
causes.
(c) It offers freedom from land acquisition rights that are required for
laying, repairing the cables.
(d) It offers ease of communication over difficult terrain.
Disadvantages:
(a) Radio-wave communication is an insecure communication.
(b) Radio-wave propagation is susceptable to weather effects like rains,
thunder storms etc.
(vi) Satellite: Satellite communication use the synchronous satellite to relay the
radio signal transmitted from ground station. Satellite and microwave
communications network features the time saving, fast-implementation and
broad coverage characteristics. It provides voice, fax, data and video
services as well as email, file transfer, WWW internet applications.
Advantages:
(a) The area coverage through satellite transmission is quite large
(b) The laying and maintenance of intercontinental cable is difficult and
expensive and this is where the satellite proves to be the alternative.
(c) The heavy usage of intercontinental traffic makes the satellite
commercial attractive.
(d) Satellites can cover large areas of the Earth. This is particularly useful
for sparsely populated areas.
Disadvantages:
(a) Technological limitations preventing the deployment of large, high
gain antennas on the satellite platform.
(b) Over-crowding of available bandwidths due to low antenna gains.
(c) The high investment cost and insurance cost associated with
significant probability of failure.
(d) High atmospheric losses above 30 Ghz. limit carrier frequencies.
DATA COMMUNICATION TECHNOLOGIES
(i) Data Channel: A channel is the medium used to carry information or data
from one point to another.
(ii) BAUD: It is the unit of measurement for the information carrying capacity
of a communication channel.
(iii) BITS PER SECOND (bps): It refers to the speed at which data transfer is
measured. Byte per second are denoted as Bps-

46
(Class - XII: INFORMATICS PRACTICES)

(a) The rate of a thousand bits per second is known as kbps i.e., kilo bits
per second.
(b) A rate of a thousand bytes per second is denoted by Kbps (Kilo
bytes per second).
(c) A rate of a million bits per second is denoted through mbps- mega
bits per second.
(d) A rate of a million bytes per second is denoted as Mbps.
(iv) BANDWIDTH: The bandwidth refers to the difference between the highest
and lowest frequencies of a transmission channel. Bandwidth is used to
mean the amount of information traveling through a single channel at any
one point of time. High bandwidth channels are called
broadband channels and low bandwidth channels are called narrowband
channels. Bandwidth is directly proportional to the amount of data
transmitted or received per unit time.
(v) DATA TRANSFER RATES:
The data transfer rate represents the amount of data transferred per second
a communications channel or a computing or storage device. Data rate is
measured in units of bits per second (bps), bytes per second (Bps) or
baud.
6. TYPES OF NETWORKS
Networks are classified on the basis of geographical spread and on this basis, there
can be three types of networks:
 Local Area Networks (LANs)
 Wide Area Networks (WANs)
 Metropolitan Area Networks (MANs)
(i) Local Area Network (LAN) Small computer networks that are confined to
a localised area (e.g., an office, a building or a factory) are known as Local
Area Networks(LANs). The key purpose of a LAN is to serve its users in
resource sharing, hardware as well as software resources. In a typical LAN
configuration, one computer is designated as the file server. It stores all of
the software that controls the network, as well as the software that can be
shared by the computers attached to the network. Computers connected to
the file server are called Workstations. Cables are used to connect the
network interface cards in each computer.
(ii) Metropolitan Area Network(MAN) Metropolitan Area Networks are the
networks spread over a city. For e.g., cable TV network that are spread over
a city, can be termed as metropolitan area networks. The purpose of a MAN
is also the sharing of hardware and software resources among its users.
(iii) Wide Area Networks (WAN) The networks spread across countries are
known as WANs. A Wide Area Network(WAN) is a group of computers that
are separated by large distances and tied together. It can even be a group of

47
(Class - XII: INFORMATICS PRACTICES)

LANs that are spread across several locations and connected together to
look like one big LAN. The WANs link computers to facilities fast and
efficient exchange of information at lesser costs and higher speeds. The
largest WAN in existence is the Internet.
Difference between a LAN and a WAN
LAN WAN
(i) Diameter of not more than a few kilometers (i) Span entire countries.
(ii) A total data rate of at least several Mbps. (ii) Data rate less than 1
Mbps
(iii) Complete ownership by a single organisation. (iii) Owned by multiple
organisation.
(iv) Very low error rates. (iv) Comparatively higher
error rates.
7. NETWORK TOPOLOGIES
The pattern of interconnection of nodes in a network is called the TOPOLOGY.
Point-to-Point Link
Refer to Fig. below a P-P(Point-to-Point) link basically relies upon two
functions-transmit and receive. The main characteristic of P-P network is that
each station receives exactly from one transmitter, and each transmitter
transmits to exactly one receiver. The transmit and receive operations can occur
over separate wires or they can take turns over the same wire using a variety of
techniques.
Transmit Receive

X Y
Receive Transmit

Fig. Point-to-Point Network


Many topologies have been developed, but major ones are:
 The Star topology;
 The Bus;
 The Ring or Circular;
 The tree;
 The Graph;
 The Mesh;
(i) The Star Topology: This topology consists of a central node to which all
other nodes are connected by a single path.
Advantages of the Star Topology
Ease of service: The star topology has a number of concentration points.
These provide easy access for service or reconfiguration of the network.
(a) One device per connection

48
(Class - XII: INFORMATICS PRACTICES)

(b) Centralized control/problem diagnosis: The fact that the central node
is connected directly to every other node in the network means that
faults are easily detected and isolated. It is simple to disconnect failing
nodes from the system.
(c) Simple access protocols.
Disadvantages of the Star Topology
(a) Long cable length: Because each node is directly connected to the
center, the star topology necessitates a large quantity of cable. Whilst
the cost of cable is often small, congestion in cable ducts and
maintenance and installation problem can increase cost considerably
(b) Difficult to expand: The addition of a new node to a star network
involves connections all the way to the central node.
(c) Central node dependency: If the central node in a star network fails,
the entire network is rendered inoperable. Thus heavy reliability and
redundancy constraints on this no
(ii) THE BUS OR LINEAR TOPOLOGY: This consists of a single length of
the transmission medium (normally coaxial cable) onto which the various
nodes are attached. The transmission from any station travels the length of
the bus, in both directions, and can be received by all other stations. The bus
has terminators at either end which absorb the signal and removes it from
the bus. Data is transmitted in small blocks, known as packets. Each packet
has some data bits, plus a header containing its destination address. A
station wanting to transmit some data sends it in packets along the bus. The
destination device, on identifying the address on the packets, copies the data
onto its disk.
Advantages of the Linear Topology:
(a) Short cable length and simple wiring layout: Because there is a
single common data path connecting all nodes, the linear topology
allows a very short cable length to be used. Resilient Architecture:
The LINEAR architecture has an inherent simplicity that makes it
very reliable from a hardware point of view. There is a single cable
through which all the data propagates and to which all nodes are
connected.
(b) Easy to extent: Additional nodes can be connected to an existing
bus network at any point along its length.
Disadvantages of the Linear Topology:
Fault diagnosis is difficult: Control of the network is not centralized in
any particular node. This means that detection of a fault may have to be
performed from many points in the network.
(a) Fault isolation is difficult: If a node is faulty on the bus, it must be
rectified at the point where the node is connected to the network.
(b) Repeater configuration:

49
(Class - XII: INFORMATICS PRACTICES)

(c) Nodes must be intelligent: Each node on the network is directly


connected to the central bus. This means that some way of deciding
who can use the network at any given time must be performed in
each node.

(iii) THE RING OR CIRCUL AR TOPOLOGY


In this case, each node is connected to two and only two neighbouring nodes.
Data is accepted from one of the neighbouring nodes and is transmitted
onwards to another. Thus data travels in one direction only, from node to node
around the ring. After passing through each node, it returns to the sending
node, which removes it.
Advantages of the Ring Topology:
(a) Short cable length: the amount of cabling involved in a ring
topology is comparable to that of a bus and is small relative to that of
a star. This means that less connections will be needed, which will in
turn increase network reliability.
(b) No wiring closet space required: Since there is only one cable
connecting each node to its immediate neighbours, it is not necessary
to allocate space in the building for wiring closets.
(c) Suitable for optical fibers: Using optical fibers offers the possibility
of very high speed transmission.
Disadvantages of the Ring Topology:
(a) Node failure causes network failure.
(b) Difficult to diagnose faults: The fact that failure of one will affect
all others has. The fact that failure of one will affect all others has
serious implications for fault diagnosis.
(c) Network reconfiguration is difficult.
(iv) The Tree Topology: A variation of bus topology is the tree topology. The
shape of the network is that of an inverted tree with the central root
branching and sub branching to the extremities of the network. Transmission
in this topology takes place in the same way as n the bus topology. In both
cases, there is no need to remove packets from the medium because when a
signal reaches the end of the medium, it is absorbed by the terminators. Tree
topology is best suited for applications which have a hierarchical flow of data
and control. Since the tree topology is a modification of a „pure‟ network
topology, bus topology, it is a hybrid topology.
FULLY CONNECTED
When in a network each host is connected to other directly i.e., there is a
direct link between each host, then the network is said to be fully connected.
This characteristic is termed as full connectivity.

50
(Class - XII: INFORMATICS PRACTICES)

8. NETWORK DEVICES:
(i) MODEM: A modem is a computer peripheral that allows you to connect and
communicate with other computers via telephone lines because ordinary
telephone lines cannot carry digit information, a modem changes the digital
data from your computer into analog data, a format that can be carried by
telephone lines. In a similar manner, the modem receiving the call then
changes the analog signal back into digital data that the computer can digest.
called modulation/demodulation, this transformation of signals is how the
modem received its name. (Modulation is the process of sending data on a
wave, 3 types of modulation techniques are used: AM (Amplitude
Modulation), FM(Frequency Modulation), PM(Phase Modulation))
(ii) RJ-45: RJ-45 is short for Registered Jack-45. RJ-45is an eight-wire
connector, which is commonly used to connect computers on the local area
networks i.e., LANs especially Ethernet. The RJ-45 connector look very
much similar to standard telephone connector (RJ- 11 connector), but it is
wider than RJ-11 as it houses eight wires instead of four.
(iii) Ethernet Card: Ethernet is a LAN architecture developed by Xerox Corp
in association with DEC and Intel .Ethernet uses bus or star topologies and
can support data transfer rates of up to 10 Mbps. The computers that are
part of Ethernet, have to install a special card called Ethernet Card.
(iv) Hub: A hub is a hardware device used to connect several computers
together. A hub contains multiple independent but connected modules of
network and inter- networked equipment. Active hubs electrically amplify
the signal as it moves from one connected device to another. Passive hubs
allow the signal to pass from one computer to another without any change.
(v) Switch: A switch is a device that is used to segment networks into different
subnetworks called subnets or LAN segments. Segmenting the network into
smaller subnets prevents traffic overloading in a network. A switch is
responsible for filtering i.e., transforming data in a specific way and for
forwarding packets(a piece of message being transmitted) between LAN
segments.
(vi) Repeater: A repeater is a device that amplifies a signal being transmitted on
the network. Over distance, the cables connecting a network lose the signal
transmitted. If the signal degrades too much, it fails to reach the destination.
Or if it does arrive, the degradation of the message makes it useless.
Repeaters can be installed along the way to ensure that data packets reach
their destination.
(vii) Bridges: A BRIDGE is a network device that establishes an intelligent
connection between two local networks with the same standard but with
different types of cables.
(viii) Gateway: A Gateway is a network device that connects dissimilar
networks. It establishes an intelligent connection between a local network
and external networks with completely different structures.

51
(Class - XII: INFORMATICS PRACTICES)

10 COMMUNICATION PROTOCOLS
A PROTOCOL is a format description of message formats and the rules that two
or more machines must follow to exchange those messages. Protocol defines
standardized formats for data packets, techniques for detecting and correcting
errors and so on.
(i) HTTP(Hypertext Transfer Protocol)
The HTTP protocol consists of two fairly distinct items: the set of requests
from browsers to servers and the set of responses going back to the other
way.
(ii) FTP(File Transfer Protocol) : This protocol is mainly concerned with
transfer of file.
FTP offers these advantages:
(a) It is very useful to transfer files from one network in an organization to
another.
(b) It is an effective way to get a geographically dispersed group to co-
operate on a project.
(c) It is potent and popular way to share information over the internet.
(iii) TCP/IP(Transmission Control Protocol/Internet Protocol)
TCP/IP is a layered set of protocols. TCP/IP model assumes that there are a
large number of independent networks connected together by gateways. The
user should be able to access computers or other resources on any of these
networks.
(iv) SLIP/PPP: Slip(Serial Line Internet Protocol), PPP(Point to Point
Protocol)
PPP is the Internet Standard for transmission of IP packets over serial lines.
The Point-to- Point
(a) Protocol(PPP), is currently the best solution for dial-up Internet
connections, including ISDN.
11 INTERNETWORKING TERMS AND CONCEPTS
(i) WWW (World Wide Web): The world wide web (WWW) is a set of
protocols that allows you to access any document on the Net through a
naming system based on URLs. WWW also specifies a way- the hypertext
Transfer protocol(HTTP) – to request and send a document over the
internet. URL mean Uniform Resource locator.
WWW Attributes
(a) User Friendly
(b) Multimedia Documents: Information on the Web, which may be
graphics, audio, video, animations and text is viewed in pages. A Web

52
(Class - XII: INFORMATICS PRACTICES)

page is a document on the Internet that can contain text plus any of
these multimedia elements.
(c) Hypertext and Hyperlinks: A hypertext file is a document that can
incorporate text, graphic images, audio and video tracks, and most
importantly, dynamic links to relates files or documents, even on net.
These dynamic links are called hyperlinks.

(ii) Telnet: It is an Internet utility that lets you log onto remote computer
systems.
(iii) Web Browser and Web Server: A Web Browser is a WWW client that
navigates through the World Wide Web and displays web pages. A Web
Server is a WWW server that responds to the requests made by web
browsers.
(iv) Web Sites, Web Addresses and Web Pages: A location on a net server
is called a web site. Each web site has a unique address called URL(Uniform
Resources Locator).
(v) URL and Domain Names: The Internet structure of the World Wide Web
is built on a set of rules called Hypertext Transfer Protocol(HTTP) and a
page description language called Hypertext Markup Language(HTML).
HTTP uses Internet address in a special format called a Uniform Resource
Locator or URL.
Syntax Elements of URLs
URL(Uniform Resource Locator) is an address of a file on Internet. A file‟s
Internet address or URL is determined by:
 The type of server or protocol
 The name/address of the server on the Internet
 The location of the file on the server( this location may be related as
“path” through the file hierarchy)

The naming scheme by which servers are identified is also known as domain
name system.
DEF: A URL (Uniform Resource Locator) specifies the distinct
address for each resource on the Internet. An Internet address
which is character based is called a Domain Name.
Web Page: The document residing on web sites are called web pages.
The web pages use HTTP.
(a) Home Page. It is the top-level web page of a web site. When a web-
site is opened, its home page is displayed.
(b) Web portal. It is a web site, which hosts other web sites. In other
words. A web portal has hyper links to many other web sites. By

53
(Class - XII: INFORMATICS PRACTICES)

clicking upon these links the corresponding web sites can be opened.
www.yahoo.com is an example of web portal. Other examples are:-
www.indiatimes.com , www.khoj.com etc.

(vi) WEB HOSTING


D E F : Web hosting is a means of hosting web server application on a
computer system which electronic contents on the Internet is readily
available to any web browser client. The computer system providing
the web hosting web-server or the web host.
(vii) HTML. Everything on the web is a document written in a special language
called HTML or Hypertext Markup Language. This language tells the
browsers like Mosaic or Internet Explorer or Netscape how to display text,
picture and links on the screen.

HTML is a document-layout and hyperlink-specification language i.e., a


language used to design the layout of the document and to specify the
hyperlinks. HTML tells a browser how to display the contents of a hypertext
documents i.e., a documents including text, images and other support
media. The language also tells the browser how to make a document
interactive through special hyperlinks. HTML is a language that supports
multimedia and new page layout features.

HTML provides many layout commands, called tags that let you control
the presentation of information on web pages. For example, there are tags
for various types of headings, lines, image alignment, paragraph alignment,
hyper linking etc.
(viii) XML (extensible Markup Language)
XML is a markup language for documents containing structured
information. Structured information contains both content (words, pictures,
etc.) and some indication of what role that content plays (for example,
content in a section heading has a different meaning from content in a
footnote, which means something different than content in a figure caption
or content in a database table, etc.).
(ix) DHTML (Dynamic HTML)
DHTML refers to Web contents that changes each time it is viewed.
“Dynamic HTML” is typically used to describe the combination of HTML,
style sheets and scripts that allows documents to be animated. Dynamic
HTML allows a web page to change after it‟s loaded into the browser- there
doesn‟t have to be any communication with the web server for an update.
You can think of it as „animated‟ HTML.. for example, a piece of text can
change from one size or color to another, or a graphic can move from one
location to another, in response to some kind of user action, such as clicking
a button.

54
(Class - XII: INFORMATICS PRACTICES)

12 NETWORK SECURITY
The problems encounter under network security can be summarized as follows:
(i) Physical Security holes: When individuals gain unauthorized physical access
to a computer and temper with files. Hackers do it by guessing passwords of
various users and then gaining access to the network systems.
(ii) Software security holes: When badly written programs or „privileged‟
software are compromised into doing things that they should not be doing.
(iii) Inconsistent Usage holes: When a system administrator assembles a
combination of hardware and software such that the system is seriously
flawed from a security point of view.
Protection Methods:
(a) Authorization: determines whether the service provider has granted
access to the web service to the requestor. Basically, authorization
confirms the service requestor‟s credentials. Authorization is
performed by asking the user a legal login-id.
(b) Authentication: ensures that each entity involves in using a web
service- the requestor, the provider, and the broker-is what it actually
claims to be. Authentication involves accepting credentials from the
entity and validating then against an authority.
(c) Authentication is also termed as password-protection, authorized
user is asked to provide a valid password, and if he/she is considered
to be an authentic user.
(d) Encrypted Smart Cards: Passwords in a remote log-in session
generally pass over the network in unencrypted form, any hacker(or
cracker) can simply record it and can use it later maliciously to corrupt
data/files or to harm anyone etc. To counter such threats, encrypted
smart cards are used.
(e) Biometric systems. The biometric systems involve some unique
aspect of a person‟s body such as finger-prints, retinal patterns etc. to
establish his/her identity.
(f) Firewall. A system designed to prevent unauthorized access to or
from a private network is called Firewall. Firewalls can be
implemented in both hardware and software, or a combination of
both. Firewalls are frequently used to prevent unauthorized Internet
users from accessing private networks connected to the Internet,
especially intranets. All messages entering or leaving the intranet pass
through the firewall, which examines each message and blocks those
that do not meet the specified security criteria.
There are several types of firewall techniques:
 Packet filter: looks as each packet entering or leaving the
network and accepts or rejects it based on user-defined rules.

55
(Class - XII: INFORMATICS PRACTICES)

 Application gateway: Applies security mechanisms to specific


applications, such as FTP and Telnet servers.
 Circuit-level gateway: Applies security mechanisms when a
connection is established. Once the connection has been made,
packets can flow between the hosts without further checking.
 Proxy server: Intercepts all messages entering and leaving the
network. The proxy server effectively hides the true network
addresses.

56
(Class - XII: INFORMATICS PRACTICES)

JOINS
=================================== ==========
A join is a query that combines rows from two or more tables1. In a join-query, more than
one table is listed in FROM clause. The function of combining data from multiple tables is
called joining. Consider the following query:

SELECT *
FROM EMP, DEPT;
This query will give you the Cartesian product i.e., all possible concatenations are formed
of all rows of both the tables EMP and DEPT. That is, when no particular rows (using
WHERE clause) and columns (through SELECT list) are selected. Such an operation is
also known as unrestricted join. It returns n1 × n2 rows where n1 is number of rows in
first table and n2 is number of rows in second table.

In unrestricted join or Cartesian product of two tables, all possible concatenations are
formed of all rows of both the tables.

DEF. A join is a query that combines rows from two or more tables.
But joining is not this at all. It is much more useful in many situations where we need to
derive data from more than one table. Consider the following example.

Looking at the EMP table we can see that we have a column called DEPTNO. Suppose
we also have a table called DEPT (which indeed is available in the sample database
provided by Oracle), which carries attributes such as department number, department
name, and location of the department.

Here is the data stored in that table:


SQL > SELECT * FROM DEPT;
DEPTNO DNAME LOC
…………….. …………… ………….
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
Now suppose we need to know the office location for the employee named „CLARK‟.
In reviewing the DEPT table above we note that department 10 is in „NEW YORK‟ but
the table does not include the employee‟s name field.

By reviewing the EMP table below we can see that „CLARK‟ works in department 10 but
the location of that department is not contained within this table.
…………………………………………………………………………………………………..

57
(Class - XII: INFORMATICS PRACTICES)

1. A join can combine views also. A view is a stored query that appears like a table
and can be used like a table.
Table 17.1 : EMP
EmpNo EmpName Job Mgr Hiredate Sal Comm Dept
No. SEL
7839 KING PRESIDENT 17-NOV-81 5000 10 EC
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 T st
7782 CLARK MANAGER 7839 09-JUN-81 2450 10 ate
7566 JONES MANAGER 7839 02-APR-81 2975 20 me
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 nts?
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 An
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 d th
7900 JAMES CLERK 7698 03-DEC-81 950 30 ea
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 nsw
7902 FORD ANALYST 7566 03-DEC-81 3000 NULL er is
7369 SMITH CLERK 7902 17-DEC-80 800 NULL joi
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20 n-Q
uer
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
y. L
7934 MILLER CLERK 7782 23-JAN-82 1300 NULL
et u
sNow
see how we can doisthis.
the question : How do we get this information without doing two separate

Since both the EMP table and the DEPT table carry the column DEPTNO, we can join
the tables on this common column and relate rows from the DEPT table with rows in the
EMP table. In doing this, we are creating a victual table (a table created in main
memory)which contains all the attributes for rows from the DEPT table and the EMP table
where the DEPTNO is equal. The virtual table contains the following attributes: DEPTNO,
DNAME, LOC, EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM.

In ORACLE we are able to join a multitude of tables together in this fashion. Be aware
that the more tables we join, the more complicated the query becomes.

In order to find the location of the employee named CLARK; we would use the following
query.
SQL> SELECT ENAME, LOC
FROM EMP, DEPT
WHERE ENAME = „CLARK‟
AND EMP.DEPTNO = DEPT.DEPTNO; see this is join condition
And here comes your desired result:
ENAME LOC
……….. ………..
CLARK NEW YORK

58
(Class - XII: INFORMATICS PRACTICES)

The virtually joined table that we created, consists of one row that meets the specifications
of the WHERE clause (ENAME = „CLARK‟). Since we selected only ENAME and LOC
fields, only those columns were retuned. However, we can retrieve as many attributes
from each table as we need.
Thus we can say that a join is used when a SQL query requires data from more than one
table on database. Joins can compare two or more tables (or views) by specifying a
column from each, comparing the values in those columns row by row and concatenating
rows that have matching values. The FROM clause is used to specify which tables and
views have to be joined. The columns being joined must have same or comparable
datatypes.
The FROM clause lists all the tables involved and WHERE clause specifies the join.
Without a WHERE clause, each row of the first table will be joined with every row of the
second table which results in a Cartesian Product. Multiple conditions can be
incorporated in the WHERE clause using the logical operators AND, OR and NOT. And
the relational operators =, >, <, >=, <= , <> are used as join operators.
Now consider the following example.
Example1.1.Display details like department number, department name, employee
number, employee name, job, and salary. And order the rows by employee
number with department number.
Solution. SQL>SELECT EMP.DEPTNO, DNAME, EMPNO, ENAME,
JOB, SAL FROM EMP, DEPT
WHERE EMP.DEPTNO = DEPT.DEPTNO -- join on DEPTNO
ORDER BY EMP.DEPTNO, EMPNO;
The output produced by this query will be as shown below:
DEPTNO DNAME EMPNO ENAME JOB SAL
10 ACCOUNTING 7782 CLARK MANAGER 2450
10 ACCOUNTING 7839 KING PRESIDENT 5000
10 ACCOUNTING 7934 MILLER CLERK 1300
20 RESEARCH 7369 SMITH CLERK 800
20 RESEARCH 7566 JONES MANAGER 2975
20 RESEARCH 7788 SCOTT ANALYST 3000
20 RESEARCH 7876 ADAMS CLERK 1100
20 RESEARCH 7902 FORD ANALYST 3000
30 SALES 7499 ALLEN SALESMAN 1600
30 SALES 7521 WARD SALESMAN 1250
30 SALES 7654 MARTIN SALESMAN 1250
30 SALES 7698 BLAKE MANAGER 3750
30 SALES 7844 TURNER SALESMAN 1500
30 SALES 7900 JAMES CLERK 950
14 rows selected.

59
(Class - XII: INFORMATICS PRACTICES)

Using Table Aliases


Consider once again the query given in example 1.1. Don‟t you find something
unusual about this query? Since we wanted to list DEPTNO as part of the output
and this attribute resides within each table, we had to tell ORACLE which table (it
doesn‟t matter which one) we wanted to use to extract DEPTNO. When you have
an attribute, which resides in more than one table if you do not specify the table in
the SELECT statement you will get an ambiguity error. For example had we given
the following query for example 1.1:

SQL > SELECT DEPTNO, DNAME, EMPNO, ENAME, JOB, SAL


FROM EMP, DEPT
WHERE EMP DEPTNO = DEPT.DEPTNO
ORDER BY DEPTNO, EMPNO;
Oracle would have shown us the error as given below:
ERROR at line 1:
ORA – 00918: column ambiguously defined
That means every time you have to refer to a column, which is in more than one
table participating in the join query, you have to qualify the column name by
giving its table name along with it. Doesn‟t this method require more typing since
for every such column, table name is to be typed? But don‟t worry; there is a
shorter way of doing so – the table aliases. A table alias can be used anywhere in
the SELECT statement.
D E F. A Table Alias is a temporary label given along with table name in FROM
clause.
To cut down on the amount of typing required in you queries you can use aliases
for table names in the SELECT and WHERE clauses. For example, if you wanted
to use the abbreviation „E‟ for the EMP table in your query all you need to is tell
ORACLE that EMP will be reference by E in the FROM clause. The following
queries would result in the same output:
SQL>SELECT E.DEPTNO, DNAME, EMPNO, NAME, JOB, SAL
FROM EMP E, DEPT -- table alias E used for
table EMP
WHERE E.DEPTNO = DEPT.DEPTNO -- join on field DEPTNO
ORDER BY E.DEPTNO, EMPNO;
SQL>SELECT E.DEPTNO, DNAME, EMPNO, ENAME, JOB, SAL
FROM EMP E, DEPT D -- table alias E for table
EMP,
-- table alias D for table
DEPT
WHERE E.DEPTNO = D.DEPTNO -- join on field DEPTNO
ORDER BY E.DEPTNO, EMPNO;

60
(Class - XII: INFORMATICS PRACTICES)

Additional Search Conditions in Joins


Once you have joined tables, you can filter information from joined table by
incorporating additional search conditions. For example, refer to example 1.1 once again.
If you want to extract such information only for SALES department, you can do so by
giving a query similar to the one given in example 1.2.
Example 1.2 Refer to example 1.1. Do this only for SALES department.
Solution: SQL>SELECT E.DEPTNO, DNAME, EMPNO, ENAME, JOB, SAL
FROM EMP E, DEPT D
WHERE E.DEPTNO = D.DEPTNO
AND DNAME = „SALES‟
ORDER BY E.DEPTNO, EMPNO;
And now the output produced will be:
DEPTNO DNAME EMPNO ENAME JOB SAL
30 SALES 7499 ALLEN SALESMAN 1600
30 SALES 7521 WARD SALESMAN 1250
30 SALES 7654 MARTIN SALESMAN 1250
30 SALES 7698 BLAKE MANAGER 3750
30 SALES 7844 TURNER SALESMAN 1500
30 SALES 7900 JAMES CLERK 950
Non-Equi-Joins
The comparison operator used in the join condition was the equal sign “=”. Such join
queries are called equi-joins. A non-equi-join is a query that specifies some relationship
other than equality between the columns.
Example 1.3. Display employee details for Analysts in the following format.
Ename Job Sal Grade
Solution. SQL >SELECT ENAME, JOB, SAL, GRADE
FROM EMP E, SAL GRADE S
WHERE SAL BETWEEN LOSAL AND HISAL -- non-equi-join
condition
AND JOB = „ANALYST‟;
And the output produced is:
ENAME JOB SAL GRADE
SCOTT ANALYST 3000 4
FORD ANALYST 3000 4
Natural Join
By definition, the results of an equijoin contain two identical columns (see in the result of
previous query, Item# appears twice). One of the two identical columns can be
eliminated by restating the query. This result is called a Natural Join (Equi-join minus one
of the two identical columns).
D E F. The join in which only one of the identical columns (coming from joined tables)
exists, is called Natural Join.
=============================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
=============================================

61
(Class - XII: INFORMATICS PRACTICES)

PR ACT I CA L FI L E Q UE ST I O N S
Q.1. Given a GUI application having a layout as shown
Print even nos and their sum
Enter n 10 inpTF

Print PrnBtn

reslbl 1 3 5 7 9 25 reslb2

Q.2. Design an application that performs arithmetic operations (+, -, *, and


/). The sample screenshot is being show below.
Add 34
Subtract + 90

Multiply 56

Divide Clear

Q.3. During a special sale at a store, a 10% discount is taken on purchases


over Rs. 1000/-. Write a program that asks for the amount of purchases, then
calculate the discounted price. The purchase amount will be input in Rs :

Calculate
Enter Amount of Purchases

Discount =

Discounted price :

Q.4. The given form calculates the LCM of two numbers.


LCM Calculator
Number 1 6

Number 2 8

LCM 24

Compute LCM LCM Btn

Write code for the button (compute LCMBtn) to print the LCM in the label (lblLcm).

62
(Class - XII: INFORMATICS PRACTICES)

Q.5. The given form calculates the GCD(HCF) of two numbers. Write code for
the command button (cmdGcd) to print the GCD in the label (lblGcd).

G C D Calculator
Num1TF(Text field) Num 1
GCDLable(Label)
GCD
Num1TF(Text field) Num 2

GCD GCDBtn(Button)

Q.6. FRX Consultancy is registering job seekers for placement. Their basic
entry form has following features :
Name NameTF(text field)

Gender Qualification
Intermediate InterCB(Check box)
MaleRB(Radio button) Male
Graduate GradCB(Check box)
FemaleRB(Radio button) Female
Post Graduate PgtCB(Check box)
ClearBtn(Button) Clear

SubmitBtn(Button) Submit

(i) All the characters entered in text field should be converted into uppercase
characters.
(ii) When submit button SubmitBtn is clicked the following things should
happen :
(a) If checkbox PgtCB is selected checkboxes GradCB and InterCB
should also get selected.
(b) If GradCB is selected InterCB should also be selected.
(c) A message box should ClearBtn is clicked the textbox, checkboxes
and the option button should be set to Male.
Write the codes under specific events for the above requirements.
Q.7. Department of Human Resources along with Department of Higher
Education wants to conduct an online survey of school students time
spending habits and their subject choices. It will help them design a
better education policy and create better placement opportunities.
Design a GUI application for this online survey.
Q.8. A class Telcall calculates the monthly phone bill of a consumer. Some
of the members of the class are given below :
Class Name : Telcall
Data members/instance variable :
phno : phone number
name : name of consumer

63
(Class - XII: INFORMATICS PRACTICES)

n : number of calls made


amt : bill amount
Member functions/methods :
Telcall( ) : Parameterised constructor to assign
values to data members
void compute( ) : to calculate the phone bill amountbased on the slabs
given below
void dispdata( ) : to display the details in the specified format

Number of calls Rate


1 – 100 Rs 500/- rental charges only
101 – 200 Rs 1.00 per call + rental charge
201 – 300 Rs 1.20 per call + rental charge
Above 300 Rs 1.50 per call + rental charge

The calculations need to be done as per the slabs.


Specify the class Telcall, giving the details of the constructor, void compute ( ) and
void dispdata( ). In the main function, create an object of type Telcall and display
the phone bill in the following format :
Phone Number Name Total calls Amount
XXXXXXXXXX XXX XXXXX XXXX

Q.9. Design a class to represent a bank account. Include the following


members :
Data members
(i) Name of the depositor
(ii) Account number
(iii) Type of account
(iv) Balance amount in the account
Design a GUI application having following interface :
Bank Account
Deposit Withdraw Statement

Transaction Amount 1700


Account Status
Account No : 1234
Current balance : 5700
Last transaction type : Deposit

Add functionality to above application by creating required methods and


implementing them.

64
(Class - XII: INFORMATICS PRACTICES)

Q.10.Write a method that take a number as argument and displays the sum of
all the digits in the number. For example if the argument passed is 354,
the procedure should display 12 (i.e. 3 + 5 + 4).
Implement the method through a GUI application that obtains a number
in a text field, computes the sum of its digits and displays in a label.
Q.11.Create an application that lets you enter a film’s details like name, year,
awards and nominations through a table and when the user clicks at
Add to Library button the film’s details get added to the Library table.
The library table is un-editable otherwise; the entries to it can be made
only by clicking the add to Library button.
Enter Film Details below FILMS IN MOVIE LIBRARY
Name Babel ADD Name Year Awards Nominations
Year 2006 TO The Aviator 2004 5 11
Awards 1 LIBRARY Atonement 2007 1 7
Nominations 7 Babel 2006 1 7

Q.12.Create a Java GUI application that lets you create an address book. The
details to be added in Address Book are : Name, Email ID, Phone. Add
search facility to find a column value and report it. (Refer Page no. 312)
Q.13.Assume that a bank maintains two kinds of accounts for customers, one
called as savings account and the other as current account. The savings
account provides compound interest and withdrawal facilities but not
cheque book facility. The current account provides cheque book facility
but not interest. Current account holders should also maintain a
minimum balance and if the balance falls below this level, a service
charge is imposed.
Create a class Account that stores customer name, account number and opening
balance.
From this derive the classes Current and Savings to make them more specific to
their requirements. Include necessary member functions in order to achieve the
following tasks :
(i) deposit an amount for a customer and update the balance
(ii) display the account details
(iii) compute and deposit interest
(iv) withdraw amount for a customer after checking the balance and update the
balance.
(v) check for the minimum balance (for current account holders), impose
penalty, if necessary, and update the balance.
Implement these without using any constructor.

65
(Class - XII: INFORMATICS PRACTICES)

Q.14. class D2Point defines the coordinates of a point in a plane while


another class D3Point defines the coordinates of a point in space. The
details of both the classes are given below :
Class name : D2Point
Date members double x,y To store the x and y coordinates
Functions/methods :
D2Point( ) Constructor to assign 0 to x
D2Point(double nx, double ny) Constructor to assign nx to x and ny to y
double distance 2d (D2Point b) to return the distance between the point b
and the current point in a plane.
Class name : D3Point
Date members double z To store the z coordinate.
Functions/methods :
D3Point( ) Constructor to assign 0 to z
D3Point(double nx, double nz) Constructor to assign nz to z
double distance 3d (D3Point b) to return the distance between the point b
and the current point in space.
If x1, y1, z1, x2, y2, z2 be the coordinates of the two points, then the distance
between the points in a plane is given by the formula :
(x2-x1)2 + (y2-y1)2
And the distance between the points in space is given by the formula :
(x2-x1)2+(y2-y1)2 + (z2-z1)2
Specify the class D2Point giving the details of the two constructors and function
double distance2d(D2Point b). Using the concept of inheritance specify the class
D3Point giving the details of the two constructors and function double
distance3d(D3Point b). You do not need to write the main function.
Q.15.A class Student defines the personal data of a student while another
class Marks defines the register number, name of subject and marks
obtained by the student. The details of both the classes are given below
Class name : Student
Date members / instance variables :
name [ ] , sex [ ] : array of characters.
age : integer variable
Member functions / methods :
void inpdetails l ( ) : to accept value for data members
void show l ( ) : to display personal data of student
Class name : Student
Date members / instance variables :
regnum, marks : integer type variables.
subject[ ] : array of characters
Member functions / methods :
void inpdetails l ( ) : to accept value for data members

66
(Class - XII: INFORMATICS PRACTICES)

void show l ( ) :to display exam details (regnum,


marks, subject)
(i) Specify the class Student giving details of the functions void inpdetails1( )
and void show1( )
(ii) Using the concept of inheritance, specify the class Marks, giving the details of
the functions void inpdetails2( ) and void show2( ). The main function
need not be written.
Q.16.An application counts the number of vowels in a string. Write the
suitable code under the command button CountBtn to achieve this goal.

Ram is a good boy

CountBtn Vowel Counter 7

Q.17.Design an application that accepts a string and two integers from user.
It then changes the case of characters at those indices as specified by two
integers entered by the user.
Refer to following sketch for designing interface.
Enter a string A Sample string

Enter two integers 3 9

Submit

Output string is

A sample string

Q.18.An application counts the occurrence of a particular character in a


string. Write the suitable code under the command button countBtn to
achieve this goal.

Sentence STF(text field)

Search Char charTF(text field)

Count Occurance
CountBtn(Button) OccurLable(label)

Q.19.Write a suitable code under the command button cmdRev to reverse the
input string in text box txtIn and display it in the text box txtRev. The code
should not include the StrReverse() library function.

67
(Class - XII: INFORMATICS PRACTICES)

String StringTF(text field)

Reverse RevTF(Text field)

RevBtn(Button) Reverse

Q.20.An application changes first letter of each word in a text box to upper
case and displays the modified sentence in the same text box. Write the
suitable code under the command button CaseBtn to achieve this goal.

Enter a sentence TF(text field)


to be modified

Sentence Case CaseBtn


(button)
Q.21.Program to check whether a string is a palindrome or not.

Palindrome Test

Enter a string (text field)

Perform Palindrome Test (button)

(label)

Q.22.Create an Edit menu with following menu control captions and its
property settings respond to the corresponding keys.
Menu Control Caption Caption Property Access Keys
Cut Cu & t t
Copy C & opy o
Paste & Paste p
Delete De & lete l
Select All Select & All a
Time / Date Time / & Date d
Q.23.Design a GUI application that first obtains Login Id and password from
the user.
(i) If the correct password (Which is “Proceed”) is entered, then a new form –
Email Form – is shown on the screen that obtains details like : From :, To:,
Subject: and Email text.
In the Email form,
(a) if user clicks at Send button then a dialog pops up saying that
“Message has been sent successfully.” And the Email Form closes.
(b) If the user clicks at Discard button then Email Form simply closes.

68
(Class - XII: INFORMATICS PRACTICES)

(ii) If the user enters incorrect password, then a dialog pops up saying that
“Invalid pass word”.
(iii) On the dialog, if the user clicks OK button, the dialog simply disappears.
Q.24.Design an application that obtains the rollnumber of a student and
searches in a list containing the details of students who have passed an
entrance exam. The details in the list are in the form <rollnumber>-
<name> and are listed rank wise. The topmost rank holder’s details are
at position 1, and the lowest rank holder’s details are at the last
position.

69
(Class - XII: INFORMATICS PRACTICES)

DATA B A SE CO N NECT I VIT Y

Q.1. Design a data connectivity application that fetches data from EMPL
table and has an interface as shown below :

Fields for display Sort Criterion Filters


Empno
Ename O Salary Job MANAGER
Job O asc
Mgr O Deptno
Hiredate O desc
O Hire Date Deptno ANY
Sal
Comm
Deptno

Empno Ename Job Mgr Hiredate Sal Comm Deptno


8698 BINA 8839 2850.0 0.0 30
8566 MAHADEVAN 8839 2985.0 0.0 20
8882 SHIAVNSH 8839 2750.0 0.0 10

The application works as per following specifications :


(i) The user should be able to choose any field(s) in the select list
(ii) The sort criteria should be decided by user for Order By clause
(iii) The filtering conditions for where clause should be specified by user for Job
and / or dept no fields. Go only for equality comparisons.
(iv) As per the specified details the data should be fetched from EMPL table and
shown in the tabular format.
Q.2. A studentGrade database contains two very simple tables. One holds
student information and the other holds assignment grade information. What
you need to do is to provide a very rudimentary interface to the database
allowing for some simple manipulation of the data. You will need to allow the
user to :
(i) View the details of specific student after obtaining his/her roll no.
(ii) Add grades for an assignment.
(a) You will need to prompt the user for the assignment number, and
then prompt the user for each student‟s grade. When asking for the
grade make sure you display the student‟s name and the assignment
number (i.e., Please enter Joe Smith‟s Assignments 5 Grade.
(iii) Change a grade for an assignment (i.e., this should work on only one
student).

70
(Class - XII: INFORMATICS PRACTICES)

W E B DE SI GN IN G
Q.1. Create a webpage that received pizza orders through a web form as
shown below :
Pizza Factory
Pizza order form
Name
Address
Size Toppings
O Small Cheese
O Medium Olives
O Large Pepperoni
Bacon
Process Order Clear

Q.2. Create a XML document to represent a quiz where each question comes
with four possible answers, but there is only one correct answer.
Render this XML-document on a web browser.
Q.3. Create an XML document to represent your marksheet.
(i) Create a stylesheet for this and open it in browser.
(ii) Try to render it in multiple ways by creating multiple stylesheets.
(iii) Check whether your XML-document is well-formed and valid or not.

71
(Class - XII: INFORMATICS PRACTICES)

SQL
Q.1.
Table: HOSPITAL
NO NAME AGE D_CODE DATOFADM CHARGES SE X
1 Sandeep 65 D101 23-Feb-2006 300 M
2 Ravina 24 D105 20-Jan-2006 200 F
3 Karan 45 D105 19-Feb-2006 200 M
4 Tarun 12 D101 01-Jan-2006 300 M
5 Zubin 36 D108 12-Jan-2006 250 M
6 Ketaki 16 D108 24-Feb-2006 300 F
7 Ankita 29 D120 20-Feb-2006 800 F
8 Zareen 45 D115 22-Feb-2006 300 F
9 Kush 19 D120 13-Jan-2006 800 M
10 Shailya 31 D125 19-Feb-2006 400 F

Table : DEPARTMENT
D_CODE DEPARTMENT DOCTOR
D101 Surgery Dr.D.Nayar
D105 Orthopedic Dr.M.Roy
D108 ENT Dr.K.Bhatia
D115 Gynecology Dr.P.Tejpal
D120 Cardiology Dr.D.Singh
D125 Nuclear Medicine Dr.A.Banerjee

(i) To show information about the patients of cardiology department.


(ii) To list names of female patients with their date of admission in ascending
order.
(iii) To list name of patients who are admitted after 15-Jan-2006.
(iv) To display Patients name and name of the Doctor with their Department.
(v) To count the number of patients with age> 30.
(vi) To insert a new row in the Hospital table with following data:
11 Rakesh 40 D125 25-Feb 2006 350 M

(vii) To reduce charges by 10% for all female patients.


(viii) To add a new column named MOBILENO of Number(10) in the table
Department.
(ix) To calculate average charges of the patients in each department.
(x) To delete Zareen from hospital table

72
(Class - XII: INFORMATICS PRACTICES)

Q.2.
Table: INTERIORS
NO ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT
1 Red rose Double Bed 23-Feb-2006 32000 15
2 Soft touch Baby cot 20-Jan-2006 9000 10
3 Jerry‟s home Baby cot 19-Feb-2006 8500 10
4 Rough woof Office table 01-Jan-2006 20000 20
5 Comfort zone Double bed 12-Jan-2006 15000 20
6 Jerry look Baby cot 24-Feb-2006 7000 19
7 Lion king Office table 20-Feb-2006 16000 20
8 Royal tiger Sofa 22-Feb-2006 30000 25
9 Park sitting Sofa 13-Dec-2005 9000 15
10 Dine Paradise Dining Table 19-Feb-2006 11000 15

(i) To show all information about the Sofa‟s from the interiors table.
(ii) To list the item name which are priced at more than 10000 from the interiors
table?
(iii) To display item name and date of stock of those items, in which the discount
(iv) Percentage is more than 15 from interiors table.
(v) To list item name and type of items, in which data of stock is before 22-Jan-
2002
(vi) from the interiors table in descending order of item name.
(vii) To count the number of items of each type from interiors table.
(viii) To insert new row in interiors table with following data:
11 White wood Double Bed 23-Feb-2006 20000 20
(ix) To count distinct types from interiors table.
(x) To find average discount from interiors for each type of interiors.
(xi) To calculate sum of price from interiors where data of stock is before 12-
Feb-2002
(xii) To increase price of all Office table by 3000 from interiors table.
Q.3.
Table : GAMES
GCO D E GAMENAME NUMBER PRIZEMONEY SCHEDULEDATE
101 Carom Board 2 5000 23-Jan-2006
102 Badminton 2 12000 12-Dec-2005
103 Table Tennis 4 8000 14-Feb-2006
105 Chess 2 9000 01-Jan-2006
108 Lawn Tennis 4 25000 19-Nov-2005

73
(Class - XII: INFORMATICS PRACTICES)

Table : PLAYER
PCODE NAME GCO D E
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
(i) To display the names of all games where schedule data is after 31-Dec-
2005.
(ii) To display the name of the players in the table player with their
gamesname.
(iii) To display the content of the games table in ascending order of schedule
date.
(iv) To display the sum of prize money received by players in the table player.
(v) To add a new column (attribute) ADDRESS of type Character(20) in the
table
(vi) PLAYER.
(vii) To display maximum and minimum schedule date.
(viii) To change the prize money for Chess from 9000 to 10000.
(ix) To display unique gcodes from players.
(x) To delete all rows from games table where schedule date was before 01-Jan-
2006.
(xi) To insert a new record in the player table as follows:
5 Anand 105
Q.4.
Table STOCK
NO ITEMCODE QUANTITY DATEOFPURCHASE WARRANTY
1 C201 9 21-May-2005 2
2 P1010 3 21-May-2005 4
3 S203 1 29-Sep-2004 3
4 C201 2 13-Jun-2005 1
5 P1010 1 31-Oct-2004 2
6 U34 5 21-May-2005 1
7 P1010 2 11-Jan-2006 2
Table: ITEM
ITEMCODE ITEMNAME PRICE
C201 Computer 39000
P1010 Printer 11000
S203 Scanner 4500
WC05 Camera 1200
U34 UPS 1900

74
(Class - XII: INFORMATICS PRACTICES)

(i) To select item purchased after 31-Jan-2005.


(ii) To list the item name in descending order of date of purchase where
quantity is more than three
(iii) To count number of Items (total quantity) whose cost is more than 10000.
(iv) To insert a new record in the table STOCK with following data:
8 C201 5 13-Jun-2005 1
(v) To find minimum distinct item type (itemcode) from STOCK.
(vi) To generate a report on each item code with the item name and total value
(quantity * Price).
(vii) To find average cost of all items with more than 2 items.
(viii) To find average cost of items with date of purchase is before 1-Jan-2005.
(ix) To reduce the cost of all UPS by 100.
(x) To delete the table STOCK.
Q.5.
Table : BOOKS
BOOK_ID BOOK_NAME AUTHOR_NAME PUBLISHERS Rs. TYPE QTY.
C0001 Fast Cook Lata Kapoor EPB 355 Cookery 5
F0001 The Tears William Hopkins First Publishers 650 Fiction 20
T0001 My First C+ + Brains & Brroke EPB 350 Text 10
T0002 C+ + A.M.Rossaine TDH 350 Text 15
Brainworks
F0002 Thunderbolts Anna Roberts First Publishers 750 Fiction 50
Table : ISSUED
BOOK_ID QUANTITY_ISSUED
T0001 4
C0001 5
F0001 2
(i) To show book name, author name and price of books of First Publishers.
(ii) To list the names from books of Text type.
(iii) To display the names and price from books in ascending order of their price.
(iv) To increase the price of all books of EPB publishers by 10%.
(v) To display the book id, book name and quantity issued for all books which
have been issued.
(vi) To insert new row in the table issued having the following data:
(vii) „F3003‟, 1
(viii) To display the total no. of books (quantity) of each type.
(ix) To find the maximum price from books which have quantity more than 15?
(x) To count unique publishers from books & cost less than 400.
(xi) To display the no. of titles available of each publishers.

75
(Class - XII: INFORMATICS PRACTICES)

JAVA PRACTICE QUESTIONS


(i) Events : Occurrence of some action.
(ii) Event handlers : Where you write the cod.
(iii) Clear Text button : Put “ “ in setText( );
(iv) Exit button : System.exit( 0 ) ;
General format of writing Java Code
(i) Code on “exit” Button
System.exit (0);

(ii) Code on “clear” button


Textboxname.setText(“”);
[ All the textboxes setText property to empty cotes. That cleans its contents]

(iii) Code for disabling certaining components on


Form_Wad Event or
windowGainedFocus event handler
txtbox.enable(false);
Q.1. Read the following case study and answer the questions that follow:
Naveen electronics has the following products with their list prices
given. The store gives a 10% discount on Product. However at the time
of festival seasons, the store gives further 7% discount after 10%.
Product Name List Price Discount Price
Washing Machine 12000 …………
Color Television 17000 …………
Refrigerator 18000 …………
OTG 8000 …………
CD Player 14500 …………

Note that the Product Name is stored in JCombo Box control.

76
(Class - XII: INFORMATICS PRACTICES)

The list of controls for the above form is as follows :


Control Type Control Name Property Name Property Value
JFrame NaveenUI title Naveen Electronics
JLabel JLabel1 text Customer Discount
JLabel2 text Product Name
JLabel3 text List Price
JLabel4 text Discount
JLabel5 text Net Price
TextField TextField1 text [None]
Variable Name txtLPrice
TextField2 text [None]
Variable Name txtDiscount
TextField3 text [None]
Variable Name txtNPrice
JPanel JPanel1 Border
Title Choose a type
JComboBox JComboBox1 Variable Name cmbProduct
ButtonGroup ButtonGroup1
JRadioButton JRadioButton1 text Festival
Variable Name optFest
ButtonGroup ButtonGroup1
JRadioButton2 text Non-Festival
Variable Name optNFest
ButtonGroup ButtonGroup1
JButton JButton1 text List Price
Variable Name cmdList
JButton2 text Discount Price
Variable Name cmdDisc
JButton3 text Net Price
variable Name cmdNet

(i) Write the code to disable the text boxes txtLPrice, txtDisccount and
txtNPrice in the form when the form activated.
(ii) Write the code for List Price button (cmdList) to display the List Price in
txtLPrice.
(iii) Write the code for Discount Price button (cmdDisc) to calculate discount
price in txtDiscount.
(iv) Write the code for Net Price button (cmdNet) to calculate the net price in
txtNPrice.
(v) Write the code for cmdExit to exit the application.

77
(Class - XII: INFORMATICS PRACTICES)

SOLUTION
(i) Right click on form IntCalUI. Select Events >> WindowFocus>>
windGained focused. Notice that a formWindowGainedFocus event handler
appears with a // TODO marker line. Write the following lines,
txtLPrice.enable(false);
txtDiscout.enable(false);
txtNPrice.enable(false);
(ii) Double click on the List Price button. Notice that a cmdListActionPerformed
event handler appears with a // TODO marker line. Write the following lines,
String Product=cmbProduct.getSelectedItem().toString();
If (Product.equals(“Washing Machine”)){
txtLPrice.setText(“12000”);
} else if (Product.equals(“Color Television”)) {
txtLPrice.setText(“17000”);
} else if (Products.equals(“refrigerator”)) {
txtLPrice.setText(“18000”);
} else if (Product.equals(“OTG)){
txtLPrice.setText(“8000”);
} else if (Product.equals(“CD Player”)) {
txtLPrice.setText(“14500”);
}
(iii) Double click on the Discount Price button. Notice that a
cmdDiscActionPerformed event handler appears with a // TODO
marker line. Write the following lines,
float ProductPrice, Discount;
ProductPrice = Float.parseFloat(txtLPrice.getText());
// Calculating Discount Price
If ( optFest.is Selected()){
Discount = ProductPrice * 7/100;
} else {
Discount = ProductPrice *10/100;
}
txtDiscount.setText( Float.toString( Discount));
(iv) Double click on the Net Price button. Notice that a cmdNetActionPerformed
event handler appears with a // TODO marler line. Write the following lines,
Float NetPrice;
NetPrice = Listprice-Discount
NetPrice = Float.parseFloat(txtLPrice.getText()) –
Float.parseFloat(txtDiscount.getText());
txtNPrice.setText(Float.toString(NetPrice));

78
(Class - XII: INFORMATICS PRACTICES)

Q.2. Read the following case study and answer the questions that follows :
The Pizza Café has computerized its billing. The following is the data
entry screen used at their outlet. The outlet offers two different types of
pizzas, regular and pan pizzas. The price of a regular pizza is Rs. 120
and that of a pan pizza is Rs. 160. The user can choose to have three
different types of extra toppings of he wants. Extra toppings costs as :
Toppings Cost
Cheese 40
Capsicum 20
Pepperonion 25

The list of controls for the above form is as follows :


Control Type Control Name Property Name Property Value
JFrame PizzaUI Title Pizza Café
JLabel JLabel1 text Pizza Café
JLabel2 text Customer Name
JLabel3 text Quantity
JLabel4 text Rate
JLabel5 text Cost of toppings
JLabel6 text Amount
TextField TextField1 text [None]
Variable Name txtName
TextField2 text [None]
Variable Name txtQty
TextField3 text [None]
Variable Name txtRate
TextField4 text [None]
Variable Name txtTop
TextField5 text [None]
Variable Name txtAmount

79
(Class - XII: INFORMATICS PRACTICES)

JPanel JPanel1 Border


Title Pizza Type
Jpanel2 Border
Title Toppings
ButtonGroup ButtonGroup1
JRadioButton JRadioButton1 Text Regular
Variable Name optRegular
ButtonGroup ButtonGroup1
JRadioButton2 text Pan
Variable Name optPan
ButtonGroup Button Group1
JCheckBox JCheckBox1 text Cheese
Variable Name chkCheese
JCheckBox2 text Capsicum
Variable Name chkCap
JCheckBox3 text Pepperonion
Variable Name chkPep
JButton JButton1 text Calculate Rate
Variable Name cmdCalcRate
JButton2 text Calculate Amount
Variable Name cmdCalcAmt
JButton3 text Clear
Variable Name cmdClear
JButton4 text Exit
Variable Name cmdExit

(i) Write the code for Calculate Rate button to calculate the rate of the pizza
and display it in txtRate depending on the type of pizza selected by the
customer.
(ii) Write the code for cmdAmount to calculate the total amount and display it in
txtAmount. The total amount is calculated by first finding the cost of extra
toppings selected by the customer. Remember that each extra toppings adds
the value with previous topping. Then add it to the rate and multiply the
resultant amount by the quantity ordered.
(iii) Write the code for Clear button to clear all the text boxes and make default
to Regular Pizza Type and Cheese as Topping.
(iv) Write the code for cmd Exit to exist the application.
SOLUTION:
(i) Double click on the Calculate Rate button. Notice that a
cmdCalcRateActionPerformed event handler appears with a // TODO
marker line. Write the following lines,
If ( optRegular.isSelected())
txtRate.setText(String.valueof(120)); // String.valueOf convert integer to
String
else
if(optPan.isSelected())
txtRate.SetText(String.valueOf(160));

80
(Class - XII: INFORMATICS PRACTICES)

(ii) Double click on the Clear button. Notice that a cmdClearActionPerformed


event handler appears with a // TODO marker line. Write the following lines,
int Top = 0; // topping cost
float amt = 0; // Pizza amount
// finding topping cost
if (chkCheese.isSelected())
{
Top = 40;
}
if (chkCap.isSelected())
{
Top = Top+20;
}
if (chkPep.isSelected())
{
Top = Top + 25;
}
txtTop.setText(Integer.toString(Top));
// Finding Pizza order amount
Amt = (Integer.parseInt(txtRate.getText()) + Top) * Integer.parseInt(txtQty.
getText());
txtAmount.setText(Float.toString(Amt));
(iii) Double click on the clear button. Now appear with a // TODO marker line
appear.
txtPer.enable(false);
txtName.setText(“”);
txtQty.setText(“”);
txtRate.setText(“”);
txtTop.setText(“”)
txtAmount.setText(“”);
optRegular.setSelected(true);
chkCheese.setSelected(true);
chkCap.setSelected(false);
chkPep.setSelected(false);
(iv) Double click on the cmdExit button. Now appears with a // TODO marker
line.
System.exit(0);

Q.3. Read the following case study and answer the questions that follow ;
Mr. Vidyarthi works in Blossoms Public School as a programmer. He is
required to develop a student record. The school offers two different
streams, medical and non-medical, with different grading criteria. The

81
(Class - XII: INFORMATICS PRACTICES)

school also offers incentive to the NCC cadets in the form of a 3%


increment in percentage for all the NCC cadets. The grading criteria for
the two streams is given below :

Stream Percentage Grade


Medical >=80 A
60-79 B
<60 C
Non-Medical >=75 A
50-74 B
<50 C

The list for the above is :


Control Type Control Name Property Name Property Value
JFrame SRecordUI title Blossoms Public School
JLabel JLabel1 text Student Record
JLabel2 text First Term Marks
JLabel3 text Second Term Marks
JLabel4 text Percentage
JLabel5 text Grade
TextField TextField1 text [None]
Variable Name txtFirst
TextField2 text [None]
Variable Name txtSecond
TextField3 text [None]
Variable Name txtPer
TextField4 text [None]
Variable Name txtGr
JPanel JPanel1 Border
Title Stream
ButtonGroup ButtonGroup1
JRadioButton JRadioButoon1 text Medical
Variable Name OptMed
ButtonGroup Buttongroup1
JRadioButton2 text Non_Medical
Variable Name OptNMed
ButtonGroup ButtonGroup1
JCheckBox JCheckBox1 text NCC Cadet
Variable Name chkNCC

82
(Class - XII: INFORMATICS PRACTICES)

JButton JButton1 text Disable


Variable Name cmdDis
JButton2 text Calculate Percentage
Variable Name cmdCalcPer
JButton3 text Calculate Grade
Varible Name cmdCalcGrade
JButton4 text Clear
Variaable Name cmdClear
JButton5 text Exit
Variable Name cmdexit
(i) Write the commands to disable the textboxes txtPercentages and txtGrade.
Also, set Medical as default stream.
Solution
(i) Double click on the Disable button. Notice that a cmdDiscActionPerformed
event handler appears with a // TODO marker line. Write the following lines,
txtPer.enable(false);
txtGr.enable(false);
optMed.setSelected(true); // Default button selected
optNMed.setSelected(false);
(ii) Write the code for cmdClacPer to calculate the percentage after finding the
total marks of first term and second term ( assuming that both marks are out
of 100). Also ensure that NCC cadets get an increment of 3% in their
percentages.
Solution
int fTerm, sTerm;
int Total = 0;
float per = 0;
fTerm = Integer.parseInt(txtFirst.getText());
sTerm = Integer.parseInt(txtSecond.getText());
Total = fTerm + sTerm; // Total marks
per = Total/2; // Percentage of marks
if chkNCC.isSelected())
per = per + 3; // Extra 3% is given as NCC Cadet
// Displaying percentage
txtPer.setText(Float.toString(per));

(iii) Write the code for cmdCalcGrade to calculate the grade depending on the
stream selected according to the criteria given above.
Solution:
float per = Float.valueOf(txtPer.getText());
String gr=””;
// Medical section
if (optMed.isSelected())
{
if (per >= 80)
gr = “A”;
else

83
(Class - XII: INFORMATICS PRACTICES)

if (per >= 60 && per <= 79)


gr = “B”;
else
if (per < 60)
gr = “C”;
}
// Non-Medical section
else
if (optNMed.isSelected())
{
if (per >= 75)
gr = “A”;
else
if (per >= 50 && per <= 74)
gr =”B”;
else
if (per < 50)
gr = “C”;
}
txtGr.setText(gr);
(iv) Write the code for cmdClear Command Button to clear all the text boxes
and the check box and Medical as default stream.
Solution :
Double click on the Clear button. Notice that a cmdClearAction appears with
a // TODO marker line. Write the following lines,
txtFirst.setText(“”);
txtSecond.setSetText(“”)
txtPer.setText(“”)
txtGr.setText(“”)
chkNCC.setSelected(false);
optMed.setSelected(true); // Default button selected
optNMed.setSelected(false);
Q.4.

84
(Class - XII: INFORMATICS PRACTICES)

The list of controls for the above form is as follows :


Control Type Control Name Property Name Property Value
JFrame IciciUI title ICICI Bank
Interest Calculator
JLabel JLabel1 text ICICI Bank
JLabel2 text Principal
JLabel3 text Time
JLabel4 text Rate
JLabel5 text Amount
TextField TextField1 text [None]
Variable Name txtPrincipal
TextField2 text [None]
Variable Name txtTime
TextField3 text [None]
Variable Name txtRate
TextField4 text [None]
Variable Name txtInterest
TextField5 text [None]
Variable Name txtAmount
TextField6 text [None]
Variable Name txtDate

JPanel Jpanel1 Border


Title Account Type
ButtonGroup ButtonGroup1
JRadioButton JRadioButton1 text Fixed Deposit
Variable Name optFD
ButtonGroup ButtonGroup1
JRadioButton2 text Reccuring Deposit
Variable Name optRD
ButtonGroup ButtonGroup1
JCheckBox JCheckBox1 text Sr. Citizen
JButton JButton1 text Calculate
Variable Name cmdCalculate
JButton2 text Clear
Variable Name cmdClear
JButton3 text Exit
Variable Name cmdExit

(i) Write the code to disable the text boxes txtInterest, txtAmount, txtRate and
txtDate in the form when the form activated.
(ii) Write the code for cmdClear command button to clear all the textboxes and
check box except txtDate. Set the default choice in the option button as
Fixed Deposit.
(iii) Write the code for the click event of the command button cmdCalculate to
calculate compound interest and amount and display the values in textboxes
txtInterest and txtAmount depending on the principal, rate and time
Note that the compound interest is calculates as P*(1+r/100)^T &amount
as Principal+Interest.

85
(Class - XII: INFORMATICS PRACTICES)

Rate is calculated based on the time according to the following table.


Account Time(in yrs) Rate
Fixed Deposit <= 1 10%
> 1 and <=5 12%
>5 15%
Recurring Deposit <= 2 10%
> 2 and <=7 12%
>7 15%

An additional rate of 2% is given to senior citizen i.e. if the chkSR checkbox


is checked.
(iv) Write the code for cmdExit to exist the application.
Solution :
(i) Right click on form IntCalUI. Select Events >> WindowFocus >>
windGaunedFocused. Notice that a form WindowGainedFocus event
handler appears with a // TODO marker line. Write the following lines,
txtInterest.enable(false);
txtAmount.enable(false);
txtRate.enable(false);
txtDate.enable(false);
(ii) Double click on the Clear button. Notice that a btmClearActionPerformed
event handler appears with a // TODO marker line. Write the following lines,
txtPrincipal.setText(„‟);
txtTime.setText(“”);
txtRate.setTex(“”);
txtInterest.setText(“”);
txtAmount.setText(“”);
txtDate.setText(“”);
optFD.setSelected(true); // Default button selected
optRD.setSelected(false);
(iii) Double click on the Calculate button. Notice that a btnCalcActionPerformed
event handler appears with a // TODO marker line. Write the following lines,
int T = Integer.parseInt(txtTime.getName());
jLabel8.setText(“”+T);
// compound interest and total amount
double CI = 0, Amount = 0;
// Principal amount
double P = Double.parseDouble(txtPrincipal.getText());
// Rate of interest
float R = 0;
if ( optFD.isSelected())
{
if (T< = 1)

86
(Class - XII: INFORMATICS PRACTICES)

R = 10;
else
if ((T>1) && (T<=5))
R = 12;
else
If (T>5)
R=15;
}
Else
if ( optRD.isSelected())
{
if ((T< = 2)
R = 10;
else
if ((T>2) && (T< = 7))
R = 12;
else
if (T>7)
R = 15;
}
// If Sr, Citizen selected
if (chkSR.isSelected())
R = R + 2;
// Displaying Rate
txtRate.setText(Float.toString(R));
// pow() function calculates power of a number
CI = P * Math.pow((1 + (R/100)), T);
// Calculating total amount
Amount = P + CI;
txtInterest.setText(String.valueOf(CI));
txtAmount.setText(String.valueOf(Amount));
(iv) Double click on the Exit button. Notice that a cmdExitActionPerformed
event handler appears with a // TODO marker line. Write the following line,
System.exit(0);
Q.5. SBI HOME FINANCE revised its rate of interest for Public Deposit as
follows :
Years Cumulative Interest Annual Income Scheme
Scheme (p.a.) (Compounded Annually)
1 - 10%
2 - 10.5%
3 11.5% 11%
4 11.5% 11%
5 11.5% 11%

87
(Class - XII: INFORMATICS PRACTICES)

Deposit under the cumulative scheme is accepted for a period between


3 and 5 years only. The following is the screen used to calculate home
loan :

Solution:
(i) Double click on the JRadioButton1 button. Notice that a jRadioButton1
ActionPerformed event handler appears with a // TODO marker line. Write
the following lines,
txtY15.setText(“”);
txtY15.setEnabled(false);
txtA.setText(“”);
txtIA.setText(false);
txtIA.setEnabled(false)
jLabel3.setEnabled(false);
jLabel5.setEnabled(false);
txtCA.setEnabled(false);
txtCA.setText(“”);
txtY35.setEnabled(true);
txtY35.setText(“”);

(ii) Double click on the JRadioButton2 button. Notice that a


jRadioButton2ActionPerformed event handler appears with a // TODO
marker line. Write the following lines,
txtY35.setEnabled(false);
txtY35.setText(“”);
txtIA.setEnabled(false);
txtIA.setText(“”);
jLabel2.setEnabled(false);
jLabel4.setEnabled(false);
txtCA.setText(“”);
txtCA.setEnabled(false);
txtY15.setText(“”);

88
(Class - XII: INFORMATICS PRACTICES)

txtY15.setEnabled(true);
(iii) Double click on the Calculate button. Notice that a btnCalcActionPerformed
event handler appears with a // TODO marker line. Write the following lines,
float P;
double A = 0, r = 0, I = 0;
int op, y, ch;
if (jRadioButton1.isSelected())
{
P = Float.parseFloat(txtAmt.getText(();
Y = Integer.parseInt(txtY35.getText());
If (( y = = 3) || ( y = = 4) || ( y = = 5))
R = 0.115;
A = P * (1 + 0.01 * r) * y;
txtCA.setText(Double.toString(A));
}
if (jRadioButton2.isSelected()) {
P = Float.parseFloat(txtAmt.getText());
Y = Integer.parseInt(txtY35.getText());
if (y = = 1)
r = 0.10;
if (y = = 2)
r = 0.105;
if (y = = 3) || (y = = 4) || (y = = 5))
r = 0.11;
I = 0.01 * P * r;
txtIA.setText(Double.toString(I));
}
Q.6. Read the following case study and answer the questions that follow:
Mr. Nath of ABC software Corporation has got requirement of a
Software Project from a customer in Tours and Travels Business. He
performed the preliminary analysis and found that software Application
should be based on Client/ Server technology. He opted for Java Swing
to develop the front end, as RAD is one of its features. We had taken
the excerpt from his analysis and presenting you one of the forms to
enquire about railway reservation. Carefully observe the following
picture.

89
(Class - XII: INFORMATICS PRACTICES)

The List for the above form is as follows :


Object Type object Name Description
Text Fields OriginatingStationTF To enter string type value
DestinationStationTF To enter string type value
DDTF To enter Date
MMTF To enter a numeric value of Month
YYYYTF To enter a numeric value of Year
Button checkStatusBTN To check Status of Ticket Availability
closeMeBTN To close the application

(i) Write the code to obtain and display the value for the text property of the
Object CheckStatusBTN.
(ii) Write the code snippet for CloseMeBTN button if it is required to close the
form on its Action event.
(iii) Write the code snippet to allow the user to restrict alphabets (i.e., only
numbers allowed in the DD field.
(iv) Write the procedure to check for the validity of the entered date value. Clear
the text fields for invalid date value.
Ans.
(i) String txt = checkStatusBTN.getText() ;

JoptionPane.showMessageDialog(null, “ Text of checkStatusBTN is :”+ txt);

(ii) Private void closeMeBTNactionPerformed(…) {

system.exit(0) ;
}

(iii) private void DDTFkeyType( leyEvent evt ) {


char ch = evt.getkeychar() ;
if ( ! (ch >= „0‟ && ch <= „9‟) )
evt.consume() ;
}

(iv) void checkDate() {


int dd = Integer.parseInt(DDTF.getText()) ;
int mm = Integer.parseInt(MMTF.getText ()) ;
int yy = Integer.parseInt(YYYYTF.getText());
if (yy <= 0)
JoptionPane.showMessageDialof(null, “Invalid date.”);

if (mm = 1 || mm = 3 || mm = 5 || mm = 7 ||

90
(Class - XII: INFORMATICS PRACTICES)

mm = 8 || mm = 10 || mm = 12 ) {
if( ! (dd >0 && dd <= 31) {
JoptionPane.showMessageDialog(null, “Invalid date.”);
}
}
else if (mm = 4 || mm = 6 || mm = 9 || mm = 11) {
if (! (dd > 0 && dd <= 30) ) {
JoptionPane.showMessgeDialog(null, “Invalid date.”):
}
}
else if (mm = 2){
if(! (dd > 0 && dd <= 28) ){
JoptionPane.showMessageDialog(null, “Invalid date.”);
}
}
else
JoptionPane.showMessageDialog(null, “ Invalid date.”);
DDTF.setText(“ “);
MMTF.setText(“ “);
YYYYTF.setText(“ “);
DDTF.requestFocus();
}
Q.7. Read the following case study and answer the questions that follow :
Mr. Das is working as a Chief Information Officer in AMD
Constructions Company. In the month of January he received a
letter from the management to all his employee information in
electronic form. He decided to develop a small software application
to store employee’s personal data. He instructed one of his juniors
to make a form in Java Swing to enter employee information. The
junior presented the following form to Mr. Dass :

91
(Class - XII: INFORMATICS PRACTICES)

The form details are given in the following table :


Object or Control Type Object Name Description
Text Field NameTF To enter Name of Employee
FatherNa TF To enter Father‟s Name of employee
MotherNameTf To enter Mother‟s Name of employee
AddressTF To enter Address of employee

Radio Button FemaleRB


maleRB To provide Gender Information
Button Group GenderBG Button group for radio buttons FemaleRB
and MaleRB
checkbox IntermediateCB To be checked if employees is Intermediate
GraduateCB To be checked if employee is Graduate
PostGraduateCB To be checked if employee is Post Graduate
Button clearFormBTN To clear all the entered values in the form
closeFormBTN To close the form
submitDetailsBTN To store the form data
(i) Write a code snippet on Action event of ClearFormBTN button to clear text
field objects, set default choice in the Radio Buttons to Female and clearing
all Check Box Controls.
(ii) Write a method procCheckQualification to be called in Submit Button‟s
action event. The procedure code will perform the following action :
If the check box PostGraduateCB is checked then the procedure will
automatically check the check boxes GraduateCB and IntermediateCB
irrespective of their initial state. Similarly if the check box GraduateCB is
checked then IntermediateCB should also be automatically checked.
(iii) Write a method procConvertCase to convert all the employee details in
NameTF, FatherNameTF, MotherNameTF and AddressTF to Upper case
characters.
Ans.
(i) Private void ClearFormBTNactionPerformed (..) {
NameTF.setText(“ „);
FatherNameTF.setText(“ “);
MotherNameTF.setText(“ “);
AddressTF.setText(“ “);
FemaleRB.setselected(True);
IntermediateCB.setselected(false);
GraduateCB.setselected(false);
PostGraduateCB.setselected(false);
}
(ii) void procCheckQualification () {
if (PostGraduateCB.isselected() ) {
IntermediateCB.setselected(true);
GraduateCB.setselected(true);
}

92
(Class - XII: INFORMATICS PRACTICES)

if (GraduateCB.is selected() ) {
IntermediateCB.setselected(true);
}
}
(iii) avoid procConveryCase() {
String name = NameTF.gertext();
NameTf.setText( name.toUpperCase() );
String fname = FatherNameTf.gerText() );
FatherNameTF.setText( fname.toUpperCase() );
String mname = MotherNameTF.getText() ;
MotherNameTF.setText( mname.toUpperCase() );
String add = AddressTF.getText();
AddresTF.setText( add.toUpperCase() );

93
(Class - XII: INFORMATICS PRACTICES)

SQL Queries
Q.1. Write the resulting output of the following :
(a) SELECT ROUND(1023.432,1);
(b) SELECT LENGTH(„RAMESH SHARMA‟);
(c) SELECT UPPER(„master);
(d) SELECT MOD(ROUND(120.60, 1) , 5);
(e) SELECT POWER( 5, 5);
(f) SELECT CEIL(120.0);
(g) SELECT CEIL(120.34);
(h) SELECT FLOOR ( 65467.8890);
(i) SELECT FLOOR(12340.0);
(j) SELECT MOD(36, 3);
(k) SELECT MOD(14*9, 90/9);
(l) SELECT ROUND(3244.1962, 1);
(m) SELECT SQRT(144);
(n) SELECT SQRT(15.6*24.3);
(o) SELECT 1000+SQRT(100);
(p) SELECT FLOOR(144.34) + 1000 + CEIL(32.23);
(q) SELECT MOD(9*5, 9)+CEIL(100.56);
(r) SELECT SQRT(15);
(s) SELECT SQRT(345) + SQRT(15);
(t) SELECT FLOOR(100.34)+ ABS(200.43);
(u) SELECT FLOOR(3456.98+CEIL(9876.89);
(v) SELECT TRIM („ ABS Public School „);
(w) SELECT LENGTH(„ABS Public School‟);
(x) SELECT LOWER ( „ABS Public School‟);
(y) SELECT SUBSTR(„ABS Public School‟,1,3);
(z) SELECT UPPER(„ABS Public School‟);
(aa) SELECT SUBSTR(TRIM(„ INDIA IS GREAT „),3,9);
Q.2. Given the following EMPLOYEE relation. Write SQL command for
question (a) to (d) and the output for (e).
TABLE : EMPLOYEE
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPT
7369 Sunita Sharma CLERK 7902 1980-12-17 2800 20
7499 Ashok Singhal SALESMAN 7698 1981-12-17 3600 300 30
7521 Rohit Rana SALESMAN 7698 1981-02-22 5250 500 30
7566 Jyoti Lamba MANAGER 7839 1981-04-02 4975 20
7654 Martin S. SALESMAN 7698 1981-09-28 6250 1400 30
7698 Binod Goel MANAGER 7839 1981-05-01 5850 30
7782 Chetan Gupta MANAGER 7839 1981-06-09 2450 10
7788 Sudhir Rawat ANALYST 7566 1987-04-19 5000 20
7839 Kavita Sharma PRESIDENT 1981-11-17 5000 10

94
(Class - XII: INFORMATICS PRACTICES)

7844 Tushar Tiwari SALESMAN 7698 1981-09-08 4500 0 30


7876 Anand Rathi CLERK 7788 1987-05-23 6100 20
7900 Jagdeep Rana CLERK 7698 1981-12-03 4950 30
7902 Sumit Vats ANALYST 7566 1981-12-03 3500 3600 20
7934 Manoj Kaushik CLERK 7782 1982-01-23 5300 10
(i) To convert the designation into lower case.
(ii) To list the name and employee number by converting the name into
uppercase.
(iii) To list position of character „a‟ in the name of the employees.( hint use
instring function.
(iv) Display first three character of the field JOB, ( use substring function)
(v) What will be the output of the following :
(a) SELECT ENAME, INSTR(ENAME, „a‟ ) FROM EMPLOYEE;
(b) SELECT SUBSTR(ENAME, 1,5 ) FROM EMPLOYEE;
(c) SELECT CONCAT(ENAME, JOB) FROM EMPLOYEE;
Q.3. Write SQL commnds to create the table HOSPITAL with following
specification:
Field Name Data Type Constraints
PNo Int(4) Primary Key
Name Varchar(20)
Age Int(2)
Department Varchar(15)
Dateofadm Date
Charges Double(7,2)
Sex Char(1)
Q.4. Write SQL queries for a-f below :
No. Name Age Department Dateofadm Charges Sex
1 Arpit 62 Surgery 1998-01-21 300 M
2 Zarina 22 ENT 1997-12-12 250 F
3 Kareem 32 Orthopaedic 1998-02-19 200 M
4 Arun 12 Surgery 1998-01-11 300 M
5 Zubin 30 ENT 1998-01-12 250 M
6 Ketaki 16 ENT 1998-02-24 250 F
7 Ankita 29 Cardiology 1998-02-20 800 F
8 Zareen 45 Gynaecology 1998-02-22 300 F
9 Kush 19 Cardiology 1998-01-13 800 M
10 Shilpa 23 Nuclear Medicine 1998-02-21 400 F
(i) To select all the information of patients of cardiology department.
(ii) To list the names of female patients who are in ENT department.
(iii) To list names of all patients with their date of admission in ascending order.

95
(Class - XII: INFORMATICS PRACTICES)

(iv) To display Patient‟s Name, Charges, Age of only female patients.


(v) To list details of patients with Age < 30.
(vi) To insert a new row in the HOSPITAL table with the following data :
11, „Aftab‟,24, „Surgery‟,‟1998-02-25‟, 300, „M‟

Q.5. Create table customer as per following table chart.


Col. Name Cust-ID Cust-Name Cust-Add1 Cust-Add2 Pincode Phone
Data Type Number Varchar Varchar Varchar Number Varchar
Length 7 30 20 30 6 10

(i) Add one column Email of data type Varchar & size 30 to the table customer.
(ii) Insert one record in customer table.
(iii) Deop the column Cust-Add2 from take customer.
(iv) Change the name of Cust-Add1 column to „Address‟.
(v) Add a unique constraint on column Phone.
Q.6. Write SQL queries for the following questions :

TABLE : EMPLOYEE
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPT
7369 Sunita Sharma CLERK 7902 1980-12-17 2800 20
7499 Ashok Singhal SALESMAN 7698 1981-12-17 3600 300 30
7521 Rohit Rana SALESMAN 7698 1981-02-22 5250 500 30
7566 Jyoti Lamba MANAGER 7839 1981-04-02 4975 20
7654 Martin S. SALESMAN 7698 1981-09-28 6250 1400 30
7698 Binod Goel MANAGER 7839 1981-05-01 5850 30
7782 Chetan Gupta MANAGER 7839 1981-06-09 2450 10
7788 Sudhir Rawat ANALYST 7566 1987-04-19 5000 20
7839 Kavita Sharma PRESIDENT 1981-11-17 5000 10
7844 Tushar Tiwari SALESMAN 7698 1981-09-08 4500 0 30
7876 Anand Rathi CLERK 7788 1987-05-23 6100 20
7900 Jagdeep Rana CLERK 7698 1981-12-03 4950 30
7902 Sumit Vats ANALYST 7566 1981-12-03 3500 3600 20
7934 Manoj Kaushik CLERK 7782 1982-01-23 5300 10
(i) To select all the columns of the above table.
(ii) To list the name and employee number from the above table.
(iii) To list all names, hiredate and salary of all employees.
(iv) To display the employee name and the incremented value of SAL as SAL
+ 300.
(v) To list the employee name and his annual salary
( Annual salary = 12*sal +100).
(vi) Display the ename and sal where comm. is NULL.
(vii) To list the distinct department number from the table.

96
(Class - XII: INFORMATICS PRACTICES)

(viii) To list the unique jobs from the table.


(ix) To list the salary where salary is less than the commission.
(x) To list the salary between 3000 and 4000.
(xi) To list the mgr which are IN 7902, 7566, 7788.
(xii) To list the ename starting with „S‟.
(xiii) To list all the columns where salary is greater than 4100.
(xiv) To list all the columns in the ascending order of hiredate.
(xv) To list all the columns in the ascending order of deptno and descending
order of salary.
(xvi) To display the employee name and job of employees hired between Feb 20,
1981 and May 1, 1981.
(xvii) Display the ename and deptno of all employees in department 20 and 30 in
alphabetical ORDER BY name.
(xviii) To list the name and salary of all the employees who earn more than 1200
and are in department 10 or 40.
(xix) To list name and hiredate of all the employees who are hired in 1981.
(xx) To list all the employees who do not have manager.
(xxi) To list name and salary of all employees who earn commissions.
(xxii) To list the names of all employees where the second letter of their name is
an a.
(xxiii) To list the names and job of all the employees who work in department 20
and their manager is 7788.
(xxiv) To list the deptno, job and sum of salary group by deptno and job.
(xxv) Write the output of the following :
(a) SELECT ENAME, 12*SAL + COMM FROM EMPLOYEE
WHERE ENAME = „Ashok Singhal‟;
(b) SELECT ENAME
FROM EMPLOYEE WHERE ENAME LIKE „_a%‟;
(c) SELECT ENAME, MGR
FROM EMPLOYEE WHERE MGR IS NULL;

97
(Class - XII: INFORMATICS PRACTICES)

My SQL Practice Questions


Types of SQL queries.
(i) DDL – create , Alter
(ii) DML – Select , Insert , delete.
(iii) TCL – Commit ,Roll back
Q.1.
(i) Write an SQL query to create a table „TEAMS‟ with the following structure :
Field Type Constraint
TeamCode Varchar(5) Primary Key
TeamName Varchar(20)
TeamLeader Varchar(20)
NoOfMembers Integer
Team_Symbol Char(1) Not Null

(ii) In a database there are two tables Company and Model as shown below:
Company Model
CompID CompName CompHD ContPerson MoIdelID CompID ModelCost
1 Titan Okhla CB.Ajit T020 1 2000
2 Maxima Shahdra V.P.Kohli M032 4 2500
3 Ajanta Najafgarh R. Mehta M059 2 7000
(a) Identify the foreign key column in the table model.
(b) Check every value in CompID column of both the tables. Do you find
any discrepancy.
(iii) Consider the tables DOCTORS and PATIENTS given below :

DOCTORS
DadD DocName Department OPD Days
101 M.Pandey ENT TTS
102 G. P. Gupta Paed MWF
201 K.Sharma Ortho MWF

PATIENTS
PatNo PatName Department DodD
1 Neeraj ENT 101
2 Mohit Ortho 201
3 Ragini ENT 101
4 Mohit Paed 102
5 Nandini Ortho 201

With reference to these tables, write commands in SQL for (i) and (ii) and output
for (iii) below :

98
(Class - XII: INFORMATICS PRACTICES)

(i) Display the PatNo, PatName and corresponding DocName for each
patient.
(ii) Display the list of all patients whose OPD_Days are MWF.
(iii) Select OPD_Days, Count(*)
from doctors, Patients
where patients. Department = Doctors. Department
Group by OPD_Days ;
Ans.
(i) CREATE TABLE TEAMS
( Teamcode varchar(5) primary key,
Teamname varchar(20),
TeamLeadr varchar(20),
NootMembers int,
Team_Symbol char(1) NOT NULL );

(ii)
(a) Like CompID
(b) In the 2nd row of Model table the value of CompID is 4. This
CompID does not exist in the table company.
(iii)
(a) SELECT PatNo, PatName, DocName
FROM Patients, doctors
WHERE Patients.DocID = Doctors.DocID

(b) SELECT Patients.*


FROM Patients , Doctors
Where Patients.DodD = Doctors.DocID
AND OPD_Days = „MWF‟ ;

(c) OPD-Days count(*)


MWF 3
TTS 2
Q.2. What is a transaction ?
Ans. A transaction is one logical unit of work consisting of one or more
logically related statements. In order to understand transactions, let us
consider that Report cards to be prepared. Now this involves a lot of
steps like :
(i) Getting student information from student table
(ii) Getting marks details from Marks table
(iii) Calculating percentage and grade
(iv) Preparing report card
(v) Writing on Result table.

99
(Class - XII: INFORMATICS PRACTICES)

Now all these steps together make a logical unit of work and hence,
are together known as a transaction. MySQL treats a transaction as
a single entity. In case of successful termination of a transaction
(when all the steps are carried out successfully); the changes are
mage permanent through COMMIT. And in case of unsuccessful
termination, changes are undone with ROLLBACK statement.
Q.3. Answer the following queries based on EMP, DEPT and SALGRADE
tables of MySQL database :
Structures of these tables are given below :
emp (empno, ename, job, mgr, hiredate, sal, comm., deptno )
Dept (Deptno, dname, loc)
SalGrade (grade, losal, hisal)
(i) Practice – Restricting and Sorting Data
(a) Create a query to display the name and salary of employees earning
more than Rs. 2850.
(b) Create a query to display the employee name and department
number for employee number 7566.
(c) Display the employee name, job and start date of employees hired
between February 20,1991 and May 1,1991. Order the query in
ascending order of start date.
(d) Display the employee name and department number for all
employees in departments 10 and 30 in alphabetical order by name.
(e) List the name and salary of employees who earn more than Rs. 1500
and are in department 10 or 30. Label the columns Employee and
Monthly Salary, respectively.
(f) Display the name and hiredate of every employee who was hired
in1982.
(g) Display the name, job and salary for all employees whose job is Clerk
or Analyst and their salary is not equal to Rs. 1000, Rs. 3000 or Rs.
5000.
(h) Display name, salary and commission for all employees whose
commission amount is greater than their salary increased by 10%.
(ii) Practice –single-Row Functions
(a) Display the employee number, name, salary and salary increase by
15% expressed as a whole number. Label the column New Salary.
(b) Add an additional column that will subtract the old salary from the
new salary. Label the column Increase.
(c) For each employee display the employee name and calculate the
number of months between today and the date the employee was
hired. Label the column MONTHS_WORKED. Order the results by

100
(Class - XII: INFORMATICS PRACTICES)

the number of months employed. Round the number of months up to


the closest whole number.
(d) Write a query that produces the following for each employee :
<employee name>earns<salary>monthly but wants<3times salary>
(e) Create a query to display name and salary for all employees. Format
the salary to be 15 character long, left-padded with Rs. Label the
column SALARY.
(iii) Practice – Displaying Data from Multiple Tables
(a) Write a Query to display the name, department number, and
department name for all employees.
(b) Write a query to display the employee name, department name, and
location of all employees who earn a commission.
(c) Write a query to display the name, job, department number, and
department name for all employees who work in Dallas.
(d) Display the employee name and employee number along their
manager‟s name and manager number. Label the columns
Employee, Emp#, Manager, and Mgr#, respectively.
(e) Create a query that will display the employee name, department
number, and all the employees that work in the same department as
the employee „Anya‟. Give each column an appropriate label.
(f) Show the structure of the SALGRADE table. Create a query that will
display the name, job, department name, salary, and grade for all
employees.
(g) Create a query to display the name and hire date of any employee
hired after employee Blake.
(h) Create a query that displays the employee name and the amount of
the salaries of the employees are indicated through asterisks. Each
asterisk signifies a hundred dollars. Sort the data in ascending order
of salary. Label the column EMPLOYEE_AND_THEIR_SALARIES.
(iv) Practice – Aggregating Data Using Group Functions
(a) Write a query to display the number of people with the same job.
(b) Determine the number of managers without listing them. Label the
column Number of Managers.
(c) Write a Query that will display the difference between the highest and
lowest salaries. Label the column DIFFERENCE.
(d) Display the manager number and the salary of the lowest paid
employee for that manager. Exclude anyone where the manager id
is not known. Exclude any groups where the minimum salary is
less than Rs. 1000. Sort the group output in descending order of
salary
(e) Write a Query to display the department name,; location name,
number of employees, and the average salary for all employees in

101
(Class - XII: INFORMATICS PRACTICES)

that department. Label the columns as Dname, Number of


people, and Salary, respectively.
Ans
(i) Restricting and sorting data
(a) SELECT Ename, Sal FROM Emp
WHERE Sal > 2850 ;
(b) SELECT EName, Deptno FROM Emp
WHERE Empno = 7566 ;
(c) SELECT Ename, job, HireDate FROM Emp
WHERE HireDate BETWEEN str_to_date („Feb 20, 1991‟ ,
%m%d%,%y‟) ;
and str_to_date( „May1, 1991‟ , %m%d, %y‟) ;
ORDER BY HIREDATE ;
(d) SELECT Ename, , Deptno FROM Emp
WHERE Deptno IN (10, 30)
ORDER BY Ename ;
(e) SELECT Ename as Employee, Sal as “Monthly Salary” FROMEmp
WHERE Sal > 1500 AND Deptno IN (10, 30)
(f) SELECT Ename, HireDate FROM Emp
WHERE Year (HireDate) = 1982 ;
(g) SELECT Ename, Job, Sal FROM Emp
WHERE UPPER(job) IN („CLERK‟, „ANALYST‟)
AND Sal NOT IN (1000, 3000, 5000) ;
(h) SELECT Ename, Sal, Comm FROM Emp
WHERE Comm > (Sal + sal * 0.1) ;
(ii) Single row functions
(a) SELECT Empno, Ename, Sal, ROUND (Sal + Sal * 0.15) as “New
Salary”
FROM Emp ;
(b) SELECT Empno, Ename, Sal, Sal + Sal * 0.15 as “New Salary”, Sal
* 0.15 as “INCREASE” FROM Emp ;
(c) SELECT Ename,
ROUND (To_Days(curdate()) – To_days(Hiredate))/30) as

MONTHS_WORKED”
FROM Emp
ORDER BY 2 ;

102
(Class - XII: INFORMATICS PRACTICES)

(d) SELECT Concat(Ename, „earns‟ , sal, „but wants‟, sal*3) as “Dream


Salaries”
FROM Emp ;
(e) SELECT Ename, concat ( „Rs.‟ , Lpad ( Format(sal, 0) ,15, „ „))
FROM Emp ;
FROM Emp ;
FROM Emp ;
(iii) Displaying data from multiple tables
(a) SELECT Ename , Emp.Deptno As “Deptno” , Dname
FROM Emp, Dept
WHERE Emp.Deptno = Dept.Deptno ;
(b) SELECT Ename, Dname, Loc
FROM Emp, Dept
WHERE Emp.Deptno = Dept.Deptno
AND Comm IS NOT NULL ;
(c) SELECT Ename, Job, Emp.Deptno As “Deptno”, Dname
FROM Emp, Dept
WHERE Emp.Deptno. = Dept.Deptno
AND LOC = „Dallas‟ ;
(d) SELECT A.Ename as “Employee” , A.Empno as “Emp#”, B.Ename
as “Manager” B.Eno as “Mgr#”
FROM Emp A, Emp B
WHERE A.Mgr = B.Empno ;
(e) SELECT B.Ename as “Collegue Name” , B.Empno as “Collegue#”
FROM Emp A. Emp B
WHERE A.Deptno = B.Deptno
AND (A.Empno) < > B.Empno
AND A.Ename = „Anya‟ ;
(f) DESC SALGRADE ;
SELECT Ename , Job , Dname, Sal, Grade
FROM Emp, Dept, SalGrade
WHERE Emp.deptno = Dept.Deptno
AND Sal BETWEEN LoSal and Hisal ;
(g) SELECT A.Ename, A.HireDate
FROM Emp A, Emp B
WHERE A.HireDate > B.HireDate
AND B.Ename = „BLAKE;;
(h) SELECT Concat(RPAD (Ename, 10) , RPAD („ „ , ROUND
(Sal/100, 0) + 1 , „*‟) ) as “EMPLOYEES_AND_THEIR_SALARIES”
FROM Emp
ORDER BY Sal ;

103
(Class - XII: INFORMATICS PRACTICES)

(iv) Aggregating data using group functions :


(a) SELECT Job, COUNT(*)
FROM Emp
GROUP BY Job ;
(b) SELECT COUNT(*) “Number of Managers”
FROM Emp
WHERE Job = „MANAGER‟ ;
(c) SELECT MAX(Sal) – MIN(sal) “DIFFERENCE”
FROMEmp ;
(d) SELECT Mgr, MIN(Sa;)
FROM Emp
WHERE Mgr IS NOT NULL
GROUP BY Mgr
HAVING MIN(Sal) >= 1000
ORDER BY 2;
(e) SELECT Dname, Loc, Count(Empno) as “Number of people”,
ROUND(AVG (Sal), 2) as “Salary”
FROM Dept, Emp
WHERE Dept.Deptno = Emp.Deptno
GROUP BY Dname, LOC ;
Q.10.Write SQ L commands for the following on the basis of given table CLUB
Table : CLUB
COACH_ID COACHNAME AGE SPORTS DATOFAPP PAY SEX
1. KUKREJA 35 KARATE 27/03/1996 1000 M (ii)
2. RAVINA 34 KARATE 20/01/1998 1200 F i
3. KARAN 34 SQUASH 19/02/1998 2000 M nd
4. TARUN 33 BASKETBALL 01/01/1998 1500 M esc
5. ZUBIN 36 SWIMMING 12/01/1998 750 M end
ing
6. KETAKI 36 SWIMMING 24/02/1998 800 F
ord
7. ANKITA 39 SQUASH 20/02/1998 2200 F
er.
8. ZAREEN 37 KARATE 22/02/1998 1100 F
(iii)
9. KUSH 42 SWIMMING 13/01/1998 900 M f
10. SHAILYA 37 BASKETBALL 19/02/1998 1700 M or
all
(i) the coache
To show all information about the swimming coaches in the club.
(iv) Give the output of following SQL statements :
(a) SELECT LCASE (SPORTS) FROM Club ;
(b) SELECT MOD(Age, 5) FROM CLUB WHERE Sex = „F‟ ;

104
(Class - XII: INFORMATICS PRACTICES)

(c) SELECT POWER(3, 2) FROM CLUB WHERE Sex = „f‟ ;


(d) SELECT Substr(CoachName, 1, 2) FROM WHERE SPORTS =
„KARATE‟ ;
(v) Give the output of following SQL statements :
(a) SELECT COUNT (DISTINCT SPORTS) FROM Club ;
(b) SELECT MIN(Age) FROM CLUB WHERE Sex = „F‟ ;
(c) SELECT AVG(Pay) FROM CLUB WHERE SPORTS = „KARATE‟ ;
(d) SELECT SUM(Pay) FROM CLUB WHERE Datofapp > „31/01/98‟ ;
Ans.
(i) SELECT * FROM CLUB WHERE SPORTS = „SWIMMING‟ ;
(ii) SELECT COACHNAME, DATOAPP FROM CLUB ORDER BY
DATOFAPP DESC;
(iii) SELECT COACHNAME, PAY, AGE, PAY * 0.15 AS BONUS FROM
CLUB;
(iv)
(a) (b)
LCASE ( SPORTS)
karate MOD ( AGE, 5)
karate 4
squash 1
basketball 4
swimming 2
swimming
squash
karate
swimming
basketball

Substr(COACHNAME, ( 1, 2)
(c) (d)
POWER (3, 2) KA
9 KE
9 AN
9 ZA
SH

(e)
(i) 4
(ii) 34
(iii) 1100.0000
(iv) NULL

105
(Class - XII: INFORMATICS PRACTICES)

Q.2. Draw an entity relationship diagram to illustrate the case given below :
In a certain education institution, various student are taught by various
teachers. Each student has a student_id, name stream. A stream must
have at least one stream name and a stream code allocated to it, and
address, which further has got its own attributes like house no.,
pincode, area and state. Every Teacher must have a name, Teacher_id,
address again having specific attributes of it. Many teachers can belong
to one department.

Ans.
Teacher-id name Stud-id name

Teacher teaches student

teaches lives in lives in takes

Department Stream
adress

Stream code name


area
state house-no pin code
Department-Id name

Q.3.
(i) How does e-business improve customer satisfaction? Write one point.
(ii) How has our society benefited from e-governance? Write two points.
(iii) Vijayan works for the Customs Department. He wishes to create controls on
a form for the following functions. Choose appropriate controls from Text
field, Label, Option button, Check box, List box, Combo box, Button and write in
the third column.
S.No Control used to Control
1. Enter last name
2. Enter Gender
3. Choose City from a list of cities
4. Submit Form
Ans.
(i) Following points depict how e-business improves customer satisfaction :

106
(Class - XII: INFORMATICS PRACTICES)

(a) Goods sold through e-business are generally cheaper as cost incurred
in e-business is less compared to setting up a traditional business.
(b) Customers can receive highly customizable service.
(c) Even Remote area customers are reached in e-business.

(ii) Benefits to society from e-governance are :


(a) A lot of productive time of government servants and general public is
saved.
(b) Transparency has increased and therefore cheating cases have been
reduced.
(iii)
S.No control used to Control
1 Enter Last Name Text Field
2 Select Gender Option Button
3 Choose City from a list of Cities List Box or Combo Box
4 Submit Form Button (Command)
Q.4.
(i) How is e-learning beneficial to students? Write one point.
(ii) List two features of a good interface.
(iii) Prikshit works for a school. She wishes to create controls on a form for the
following functions. Choose appropriate controls from Text field, Label,
radio button, Check box List box, Combo box, Button and write in the third
column.

S.No Control used to Control


1 Enter Admission Number
2 Select Stream
3 Select Subjects
4 Clear the Form
Ans.
(i) Benefits to students are :
(a) Students can learn at their own pace.
(b) A lesson can be revised any number of times at students‟
convenience.
(c) Students can learn lessons at their homes at their convenient time.
(ii) A Good interface has following features :
(a) It should have pleasant color combination so that the user likes to use
it.
(b) It should have all the relevant options for all the required fields so that
the user is at ease while entering the data.
(iii)

107
(Class - XII: INFORMATICS PRACTICES)

S.No. Control used to Control


1 Enter Admission Number Text Field
2 Select Stream List Box/Combo Box/Radio Button
3 Select Subjects Check Boxes
4 Clear the Form Button

108
(Class - XII: INFORMATICS PRACTICES)

Network Practice Questions


(i) For layout 2, since the distance between buildings Alpha and Gamma is
large so a repeater would ideally be placed in between this path.

Alpha Repeater Gamma

Lambda

Beta

(ii) In both the layouts, a hub/switch each would be needed in all the
buildings, to interconnect the group of cables from the different computers in
each building.
Layout 1

Alpha Repeater Gamma


Hub Hub

Repeater
Lambda
Beta Hub
Hub

Layout 2

Alpha Repeater Gamma


Hub Hub

Repeater
Lambda
Beta
Hub
Hub

(d) The most economic way to connect it with a reasonable high speed would be to
use radio wave transmission, as they are easy to install, can travel long distances, and
penetrate buildings easily, so they are widely used for communication, both indoors
and outdoors. Radio waves also have the advantage of being omni directional, which
is they can travel in all the directions from the source, so that the transmitter and
receiver do not have to be carefully aligned physically.

109
(Class - XII: INFORMATICS PRACTICES)

Q.2. Lavanya Industries has set up its new center at Hari Om Nagar for
its office and web based activities. The company compound ha 4
buildings as shown in the diagram below :

Rudra Xavier
Building Building

Satnam
Building
Mohan
Building

Center to center distances between various buildings is as follows :


Mohan Buiding to Rudra Building 50m
Rudra Building to Xavier Building 60 m
Xavier Building to Satnam Building 25 m
Satnam Building of Mohan Building 170 m
Mohan Building to Xavier Building 125 m
Rudra Building to Satnam Building 90 m

Number of Computers in each of the buildings is follows :


Mohan Building 15
Rudra Building 150
Xavier Building 15
Satnam Building 25
(i) Suggest a cable layout of connections between the buildings.
(ii) Suggest the most suitable place (i.e. building) To house the server of
this organization with a suitable reason.
(iii) Suggest the placement of the following devices with justification :
(a) Internet Connecting Device/Moden
(b) Switch
(iv) The organization is planning to link its sale counter situated in various
parts of the same city, which type of network out of LAN, MAN or WAN
will be formed? Justify your answer.
Ans.
(i) Layout 1 :
Rudra Xavier
Building Building

Mohan Satnam
Building Building

110
(Class - XII: INFORMATICS PRACTICES)

(ii) Layout 2 : Since the distance between Xavier Building and Satnam
Building is quite short, following layout may also be considered :

Rudra Satnam
Building Building

Satnam
Building
Mohan
Building

(iii) The most suitable place/ building to house the server of this
organization would be Rudra building, as this building contains the
maximum number of computers, thus decreasing the cabling cost for
most of the computers as well as increasing the efficiency of the
maximum computers in the network.
(a) Rudra building
(b) In both the layouts, a hub/switch each would be needed in all the
buildings, to interconnect the group of cables from the different
computers in each building.
(iv) The type of network that shall be formed to link the sale counters
situated in various parts of the same city would be a MAN, because ,
MAN (Metropolitan Area Networks ar the networks) are the networks
that link computer facilities within a city.
Q.3. Lantastic Corporation caters to many high profile clients and has 6
buildings where it runs its operations (shown below)

50 mts
[55] Pro
35 mts
45 mts 65 mts
120 mts 30 mts
Robo Master
40 mts
[55] [70]

The distances between buildings are shown through Distance


above
diagram. The numbers in [ ] indicate number of computers in each building
i.e.,
(i) Building Pro has 55 computers
(ii) Building Greycell has 185 computers
(iii) Building Wizard has 60 computers
(iv) Building robo has 55 computers
(v) Building Master has 70 computer

111
(Class - XII: INFORMATICS PRACTICES)

Answer the following questions on the basis of above given information.


(i) suggest the possible cable layouts for the building.
(ii) Where would you suggest the placement of server ?
(iii) Suggest the cable type that should be used.
(iv) The management wants that the network traffic should be minimized.
For this which network device would you suggest out of the following devices
and why?
(i) hub (iii) bridge
(ii) repeater
Ans.
(i) The possible cable layouts can be :

50 mts
[55] Pro
35 mts
45 mts 65 mts
120 mts 30 mts

Robo Master
40 mts
[55] [70]

(Total cable length required to connect buildings through this layout = 190 mts)

50 mts
[55]
Pro
35 mts
45 mts 65 mts
120 mts 30 mts
Robo Master
40 mts
[55] [70]

(Total cable length required to connect buildings = 155 mts)


Q.4. What is a network? Give its goals.
A.4. A comp. network is a set of two or more interconnected computers & a
set of hardware device.
Goals :
(i) Resource sharing
(ii) Reliability
(iii) Cost Factor
(iv) Communication medium.
Q.5. Differentiate bet” a node (workstation) & a server.

112
(Class - XII: INFORMATICS PRACTICES)

A.5. Any comp on a n/w & is seeking to share the resources of the network is
a workstation and any computer that facilitates the sharing of data, s/w ,
network resources on the network is a server.
Q.6. Define.
A.6. MAC address : It refers to physical address assigned by NIC
manufacturing
10:B5:03 : 63:2E:FC ( 6 digits no.)
Manufacturing- ID Card-no.

IP address : No. given to every machine on a TCP/IP n/w


eg. 216.27.61.137

Domain Name : Unique name assigned to a website that corresponds to


IP address.
Q.7. N/W Topologies : Star, Bus, Ring, Tree, Graph, Mesh, Fully connected.

WS WS
WS WS SERVER

WS WS

WS WS
WS WS

SERVER

ws ws

ws ws ws ws

ws ws ws ws ws

Q.8. Define .
A.8. Hub : Hub is n/w device used to connect several Computers together.
(Active and Passive hubs)
Switch : Switch is used to segment n/w into different subnets.

113
(Class - XII: INFORMATICS PRACTICES)

Gateway : Gateway is a network that connects dissimilar networks. It


establishes an intelligent connection between LAN and
external network.
Bridge : Bridge connects two LAN or two segments of the same LAN
which follow the same protocol.
Router : Router connects multiple n/w irrespective of their protocols
Q.9. Network Security .
A.9. Network Security : Intrusion Problems/ Assess attacks
(i) Snooping
(ii) Eaves dropping
(iii) Dos
Q.10.Define Open Source S/W.
A.10. Open source S/W refers to those categories of S/W whose licence do not
impose
Much conditions. ( Free to use, run, modify and redistribute).
Free and OS or FLO SS
FLOSS refers to free libre and OSS.
Q.11.Define Keywords, Identifiers, litenals.
A.11. Variable : It’s a named memory location which holds a data value of a
particular data type.
Eg. Of December assignment
Type variable name
int a;
a = 2;
Q.12.Coercion and type casting.
A.12. Implicit type casting wherein data types are promoted is known as
coercion. [no operator used]
Explicit conversion of an operand to a specific type is called tyre
casting. [(type) expression]
Q.13.LOOPS
(i) What is fall through?
A.13. The fall of control to the following cases of matching case is called a fall
through.
(ii) Break and continue statements:
(iii) Identify the data type of full. exp.
byte b; int intval
char ch; long Longval
short sh; float fl;

(a) intval*longval – ch

114
(Class - XII: INFORMATICS PRACTICES)

Ans : Long because:


(intval*longval) – ch

int long ch

long

long
(b) fl +Longval/sh
Ans : float.
(iv) Rewrite using Switch :

if ( ch = =‟E‟) char ch;


Eastern + + ; Switch (ch) {
if ( ch = =‟W‟) Case „E‟ : Eastern + + ;
Western + + ; break;
if (ch = =‟N‟) Case „W‟ : Western + + ;
Northern + + ; break;
if (ch = =‟S‟) Case „N‟ : Northern + + ;
Southern + + ; break;
else Case „S‟ : Southern + + ;
Unknown + + ; Default : Unknown + + ;
}

(v) What will be the value of sum after the following code is executed.
(a) Sum = 20 (b) Sum =20
opt = 5 opt = 5
Sum = Sum + (opt++); Sum = Sum +(+ + opt);
Sum = 25 Sum = 26

(vi) Give the O/P of the following.


Int j = 44
S.O.P ( J + + + “\t” + j + “\t” + ++j) ;
S.O.P („‟ \n „‟ + j) ;
O/P 44 45 46
46

(vii) What value will be stored in different variable when the following Java code
is executed.

115
(Class - XII: INFORMATICS PRACTICES)

int i = 10 O/PI
int j, k, l, m, n; 10 15 13 14 5 83
J=i+5
K = i + j/5
L = K+1;
m = L + 1 – i;
n=k+m *L
S.O.P( i +”\n” + j =
m+k+”/n”+l = n)

(viii) Give the o/p : o/p


Char ch = „a‟
Ch = (ch = = „b‟) ? ch : „b‟; b
S.O.P (ch);

(ix) Give o/p

int i, j, n; o/p
n=0;i=1
do { n + + ; no o/p
i ++; because
S.O.P ( i , n); no S.O.P
} statement
While ( i< = 5);

(x) How many times the following loop is executed.


x = 5 ; y = 50; Infinite Loop
while (x < = y) {
x = y/x;
………..
}

(xi) Find errors .


Declaration required
m=1;
n= 0 ;
for ( ; m+n < 19; + + n)
S.O.P (“ Hello \n “) ;
m = m + 10
not part of for loop.

(xii) Write code to display.

116
(Class - XII: INFORMATICS PRACTICES)

1 int i, j;
2 2 for ( i = 1; i < = 4; i + + ) {
3 3 3 for (j = 1; j< = i; j + +)
4 4 4 4 S.O.Print( “ “ + i );
S.O.Print in ( );
}

(xiii) Code to display factorial of a given no.


Int f = 1, i , n ;
While ( + + i < n )
f*=i;
S.O.P ( “factorial of “ + n +” i s = ” + f );
Q.14. Classes and functions.
(i) What is a class?
A.14. A class represents a set of objects that have a common structure and
common behaviour. It’s a blue print that represents a set of similar
objects.
(ii) Objects
Ans. Objects is an identifiable entity with some character and behaviour.
(iii) Actual and formal Parameters.
Formal para ( method def)
int must ( int x, int y)
{ return x * y;
}

Actual para (method call)


int length = 10;
int width = 5;
int area = mull( length, width);
(iv) Static Members : Static Members are class members.
(v) Given the following code
Class X {
Private int count ;
Is the following fragment correct ?
Class Y {
Public static void mains(string args [ ] ) {
X ob =new x( );
Ob. Count = 10;
}
}
Ans : No, a private member cannot be accessed outside a class. Count is
private member of class X.

117
(Class - XII: INFORMATICS PRACTICES)

Q.15. Inheritance.
Q: What is method overloading and method overriding.
A: A function which has same name but different method signatures is
called as Overloaded bus. A fx. In child class which has same method
name and signature as that of parent class, hides the parent class fx.
This is called as method overriding.

118
(Class - XII: INFORMATICS PRACTICES)

Practice Questions on HTML


Types of Tags :
(i) Container Tags.
(ii) Empty Tags.
Types of Lists :
(i) Ordered Lists
(ii) Unordered Lists
Q.16.Questions given below are based on HTML :
(i) What is the difference between the submit button and Reset button of HTML
forms?
(ii) Specify the tags and attributes to send a form to the e-mail address
mymail@emailaccount.com
(iii) Write the HTML code to generate a Web page in the format given on next
page.
Consider the following while writing the HTML code :
(i) Background color of the page should be “Pink” and visited link color should
be “Green”.
(ii) Font face of text in the page should be “Arial”.
(iii) Text color of main heading should be “Maroon”.
(iv) Picture used in the page is file “map.jpg”.
(v) The text “NIRVANA HOLIDAYS LTD” should be in “ Red color and in
“Bold”.
(vi) Page linked to :
(a) Rajasthan Packages as “raj.html”.
(b) Kerala Packages as “kerala.html”.
(vii) The table should have a caption “Tarriff”.
(viii) Bottom message should be of size 2.

ANS.

119
(Class - XII: INFORMATICS PRACTICES)

WELCOME TO INDIA
________________________________________________________________
Welcome to India, a natural beautiful country in every season
NIRVANA HOLIDAYS LTD. is a tour operating agency that
arranges Sightseeing Tours Packages and Overland program
that have been creatively designed ofeering experiences of high
value.
We offer the following packages
1. Rajasthan Package
 Jaipur
 Udaipur
 Pushkar
2. Kerala Package
 Kumarokom Resort
 Periyar Wildlife Sanctuary
 Lovalam Beach
TARRIF
Package Normal Deluxe
Rajasthan ` 7,000 ` 10,500
Kerala ` 11,500 ` 18,000
_____________________________________________________________________________
For enquiries Mail to us

(i) Submit and Reset buttons of HTML form ar special buttons which
have a traditional purpose to serve
(a) When submit button is clicked then forms data is submitted to the
back-end application
(b) When Reset button is clicked then all forms controls are reset to
default state.
(ii) <FORM action = mailto:mymail@emailaccount.com method =
“post”>
(iii)
<HTML>
<HEAD>
<TITLE>Welcome to India</TITLE>
</HEAD>
<BODYbgcolor = “Pink” vlink = “Green”>
<FONT face = “Arial” color = “Maroon”>
<H3 align = “center”>WELCOME TO INDIA
</H3></FONT>
<FONT face = “Arial”>

120
(Class - XII: INFORMATICS PRACTICES)

<HR>
<IMG src = “map.jpg” align = “left” height = 90 width =90>
welcome to India, a natural beautiful country in every season.
<FONT color = “red”> <b>NIRVANA HOLIDAYS LTD.</B></FONT>
is a tour operating agency that arranges sightseeing Tour Packages and overland
program that have been creatively designed offering experiences o f high value.
<P>
We offer the following packages
<OL>
<li><A href = “raj.html”>Rajasthan Package</A>
<UL type = “disc”>
<li>Jaipur
<li>Udaipur
<li>Pushkar
</UL>
<li><A href = “Kerala.html”>kerala Packages</A>
<UL type = “circle”>
<li>Kumarokom Resort
<li>Periyar Wildlife Sanctuary
<li>Lovalam Beach
</ul>
<OL>
<TABLE border = 2 align = “center”>
<CAPTION> Tarrif </CAPTION>
<TR >
<TH> Package</TH>
<TH> Normal</TH>
<TH> Deluxe</TH>
</TR>
<TR >
<TD>Rajasthan</TD>
<TD>Rs. 7000</TD>
<TD>Rs. 10,500</TD>
</TR>
<TR >
<TD>Kerala</TD>
<TD>Rs. 11,500</TD>
<TD>Rs. 18,000</TD>
</TR>
<TABLE></FONT>
<HR>
<FONT size = 3><P align = “center”>
For enquiries <A href = « feedback@welcome.com »>Mail to us
</A>

121
(Class - XII: INFORMATICS PRACTICES)

<FONT>
</BODY>
</HTML>
Q.17.Questions given below are based on HTML :
(i) What is the difference between the <FRAME> and <FRAMESET> tags?
(ii) Specify the tag and attributes to create a TextArea with 5 rows and 20
columns.
(iii) Write the HTML code to generate web page in the format given below :

Hospitality Industry
________________________________________________________________
One of the industries which is on the path of rapid growth is the hospitality
industry.
The Hotels today aims to provide the highest standard of accommodation,
Facilities and services at competitive prices
Hotels are broadly classifies as:
Hotels Resorts
Business Hotels Beach resorts
Leisure Hotels Hill resorts
Budget Hotels Heritage resorts
Departments in a Hotel
1. Front Office
 Reservations
 Receptionist
 Guest Relations
2. Food and Beverages
 Room Service
 Coffee Shop
 Restaurant
_____________________________________________________________________________
For all further enquiries Contact us

Consider the following while writing the HTML code :


(a) Title of the page should be “Tourism Industry”.
(b) Background color of the page should be “Silver”, Lind color should
be “Maroon”, visited link color should be “Red”.
(c) Picture used in the page is the file “beach.jpg”.
(d) Table should have a border of width 2/
(e) Use the concept of nested lists for creating the list given in the wen
page with specified bullets.
(f) Pages linked to :

122
(Class - XII: INFORMATICS PRACTICES)

 Front office as “front.html”.


 Food and Beverages as “food.html”.
Ans.
(i) <FRAMESET> tag divides the main window into a set of frames that can
each display separate document. On the other hand <FRAME> tag defines
a single frame in a <FRAMESET>.

=============================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
=============================================

123