0% found this document useful (0 votes)
36 views61 pages

Class12 Database Concepts Notes

The document covers essential concepts of Database Management Applications for Class 12, including database definitions, properties, and the need for a Database Management System (DBMS). It explains various operations performed on databases, characteristics of DBMS, types of users, advantages and limitations of using DBMS, and details about relational databases and SQL commands. Additionally, it provides examples of creating tables and managing data within a database using SQL.

Uploaded by

editz7018
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views61 pages

Class12 Database Concepts Notes

The document covers essential concepts of Database Management Applications for Class 12, including database definitions, properties, and the need for a Database Management System (DBMS). It explains various operations performed on databases, characteristics of DBMS, types of users, advantages and limitations of using DBMS, and details about relational databases and SQL commands. Additionally, it provides examples of creating tables and managing data within a database using SQL.

Uploaded by

editz7018
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1

Database Management Applications


Class 12

Contents Page No.


Unit 1 Database Concepts 1
Unit 2 Operating Web 23
Unit 3 Fundamentals of Java Programming 32
Unit 4 Work Integrated Learning IT-DMA 57

Unit 1 Database Concepts


Database
A database is an organized collection of data that has been arranged and is typically kept electronically in a
computer system. A database management system often oversees a database (DBMS).
DATA------------------------>PROCESSING----------------------------->INFORMATION
(Marks of students------->Compute addition and % ------------->result)

Database working properties


A database has the following properties:
1) A database is a representation of some aspect of the real world also called mini world. Whenever there are
changes in this mini world they are also reflected in the database, Online courses
2) It is designed, built and populated with data for specific purpose.
3) It can be of any size and complexity.
4) It can be maintained manually or it may be computerized.

Need for a Database


Database management systems enable users to securely, efficiently, and quickly share data throughout an
organization. A data management system offers quicker access to more accurate data by quickly responding to
database requests. example:-
Payroll Department------ Application Program-----------File1
Sales Department --------Application Program----------File2

Database approach –
1. Data Redundancy – Data redundancy is the storing of the same data across many files. Space would be
wasted as a result of this.
2. Data Inconsistency – If a file is modified, all the files that contain comparable information must also be
updated, or the data will become inconsistent.
3. Lack of Data Integration – Because data files are unique, it is very challenging to obtain information from
various files.

Database Management System (DBMS)


Data is stored, retrieved, and analyzed using software called database management systems (DBMS). Users can
create, read, update, and remove data in databases using a DBMS, which acts as an interface between them and
the databases.
Application Program---->DBMS Software ---->Stored Database & Its Definition

DBMS Environment(Various Operations Perform on Database)


The various operations that need to be performed on a database are as follows –
1. Defining the Database – It involves specifying the data type of data that will be stored in the database and
also any constraints on that data.
2. Populating the Database – It involves storing the data on some storage medium that is controlled by
DBMS.
3. Manipulating the Database – It involves modifying the database, retrieving data or querying the database,
generating reports from the database etc.
4. Sharing the Database – Allow multiple users to access the database at the same time.
2
5. Protecting the Database – It enables protection of the database from software/ hardware failures and
unauthorized access.
6. Maintaining the Database – It is easy to adapt to the changing requirements. Some examples of DBMS are
– MySQL, Oracle, DB2, IMS, IDS etc.
Some examples are :-- MySQL ,Oracle ,DB2 ,IMS ,IDS etc.

Characteristics of Database Management Systems


1. Self-describing Nature of a Database System – A database system is said to as self-describing if it has
metadata that defines and explains the data and relationships between tables in the database in addition to the
database itself.
2. Insulation Between Programs and Data – Programs that access this data don’t need to be changed because
the description of the data is stored separately in the database management system (DBMS) and any changes to
the data ’s structure are made in the catalog.
3. Sharing of Data – Multiple users can access the database. Therefore, a DBMS must have concurrency
control software to provide concurrent access to the database’s data without encountering any consistency
issues.

Types of Users of DBMS


Depending on their needs and how they interact with the DBMS, different types of users use the DBMS. Four
main categories of users exist –
1. End Users – those who use the database to perform queries, make changes, and produce reports based on
their requirements is end users.
2. Database Administrator (DBA) – The DBA is in-charge of authorizing access, keeping an eye on how it’s
being used, offering technical support, and acquiring hardware and software resources.
3. Application Programmers – To communicate with the database, application developers create application
programs. To communicate with the database, these programs are created using high level languages like SQL.
4. System Analyst – A system analyst is important to the feasibility, technical, and economic elements of
database architecture.
Advantages of using DBMS Approach
Following are the advantages of using a DBMS –
1. Reduction in Redundancy – All the data is stored at one place. There is no repetition of the same data. This
also reduces the cost of storing data on hard disks or other memory devices.
2. Improved Consistency – The chances of data inconsistencies in a database are also reduced as there is a
single copy of data that is accessed or updated by all the users.
3. Improved Availability – Same information is made available to different users. This helps sharing of
information by various users of the database.
4. Improved Security – The DBA can protect the database by using passwords and restricting users’ database
access rights.
5. User Friendly – Because of its user-friendly interface, it reduces users’ dependence on computer specialists
to carry out various data-related actions in a DBMS.
Limitations of using DBMS Approach
1. High Cost – The cost of implementing a DBMS system is very high. It is also a very time consuming
process.
2. Security and Recovery Overheads – Depending on the data stored, unauthorized access to a database can
result in a threat to the individual or business. Additionally, regular data backups are necessary to guard against
disasters like fires and earthquakes.

Relational Database
A collection of data elements with per-established relationships between them make up a relational database.
These things are arranged in a series of tables with rows and columns. To store data about the things that will be
represented in the database, tables are utilized.
Employee
Name Emp_ID Gender Salary DOB
Neha 1121 F 20000 4/3/1990
Paras 2134 M 25000 19/10/1993
Himani 3145 F 20000 23/11/1992
3
In relational model,
A row is called a Tuple.
A column is called an Attribute.
A table is called as a Relation.
The data type of values in each column is called the Domain.
The number of attributes in a relation is called the Degree of a relation.
The number of rows in a relation is called the Carnality of a relation.

Relational Model Constraints


Constraints are limitations on the values that are stored in a database according to the specifications.
We describe below various types of constraints in Relational model –
1. Domain Constraint – User-defined columns called domain constraints allow users to enter values in
accordance with the data type. Additionally, if it receives an incorrect input, it alerts the user that the column
needs to be filled out correctly.
2. Key Constraint – A primary key constraint is a column or group of columns that shares the same
characteristics as a unique constraint. Relationships between tables can be specified using a primary key and
foreign key constraints.
3. Null Value Constraint – A column may by default contain NULL values. A column must not accept NULL
values according to the NOT NULL constraint. This forces a field to always have a value, thus you cannot add a
value to this field while adding a new record or updating an existing record.
4. Entity Integrity Constraint – The primary key cannot be null due to the Entity Integrity Constraint.
Individual records in a table are identified by a primary key, and if the primary key is null, we are unable to do
so. Except for the main key column, any place in the table can have null values.
5. Referential Integrity Constraint – Foreign key constraints or referential integrity constraints. A logical rule
governing the values in one or more columns in one or more tables is known as a foreign key constraint, also
known as a referential constraint or a referential integrity constraint. For instance, a group of tables presents
details about the suppliers to a company.

Data types commonly used


Data type Meaning Example
CHAR (n) Fixed length character string. ‘n’ is CHAR(5):“ Ashok” “ Vijay”
the number of characters.
VARCHAR(n) Variable length character string. ‘n’ VARCHAR(15):“Vijay
is the maximum number of Kumar”“Ashok Sen”
characters in the string.
DATE Date in the form of YYYY-MM- DATE: ‘2014-03-20’
DD
INTEGER Integer number 23
56789

DECIMAL (m, d) Fixed point number m represents DECIMAL(5,2): 999.99,-567.78


the number of significant digits that
are stored for values and d DECIMAL (5) : 23456
represents the number of digits that 99999
can be stored following the decimal
point. If d is zero or not specified
then the value does not contains any
decimal part.
Structured Query Language (SQL)
RDBMS data management is done using the SQL language. It is made up of two languages: Data Definition
Language (DDL) and Data Manipulation Language (DML), where DDL is a language used to specify the
structure and restrictions of data and DML is used to add, alter, and delete data in a database.

Create a Database –
Create Table Command –
4

CREATE TABLE<table name>


(
<column 1><data type> [constraint] ,
<column 2><data type>[constraint],
<column 3><data type>[constraint]
);
Question 1.> Write a Query to Create a new table where the field will be Teacher_ID, First_Name,
Last_Name, Gender, Date_of_Birth, Salary, Dept_No.
CREATE TABLE Teacher
(
Teacher_ID INTEGER,
First_Name VAR CHAR(20),
Last_Name VAR CHAR(20),
Gender CHAR(1),
Salary DECIMAL(10,2),
Date_of_Birth DATE,
Dept_No INTEGER
);
Output –
Teacher_ID First_Name Last_Name Gender Salary Date_of_Birth Dept_No

Question 2.> Create Table using NOT NULL – An attribute value may not be permitted to be NULL.
CREATE TABLE TEACHER
(
Teacher_ID INTEGER,
First_NameVARCHAR(20) NOT NULL,
Last_NameVARCHAR(20),
Gender CHAR(1),
Salary DECIMAL(10,2),
Date_of_Birth DATE,
Dept_No INTEGER
);
Question 3.> Create Table using DEFAULT – If a user has not entered a value for an attribute, then
default value specified while creating the table.
CREATE TABLE TEACHER
(
Teacher_ID INTEGER,
First_Name VARCHAR(20) NOT NULL,
Last_Name VARCHAR(20),
Gender CHAR(1),
Salary DECIMAL(10,2) DEFAULT 40000,
Date_of_Birth DATE,
Dept_No INTEGER
);
Question 4.>Create a Table using CHECK – In order to restrict the values of an attribute within a range,
CHECK constraint may be used.
CREATE TABLE TEACHER
(
Teacher_ID INTEGER,
First_Name VARCHAR(20) NOT NULL,
Last_Name VARCHAR(20),
Gender CHAR(1),
Salary DECIMAL(10,2) DEFAULT 40000,
Date_of_Birth DATE,
Dept_No INTEGER CHECK (Dept_No<=110)
);
5
Question 5.>Create a Table using KEY CONSTRAINT – Primary Key of a table can be specified in two
ways. If the primary key of the table consist of a single attribute, then the corresponding attribute can be
declared primary key along with its description.
CREATE TABLE TEACHER
(
Teacher_ID INTEGER PRIMARY KEY,
First_Name VARCHAR(20) NOT NULL,
Last_Name VARCHAR(20),
Gender CHAR(1),
Salary DECIMAL(10,2) DEFAULT 40000,
Date_of_Birth DATE,
Dept_No INTEGER
);
Question 6.>Create a Table using REFERENTIAL INTEGRITY CONSTRAINT – This constraint is
specified by using the foreign key clause.
CREATE TABLE Teacher
(
Teacher_ID INTEGER PRIMARY KEY,
First_Name VARCHAR(20) NOT NULL,
Last_Name VARCHAR(20),
Gender CHAR(1),
Salary DECIMAL(10,2) DEFAULT 40000,
Date_of_Birth DATE,
Dept_No INTEGER,
FOREIGN KEY (Dept_No) REFERENCES Department(Dept_ID)
);

Self Refrencing Tables

1. Naming of Constraint
In the Create Table command, constraints can be named. The benefit is that using the Alter Table command,
specified restrictions can be quickly altered or deleted. When naming a constraint, use the keyword
CONSTRAINT followed by the constraint’s name and its specification.

For example consider the following Create Table command –


CREATE TABLE Teacher
(
Teacher_ID INTEGER,
First_Name VARCHAR(20) NOT NULL,
Last_Name VARCHAR(20),
Gender CHAR(1),
Salary DECIMAL(10,2) DEFAULT 40000,
Date_of_Birth DATE,
Dept_No INTEGER,
CONSTRAINT TEACHER_PK PRIMARY KEY (Teacher_ID),
CONSTRAINT TEACHER_FK FOREIGN KEY (Dept_No) REFERENCES
Department(Dept_ID) ON DELETE SET NULL ON UPDATE SET NULL
);
In the above table, the primary key constraint is named as TEACHER_PK and the foreign key constraint is
named as TEACHER_FK.

2. Drop Table Command


This command is used to delete tables. For example, suppose you want to drop the Teacher table then the
command would be:

DROP TABLE Teacher CASCADE;


6
Thus Teacher table would be dropped and with the CASCADE option, i.e. all the constraints that refer this table
would also be automatically dropped.
However if the requirement is that the table should not be dropped if it is being referenced in some other table
then RESTRICT option can be used as shown below:
DROP TABLE Teacher RESTRICT;
3. Alter Table Command
Adding a column – Suppose we want to add a column Age in the Teacher table. Following command is used to
add the column –
ALTER TABLE Teacher ADD Age INTEGER;

Dropping a column – A column can be dropped using this command but one must specify the options
(RESTRICT or CASCADE) for the drop behavior. RESTRICT would not let the column be dropped if it is
being referenced in other tables and CASCADE would drop the constraint associated with this column in this
relation as well as all the constraints that refer this column.
ALTER TABLE Teacher DROP Dept_No CASCADE;
Dropping keys – A foreign key/primary key/key can be dropped by using ALTER TABLE command.
ALTER TABLE Teacher DROP FOREIGN KEY TEACHER_FK;
Adding a Constraint – If you want to add the foreign key constraint TEACHER_FK back, then the command
would be –
ALTER TABLE Teacher ADD CONSTRAINT TEACHER_FK FOREIGN KEY (Dept_No) REFERENCES
Department(Dept_ID) ON DELETE SET NULL ON UPDATE SET NULL;

4. Insert Command
This command is used to insert a tuple in a relation. We must specify the name of the relation in which tuple is
to be inserted and the values. The values must be in the same order as specified during the Create Table
command. For example, consider the following table Teacher:
CREATE TABLE Teacher
(
Teacher_ID INTEGER,
First_Name VARCHAR(20) NOT NULL,
Last_Name VARCHAR(20),
Gender CHAR(1),
Salary DECIMAL(10,2) DEFAULT 40000,
Date_of_Birth DATE,
Dept_No INTEGER,
CONSTRAINT TEACHER_PK PRIMARY KEY (Teacher_ID),
);
To insert a tuple in the Teacher table INSERT command can be used as shown below:
INSERT INTO Teacher VALUES (101,”Shanaya”, “Batra”, ‘F’, 50000, ‘1984-08-11’, 1);

[Link] Command
This command is used to update the attribute values of one or more tuples in a table.
UPDATE Teacher
SET Salary=55000
WHERE Teacher_ID=101;

[Link] Command
In order to delete one or more tuples, DELETE command is used.
DELETE FROM Teacher
WHERE Teacher_ID=101;

[Link] Command
The SELECT Command is used to retrieve information from a database.
SELECT <attribute list>
FROM <table list>
WHERE <condition>
Teacher table
7
Teacher_ID First_Name Last_Name Gender Salary Date_of_Birth Dept_No
101 Shanaya Batra F 50000 1984-08-11 1
102 Alice Walton F 48000 1983-02-12 3
103 Surbhi Bansal F 34000 1985-06-11 4
104 Megha Khanna F 38000 1979-04-06 4
105 Tarannum Malik F 54000 1978-04-22 5
106 Tarun Mehta M 50000 1980-08-21 2
107 Puneet NULL M 52500 1976-09-25 3
108 Namit Gupta M 49750 1981-10-19 1
109 Neha Singh F 49000 1984-07-30 7
110 Divya Chaudhary F 39000 1983-12-11 6
111 Saurbh Pant M 40000 1982-01-05 8
112 Sumita Arora F 40000 1981-09-09 9
113 Vinita Ghosh F 51500 1980-09-09 9
114 Vansh NULL M 53500 1982-05-04 2
1. Query – To retrieve all the information about Teacher with ID=101. In this query we have to specify all the
attributes in the SELECT clause. An easier way to do this is to use asterisk (*), which means all the attributes.
SELECT *
FROM Teacher
WHERE Teacher_ID=101;
Output –
Teacher_ID First_Name Last_Name Gender Salary Date_of_Birth Dept_No
101 Shanaya Batra F 50000 1984-08-11 1
2. Query – To find the names of all teachers earning more than 50000.
SELECT First_Name,Last_Name
FROM Teacher
WHERE salary > 50000;
Output –
First_Name Last_Name
Tarannum Malik
Puneet NULL
Vinita Ghosh
Vansh NULL
3. Query – To display Teacher_ID,First_Name,Last_Name and Dept_No of teachers who belongs to
department number 4 or 7.
SELECT Teacher_ID,First_Name,Last_Name, Dept_No
FROM Teacher
WHERE Dept_No = 4 OR Dept_No = 7;
Output –
Teacher_ID First_Name Last_Name Dept_No
103 Surbhi Bansal 4
104 Megha Khanna 4
109 Neha Singh 7

4. Query – To retrieve names of all the teachers and the names and numbers of their respective departments.
Note that the above query requires two tables – Teacher and Department. Consider the following query:
8
SELECT First_Name, Last_Name, Dept_ID, Dept_Name
FROM Teacher, Department;
5. Query – To retrieve names of all the teachers who belong to Hindi department.
SELECT First_Name, Last_Name
FROM Teacher, Department
WHERE Department. Dept_ID=Teacher. Dept_ID AND
Dept_Name=”Hindi”;
First_Name Last_Name
Surbhi Bansal
Megha Khanna
6. Query – To retrieve names of all the teachers starting from letter ‘S’.
SELECT First_Name
FROM Teacher
WHERE First_Name LIKE “S%”;
Output –
First_Name
Shanaya
Surbhi
Saurbh
Sumita
7. Query – To retrieve names of all the teachers having 6 characters in the first name and starting with ‘S’
SELECT First_Name
FROM Teacher
WHERE First_Name LIKE “S_ _ _ _ _”;
Output –
First_Name
Surbhi
Snmita
8. Query – To retrieve names of all the teachers having at least 6 characters in the first name.
SELECT First_Name
FROM Teacher
WHERE First_Name LIKE “_ _ _ _ _ _%”;
Output –
First_Name
Shanaya
Surbhi
Tarannum
9. Query – To list the names of teachers in alphabetical order.
SELECT First_Name, Last_Name
FROM Teacher
ORDER BY First_Name, Last_Name;
Output –
First_Name Last_Name
Shanaya Batra
Alice Walton
Surbhi Bansal
Megha Khanna
Tarannum Malik
9
Tarun Mehta
Puneet NULL
Namit Gupta
Neha Singh
Divya Chaudhary
Saurbh Pant
Sumita Arora
Vinita Ghosh
Vansh NULL
10. Query – To list the names of all the Departments in the descending order of their names.
SELECT Dept_Name
FROM Department
ORDER BY Dept_Name DESC;
Output –
Dept_Name
Physics
Mathematics
Hindi
English
Economics
Computer Science
Commerce
Chemistry
Biology
11. Query – To retrieve the names and department numbers of all the teachers ordered by the Department
number and within each department ordered by the names of the teachers in descending order.
SELECT First_Name, Last_Name, Dept_No
FROM Teacher
ORDER BY Dept_No ASC, First_Name DESC, Last_Name DESC;
Output –
First_Name Last_Name Dept_No
Shanaya Batra 1
Namit Gupta 1
Tarun Mehta 2
Vansh NULL 2
Alice Walton 3
Puneet NULL 3
Surbhi Bansal 4
Megha Khanna 4
Tarannum Malik 5
Divya Chaudhary 6
Neha Singh 7
Saurbh Pant 8
10
Sumita Arora 9
Vinita Ghosh 9
12. Query – To retrieve all the details of those employees whose last name is not specified.
SELECT *
FROM Teacher
WHERE Last_Name IS NULL;
Output –
Teacher_ID First_Name Last_Name Gender Salary Date_of_Birth Dept_No
107 Puneet NULL M 52500. 1976-09-25 3
00
104 Vansh NULL M53500. 1982-05-04 2
00
13. Query – To find the maximum and minimum salary.
SELECT MAX(Salary) AS Max_Salary, MIN(Salary) AS
Min_Salary
FROM Teacher;
Output –
Max_Salary Min_Salary
54000.00 34000.00
14. Query – To count the number of teachers earning more than Rs 40000.
SELECT COUNT(Salary)
FROM Teacher
WHERE Salary > 40000;
Output –
Count(Salary)
9
15. Query – To retrieve the number of teachers in “Computer Science” Department.
SELECT COUNT(*) AS No_of_Computer_Science_Teachers
FROM Department, Teacher
WHERE Dept_Name = “Computer Science”AND Dept_No=Dept_ID;
Output –
No_of_Computer_Science_Teachers
2
MCQ
1. Data is a collection of ________ facts which have not been processed to reveal useful information.
a. Raw t
b. Facts
c. Process
d. None of the above
Answer - a. Raw
2. Which of the following properties belong to the database _______________.
a. A database is a representation of some aspect of the real world also called miniworld.
b. It is designed, built and populated with data for specific purposes.
c. It can be of any size and complexity.
d. All of the above
Answer - d. All of the above
3. What are the benefits of databases ___________.
a. Data Redundancy
b. Data Inconsistency
c. Lack of Data Integration
d. All of the above
Answer -d. All of the above
11
4. A ____________is a collection of programs that enables users to rate, maintain and use a database.
a. Database management system
b. Database manageable system
c. Database updation system
d. None of the above
Answer - a. Database management system
5. Which of the following is not a valid SQL type?
a. FLOAT
b. NUMERIC
c. DECIMAL
d. CHARACTER
Answer - d. CHARACTER
6. Which of the following is not a DDL command?
a. TRUNCATE
b. ALTER
c. CREATE
d. UPDATE
Answer - d. UPDATE
7. What are the various operations that need to be performed on a database _____________.
a. Defining the database
b. Sharing the database
c. Manipulating the database
d. All of the above
Answer - d. All of the above
9. What are the different characteristics of Database management systems?
a. Self – describing Nature of a database system
b. Insulation between programs and data
c. Sharing of data
d. All of the above
Answer - d. All of the above
10. A multiuser environment allows multiple users to access the database simultaneously; it means
___________.
a. Sharing of data
b. Insulation between Program and data
c. Self-describing Nature of database system
d. None of the above
Answer - a. Sharing of data
11. any change in the structure of data would be done in the catalog and hence programs which access this data
need not be modified. This property is called_____________.
a. Program-Data Independence
b. Self describing
c. Sharing of data
d. None of the above
Answer - a. Program-Data Independence
12. What are the different types of DBMS users ____________.
a. End users
b. Database Administrator
c. Application programmers
d. All of the above
Answer - d. All of the above
13. Users who use the database for querying, modifying and generating reports as per their needs. They are not
concerned about the working and designing of the database known as _________.
a. End users
b. Database Administrator
c. Application programmers
d. All of the above
Answer - a. End users
12
12. How many Primary keys can there be in a table?
a. Only 1
b. Only 2
c. Depends on no of Columns
d. Depends on DBA
Answer - a. Only 1
13. Which of the following is not Constraint in SQL?
a. Primary Key
b. Not Null
c. Check
d. Union
Answer - d. Union
14. What operator tests column for absence of data
a. NOT Operator
b. Exists Operator
c. IS NULL Operator
d. None of the above
Answer - c. IS NULL Operator
15. __________ is responsible for authoring access, monitoring its use, providing technical support, acquiring
software and hardware resources.
a. End users
b. Database Administrator
c. Application programmers
d. All of the above
Answer - b. Database Administrator
16. ___________ write application program to interact with the database.
a. End users
b. Database Administrator
c. Application programmers
d. All of the above
Answer - c. Application programmers
17. _________ determines the requirements of the end users and then develops specifications to meet these
requirements
a. End users
b. Database Administrator
c. System Analyst
d. All of the above
Answer - c. System Analyst
18. __________plays a major role in the database design and all the technical, economic and feasibility aspects.
a. End users
b. Database Administrator
c. System Analyst
d. All of the above
Answer - c. System Analyst
19. Advantages of using DBMS approach.
a. Reduction in Redundancy
b. Improved consistency
c. Improved availability
d. All of the above
Answer - d. All of the above
20. Data in a DBMS is more concise because of the __________ of data.
a. Non availability of data
b. Central repository
c. Data is not Security
d. None of the above
Answer - b. Central repository
13
21. By making use of ___________, the DBA can provide security to the database.
a. Database access rights
b. Password
c. Controlling users
d. All of the above
Answer - d. All of the above
22. Limitation of using DBMS approach _________.
a. High cost
b. Security and recovery overheads
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)
23. __________organize collection of data as a collection of relations where each relation corresponds to a
table of values.
a. Data method
b. Database
c. Data system
d. None of the above
Answer - b. Database
24. A row is also called a ________.
a. Field
b. Tuple
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)
25. A column is also called ________.
a. Attribute
b. Relation
c. Domain
d. Degree
Answer - a. Attribute
26. The data types of values in each column are called __________.
a. Attribute
b. Relation
c. Domain
d. Degree
Answer - c. Domain
27. The number of attributes in a relation is called the _________ of a relation.
a. Attribute
b. Relation
c. Domain
d. Degree
Answer - d. Degree
28. The number of rows in a relation is called the _________ of a relation.
a. Cardinality
b. Relation
c. Domain
d. Degree
Answer - a. Cardinality
29. Some of the examples of databases are ___________.
a. IBM DB2
b. Oracle
c. MySQL
d. All of the above
Answer - d. All of the above
30. __________ are restrictions on the values, stored in a database based on the requirements.
a. Method
14
b. Constraints
c. Properties
d. None of the above
Answer - b. Constraints
31. What are examples of constraints in relational models?
a. Domain constraint
b. Key constraint
c. Entity Integrity constraint
d. All of the above
Answer - d. All of the above
32. What are the examples of key constraints?
a. Super key
b. Candidate key
c. Primary key
d. All of the above
Answer - d. All of the above
33. __________ is a set of attributes in a relation, for which no two tuples in a relation state have the same
combination of values.
a. Super key
b. Candidate key
c. Primary key
d. All of the above
Answer - a. Super key
34. _________ key helps to protect duplication in the table.
a. Super key
b. Candidate key
c. Primary key
d. All of the above
Answer - c. Primary key
35. ____________ is a language that is used to manage data stored in a RDBMS.
a. DDL
b. DML
c. SQL
d. None of the above
Answer - c. SQL
36. SQL Stands for __________.
a. System Query Language
b. Structured Query Language
c. Social Query Language
d. None of the above
Answer - b. Structured Query Language
37. DDL Stands for ___________.
a. Data Database Language
b. Domain Definition Language
c. Data Definition Language
d. None of the above
Answer - c. Data Definition Language
38. DML Stands for ___________.
a. Data Manageable Language
b. Domain Manipulation Language
c. Data Manipulation Language
d. None of the above
Answer - c. Data Manipulation Language
39. Database system needs to be installed on the Computer and this computer is known as ___________.
a. Database Server
b. Database storage
15
c. Database memory
d. None of the above
Answer - a. Database Server
40. _________ command is used to create a new table in the database.
a. Select command
b. Create command
c. Modify command
d. Alter command
Answer - b. Create command
41. Which datatype belongs to numerical type.
a. Integer
b. . Number
c. Decimal
d. All of the above
Answer - d. All of the above
41. What data type has a fixed length in the database.
a. Varchar(n)
b. Char(n)
c. Longvarchar(n)
d. None of the above
Answer - b. Char(n)
42. Which syntax is correct for creating a table _________.
a. Create table <table name> ( <column name> <data type>);
b. Create table <column name> ( <table name> <data type>);
c. Create table ( <column1 name> <data type>);
d. None of the above
Answer - a. Create table ( );
43. Which command is used to creating a Database;
a. Create <database name>;
b. Create Database <database name>;
c. Database Create <database name>;
d. None of the above
Answer - b. Create Database ;
44. Which command is used to display a Database;
a. Display DATABASE;
b. Show DATABASE;
c. Check DATABASE;
d. None of the above
Answer - b. Show DATABASE;
45. A command that lets you change one or more field in a table is:
a. INSERT
b. MODIFY
c. LOOK-UP
d. All of the above
Answer - b. MODIFY
46. How can you change “Mehta” into “Sinha” in the “LastName” column in the Users table?
a. UPDATE User SET LastName = ‘Mehta’ INTO LastName = ‘Singh’
b. MODIFY Users SET LastName = ‘Sinha’ LAST LastName = ‘Sinha’
c. MODIFY Users SET LastName = ‘Mehta’ INTO LastName = ‘Sinha’’
d. UPDATE Users SET LastName = ‘Mehta’ WHERE LastName = ‘Sinha’’
Answer - d. UPDATE Users SET LastName = ‘Mehta’ WHERE LastName = ‘Sinha’’
47. What are the several constraints for smooth operations in the database.
a. NOT NULL
b. DEFAULT
c. CHECK
d. All of the above
16
Answer - d. All of the above
48. If a user has not entered a value for an attribute, then the default value specified while creating the table is
used; this constraint is done by using _________.
a. NOT NULL
b. DEFAULT
c. CHECK
d. All of the above
Answer - b. DEFAULT
49. ___________ ensures that there must always exist a valid relationship between two relational database
tables.
a. Referential Integrity Constraint
b. Key Constraint
c. Default Constraint
d. None of the above
Answer - a. Referential Integrity Constraint
50. A foreign key constraints can reference columns within the same table. These tables are called
___________.
a. Self-referencing tables
b. Key Constraint
c. Default Constraint
d. None of the above
Answer - a. Self-referencing tables
51. The advantage is that named constraints can be easily _________ using the alter Table command.
a. Updated
b. Deleted
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)
52. The command is used to delete tables from a database _________.
a. Delete Table
b. Remove Table
c. Drop Table
d. None of the above
Answer - c. Drop Table
53. ____________command is used to modify the base table definition. The modifications that can be done
using this command.
a. Update Table
b. Alter Table
c. Modify Table
d. None of the above
Answer - b. Alter Table
54. A column can be dropped using this command but one must specify the options __________ for the drop
behavior.
a. Restrict
b. Cascade
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)55. If the reference is given in another table then ________ command is not allowed
to drop the table.
a. Restrict
b. Cascade
c. Both a) and b)
d. None of the above
Answer - a. Restrict
56. If the reference is given in another table then ________ command is allowed to drop the table.
a. Restrict
b. Cascade
17
c. Both a) and b)
d. None of the above
Answer - b. Cascade
57. A f___________key can be dropped by using the ALTER TABLE command.
a. Primary key
b. Foreign key
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)
58. Insert command helps to insert _________ in the table.
a. Column
b. Row
c. Tuple
d. All of the above
Answer - d. All of the above
59. ___________command is used to update the attribute values of one or more tuples in a table.
a. Insert table
b. Update table
c. Alter table
d. None of the above
Answer - b. Update table
60. In order to delete one or more tuples, _________ command is used.
a. Drop command
b. Delete command
c. Remove command
d. Erase command
Answer - b. Delete command
61. The ____________ Command is used to retrieve information from a database.
a. Select command
b. Display command
c. Show command
d. None of the above
Answer - a. Select command
62. Where clause you can use in which of the following commands.
a. Delete command
b. Select command
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)
63. ________ helps to count the number of tuples in the database.
a. Count
b. Sum
c. Max
d. Min
Answer - a. Count
64. _______ finds the sum of all the values for a selected attribute which has a numeric data type.
a. Count
b. Sum
c. Max
d. Min
Answer - b. Sum
65. ________ finds the maximum value out of all the values for a selected attribute which has numeric data
type.
a. Greatest
b. Maximum
c. Max
d. Minimum
18
Answer - c. Max
66. _________ helps to find the minimum value out of all values for a selected attribute which has numeric data
type.
a. Minimum
b. Min
c. Lowest
d. None of the above
Answer - b. Min
67. _________ helps to find the average value of all the values for a selected attribute which has numeric data
type.
a. Middle
b. Average
c. AVG
d. None of the above
Answer - c. AVG
68. Which SQL keyword is used to display the data based on certain pattern?
a. LIKE
b. IN
c. BETWEEN
d. RANGE
Answer - a. LIKE
69. Sagun is creating a table SALESMAN with fields Salesman number, Name, Total Sales. She doesn’t want
the Total Sales column to be remain unfilled i.e. she wants to make entry in this field mandatory. Which
constraint she should use at the time of creating SALESMAN table:
a. Check
b. Default
c. Not null
d. Primary key
Answer - c. Not null
70. Ranjana wants to delete the records where name starts with A from the table CUSTOMER having fields
Name, Amount, Discount. Identify the correct command:
a. Delete CUSTOMER where name like “A%”;
b. Delete from CUSTOMER where name like “A%”;
c. Delete CUSTOMER where name = “A%”;
d. Delete from CUSTOMER where name = “A%”;
Answer - b. Delete from CUSTOMER where name like “A%”;
71. The ______________command is used to modify the structure of the table STUDENT in MySQL.
a. Modify table STUDENT
b. Alter table STUDENT
c. Alter STUDENT
d. Modify STUDENT
Answer - b. Alter table STUDENT
72. Garvit wants to change the default value of DISCOUNT in the CUSTOMER table from 10 to 15. Select the
most appropriate command to do the same from the following options:
a. ALTER TABLE CUSTOMER ALTER DISCOUNT SET DEFAULT 15;
b. ALTER TABLE CUSTOMER DELETE DISCOUNT SET DEFAULT 15;
c. ALTER TABLE CUSTOMER MODIFY DISCOUNT SET DEFAULT 15;
d. ALTER TABLE CUSTOMER CHANGE DISCOUNT SET DEFAULT 15;
Answer - a. ALTER TABLE CUSTOMER ALTER DISCOUNT SET DEFAULT 15;
73. Consider a table: COACHING having fields CITY_NAME, ENROLMENTS. Shikhar wants to display the
data of the above table in ascending order of enrolments. Choose the correct query/queries from the following:
i. Select * from coaching order by enrolments asc;
ii. Select * from coaching order by enrolments desc;
iii. Select * from coaching order by enrolments;
iv. Select * from coaching order by enrolments ascending; Select the correct option:
a. Only (i) is correct
b. Both (i) and (ii) are correct
19
c. Both (i) and (iii) are correct
d. Only (iv) is correct
Answer - c. Both (i) and (iii) are correct
74. Geeta wants to know the usage of NULL in MySQL. Help her choose in which of the following case NULL
value cannot be assigned to the column Admission_Number:
a. When the Admission_Number is zero
b. When the Admission_Number is not known
c. When the Admission_Number is not available
d. When the Admission_Number is not applicable
Answer - a. When the Admission_Number is zero
75. Which of the following is NOT an advantage of DBMS approach:
a. All the data is stored at one place. There is no repetition of the same data.
b. There is a single copy of data that is accessed or updated by all the users.
c. The DBA can provide security to the database by controlling users’ database access rights.
d. Designing the database specifications and writing application programs is a time-consuming process.
Answer - d. Designing the database specifications and writing application programs is a time-consuming
process.
76. An attribute A of datatype varchar(20) has the value “Keshav”. The attribute B of datatype char(20) has
value ”Meenakshi”. How many characters are occupied in attribute A and attribute B?
a. 20,6
b. 6,20
c. 9,6
d. 6,9
Answer - b. 6,20
77. Cardinality of a table is four and degree is three. If two columns and four rows are added to the table what
will be the new degree and cardinality of the given table:
a. 5,8
b. 3,4
c. 8,5
d. 4,3
Answer - a. 5,8
Important Questions
1. What is data?
Answer – Data is a collection of raw facts which have not been processed to reveal useful information.
2. What is Database?
Answer – A database is an organized collection of structured information, or data, typically stored
electronically in a computer system. A database is usually controlled by a database management system.
3. What are the different properties of Database?
Answer – The different properties of Database are –
1) A database is a representation of some aspect of the real world also called miniworld. Whenever there are
changes in this miniworld they are also reflected in the database.
2) It is designed, built and populated with data for specific purposes.
3) It can be of any size and complexity.
4) It can be maintained manually or it may be computerized.
4. Why is a database required?
Answer – Large amounts of data may be kept in one location, which makes databases a suitable choice for data
access. The data can be accessed and changed simultaneously by several individuals. You can quickly and
easily find the information you need in databases since they can be searched and sorted.
5. What are the different advantages of Database?
Answer – Advantages of database are –
1. Reduction in Redundancy: All the data is stored at one place. There is no repetition of the same data. This
also reduces the cost of storing data on hard disks or other memory devices.
2. Improved Consistency: The chances of data inconsistencies in a database are also reduced as there is a single
copy of data that is accessed or updated by all the users.
3. Improved Availability: Same information is made available to different users. This helps sharing of
information by various users of the database.
20
4. Improved Security: By making use of passwords and controlling users’ database access rights, the DBA can
provide security to the database.
5. User Friendly: Using a DBMS, it becomes very easy to access, modify and delete data.
6. What is a Database Management System?
Answer – A database management system is a group of applications that let users build, administer, and use
databases. It permits the development of a data repository that may be created once and then accessible by
various users in accordance with their needs. As a result, all application programmes have access to a single
data source.
7. What are the various operations performed by Database?
Answer – The various operation of database are –
1. Defining the Database: It involves specifying the data type of data that will be stored in the database and also
any constraints on that data.
2. Populating the Database: It involves storing the data on some storage medium that is controlled by DBMS.
3. Manipulating the Database: It involves modifying the database, retrieving data or querying the database,
generating reports from the database etc.
4. Sharing the Database: Allow multiple users to access the database at the same time.
5. Protecting the Database: It enables protection of the database from software/ hardware failures and
unauthorized access.
6. Maintaining the Database: It is easy to adapt to the changing requirements
8 What are the different characteristics of Database?
Answer – The different characteristics of database are –
a. Self-describing Nature of a Database System – The database management system (DBMS) also includes a
description of the data that it stores. Metadata refers to this description of the data. A database catalog or data
dictionary is where meta-data is kept. It includes the data’s structure as well as the limitations placed on the
data.
b. Insulation Between Programs and Data – Programs that access this data don’t need to be changed because
the description of the data is stored separately in the database management system (DBMS) and any changes to
the data’s structure are made in the catalog. The term “Program-Data Independence” refers to this quality.
c. Sharing of Data – Multiple users can access the database at once in a multi user scenario. Therefore, a
DBMS must have concurrency control software to provide concurrent access to the database’s data without
encountering any consistency issues.
9. What are the different types of users of DBMS?
Answer – The different types of DBMS users are –
1. End Users – Users who use the database for querying, modifying and generating reports as per their needs.
2. Database Administrator (DBA) – The DBA is responsible for authoring access, monitoring its use,
providing technical support, acquiring software and hardware resources.
3. Application Programmers – Application programmes write application programs to interact with the
database.
4. System Analyst – A system analyst plays a major role in the database design and all the technical, economic
and feasibility aspects.
10. What are the limitations of using DBMS?
Answer – Limitations of DBMS are –
a. High Cost – The cost of implementing a DBMS system is very high and a very time consuming process.
b. Security and Recovery Overheads – Databases protect the data from unauthorized access from the users.
11. What is a relational Database?
Answer – A collection of data elements with pre-established relationships between them make up a relational
database. These things are arranged in a series of tables with rows and columns. To store data about the things
that will be represented in the database, tables are utilized.
12. What do you mean by domain constraint?
Answer – Columns with user-defined domain constraints make it easier for users to enter values that relate to
the data type. Additionally, it notifies the user that the column is not properly filled in if it receives a faulty
input.
13. What is entity integrity constraint?
Answer – This constraint specifies that the primary key of a relation cannot have null value. The reason behind
this constraint is that we know the primary key contains no duplicates.
14. What is the referential integrity constraint?
21
Answer – Foreign key constraints or referential integrity constraints. A logical rule about the values in one or
more columns in one or more tables is known as a foreign key constraint, also known as a referential constraint
or a referential integrity constraint.
15. How many SQL statements are used? Define them.
Answer – SQL statements are basically divided into two categories, DDL & DML.
a. Data Definition Language – Commands from the Data Definition Language (DDL) are used to specify the
structure holding the data. These commands are automatically committed, which means that any database
changes made by DDL commands are permanently recorded.
b. Data Manipulation Language – The database’s data can be changed using Data Manipulation Language
(DML) commands. These instructions can be rolled back and are not automatically committed.
16. Give an example of DDL & DML commands?
Answer –
Data Definition Language (DDL) commands:
CREATE table
ALTER table
DROP table
Data Manipulation Language (DML) commands:
INSERT table
UPDATE table
DELETE
NCERT Solutions

17. Consider the following Employee table –


Table Name – Employee
Employee_ID Employee_Name Job Title Salary Bonus Age Manager_ID
1201 Divya President 50000 NULL 29 Null
1205 Amyra Manager 30000 2500 26 1201
1211 Rahul Analyst 20000 1500 23 1205
1213 Manish Salesman 15000 Null 22 1205
1216 Megha Analyst 22000 1300 25 1201
1217 Mohit Salesman 16000 Null 22 1205

The primary key of this table is Employee_ID and Manager_ID is a foreign key that references
Employee_ID.
Write SQL commands for the following:
(a) Create the above table
CREATE TABLE EMPLOYEE
(
Employee_ID INTEGER PRIMARY KEY,
Employee_Name VARCHAR(20) NOT NULL,
Job_Title VARCHAR(20),
Salary DECIMAL(10,2) DEFAULT 40000,
Bonus VARCHAR(10),
Age INTEGER,
FOREIGN KEY (Manager_ID) REFERENCES Employee(Employee_ID)
);
(b) Insert values as shown above
INSERT INTO Employee (
Employee_Id, Employee_Name, Job_Title, Salary, Bonus, Age, Manager_Id)
Values (1201, “Divya”, “President”, 50000, NULL, 29, NULL);
or
INSERT INTO Employee (
Employee_Id, Employee_Name, Job_Title, Salary, Bonus, Age, Manager_Id)
Values (1201, “Divya”, “President”, 50000, NULL, 29, NULL),
22
(1205, “Amyra”, “Manager”, 30000, 2500, 26, 1201),
(1211, “Rahul”, “Analyst”, 20000, 1500, 23, 1205),
(1213, “Manish”, “Salesman”, 15000, NULL, 22, 1205),
(1216, “Megha”, “Analyst”, 22000, 1300, 25, 1201),
(1217, “Mohit”, “Salesman”, 16000, NULL, 22, 1205);
(c) Delete the Employee having Employee_ID 1217.
DELETE FROM Employee WHERE Employee_Id = 1217;
(d) Update the salary of “Amyra” to 40000.
UPDATE Employee SET Salary = 40000 WHERE Employee_Name = “Amyra”;
(e) Alter the table Employee so that NULL values are not allowed for Age column.
ALTER TABLE Employee MODIFY Age INTEGER NOT NULL;
(f) Write a query to display names and salaries of those employees whose salary are greater than 20000.
SELECT Employee_Name, Salary FROM Employee WHERE Salary>20000;
(g) Write a query to display details of employees who are not getting any bonus.
SELECT * FROM Employee WHERE Bonus IS NULL;
(h) Write a query to display the names of employees whose name contains “a” as the last alphabet.
SELECT Employee_Name FROM Employee WHERE Employee_Name LIKE “%a”;
(i) Write a query to display the name and Job title of those employees whose Manager_ID is 1201.
SELECT Employee_Name, Job_Title FROM Employee WHERE Manager_ID = 1201;
(j) Write a query to display the name and Job title of those employees whose Manager is “Amyra”
SELECT Employee_Name, Job_Title FROM Employee WHERE Manager = “Amyra”;
(k) Write a query to display the name and Job title of those employees aged between 26 years and 30 years.
SELECT Employee_Name, Job_Title FROM Employee WHERE Age BETWEEN 26 AND 30;
18. A Railway company uses machines to sell tickets. The machine details and daily sales information are
recorded in two tables:
Table Name - Machine
Field Data Type
Machine_ID CHAR(3)
Station Char(30)
Table Name - Sales
Field Data Type
Machine_ID Char(3)
Date DATE
Tickets Sold INTEGER
Income DECIMAL(8,2)

The primary key of the table Machine is Machine_ID. Records in the table Sales are uniquely identified by
the fields Machine_ID and Date.
(a) Create the tables Machine and Sales.
CREATE TABLE MACHINE
(
MACHINE_ID CHAR(3) PRIMARY KEY,
Station CHAR(30)
);
CREATE TABLE SALES
(
MACHINE_ID CHAR(3) NOT NULL UNIQUE,
Date DATE NOT NULL UNIQUE;
Tickets_Sold INTEGER;
Income DECIMAL(8,2)
);
(b) Write a query to find the number of ticket machines in each station.
SELECT Station FROM Machine GROUP BY Tickets_Sold;
(c) Write a query to find the total ticket income of the station “New Delhi” of each day.
23
SELECT Station FROM Machine where Station=”New Delhi” GROUP BY Sales HAVING SUM(Income);
(d) Write a query to find the total number of tickets sold by the machine (Machine_ID = 122) till date.
SELECT SUM(Tickets_Sold) FROM Sales WHERE Machine_ID = 122;

Unit -2 Operating Web


Operating Web-based Applications
Web-based applications are those that can be accessed through a web browser and a network connection. A
web-based application offers the benefit of global availability around-the-clock. Web-based applications are
now utilised for a variety of tasks, including online shopping with the option of paying with credit or debit
cards, e-governance, and learning through online tutorials, quizzes, and other activities.

Online Reservation Systems


A web-based reservation system enables online ticket purchase and cancellation. Online reservation systems
examples are –
• Airline ticket
• Railway ticket
• Bus ticket
• Movie ticket
• Hotel booking
• Car rental
• Tour and travel booking

Advantages of Online Reservation System


The advantages of the online reservation system are :
Advantages for consumers online reservation
[Link] – The user/consumer can book tickets anytime anywhere – from home, office, while travelling,
etc.
[Link] Comparison – Online booking allows the customer to check the prices, compare them and get the best
deal.
[Link] – Most online reservation sites require the user to create their profile and provide them with a
username and password. The information thus remains secure until their password is secure.
[Link] of Reservation – When a booking is done, the confirmation of the booking just takes a few
seconds. It is fast and secure.
[Link] Choices – In online booking, the user can see the arrangement of seats, select a particular seat, etc.
In railway booking, selection of lower berth/upper berth, type of food required and booking for beddings is
possible.
[Link] Saving – Online reservation consumes very less time in contrast to long queues at the counter.
[Link] Scheme – The users can avail the special discount schemes provided by the service provider like,
season discount, advance booking discount and frequent user discount.

Advantages for Providers


[Link] Less Staffing – Less man-power is required as every task is done through computers.
[Link] Spatial Restrictions – The physical location of the office does not really matter to a customer who
is reserving tickets online. So, the organization, big or small, can choose their office space depending on their
needs.
[Link] Access – The scope of access to the online reservation becomes large as anyone who has access to the
Internet can search for the reservation site and book the tickets.

Precautions while Performing Online Transactions


Some actions that can be taken to make the passwords safer are as follows –
• Make a password complex, like mix case, use numbers and special characters. This decreases ability of
automated attacks by trying different character combinations.
• Be cautious not to leave passwords around and do not share them with friends.
• Never use names of near and dear ones as passwords.
24

E-Governance
The government’s ability to give citizens access to information is made easier by the usage of ICT. The
government has established ICT-enabled services, such as the registration of birth and death certificates, the
purchase of train tickets, the submission of RTI requests, etc.
Initiative
The national satellite-based computer network, NICNET, was launched in India in 1987, providing the primary
impetus for e-Governance. The District Information System of the National Informatics Center (DISNIC)
programme, which aims to computerise all district offices across the nation, was then introduced in 1990.
The Department of Electronics and Information Technology (DEITY) and Department of Administrative
Reforms and Public Grievances (DAR&PG) created the National e-Governance Plan (NeGP) in 2006, which
has helped the e-Governance process.
E-Governance Sites
Some of the Central initiatives for e-governance include:
• National e-Governance Plan (NeGP)
• National e-Governance Division (NeGD)
• e-Governance Infrastructure
• Mission Mode Projects
• Citizens Services
• Business Services
• Government Services
• Projects and Initiatives
• R&D in e-Governance
[Link].
[Link] went live on November 10th, 2005. It falls under the National E-Government Plan, or NeGP, as a
Mission Mode Project. The National Informatics Centre, which is a division of the Ministry of Communications
and Information Technology, manages the portal.
[Link]
All websites from the Indian Government, from all levels and throughout all sectors, can be accessed through
this portal. Sites for several Indian states and union territories are also included, as are those for legislative and
judicial branches of government. It also offers details about various industries, including agriculture and
education.

Online Shopping and Bill payments


An online shopping application allows customers to make purchases of goods over the Internet. The customer
can go to a number of websites to conduct online purchasing.
Benefits of Online Shopping
Online shopping is useful in many situations. Here, we discuss some of the situations :
• The customer does not have enough time to visit a store and purchase goods.
• The store where you will get what you need may be very far off.
• The money spent in travelling to the store, parking the car, etc., is much more than overhead if any in
online shopping.
• The product you may require is not available at your market.
• You want to send a product to your friend; you can do online shopping and provide the receiver’s
address. You save your time and energy for delivery of the product to your friend’s house located in a
different city.
• You do not have time during the shopping hours. You can do online shopping from your office, home, a
friend’s place, anywhere, any time. Thus there are no fixed shopping hours
• Online shopping also has bargain offers for the customer delight.
• Some online stores allow customers to rate their services and the items.

Project Management – Web Based Application Development


The process of generating web apps is included in web based application development. A software that is kept
on a distant server is known as a web application. It is accessible online and supplied via a web browser
interface. A web application could be of various types, such as a game, quiz, or calculator for bills.
A project is a task that is carried out to produce an original good, service, or outcome. The following are some
of a project’s essential qualities –
25
• A project has a beginning and an end. The extent of the project is defined. It has boundaries.
• A project requires finite resources that are required to complete the project.
• A project has a specific time frame. It has a definite beginning and end dates.
• A project is complete when its end objectives are achieved. The objective is specific and identifiable.
Project Essentials and Tips
Phases in a Web Application Project
Web-based application development can be broadly divided into four phases. In the development
1) Requirements Definition Phase
2) Design Phase
3) Implementation Phase
4) Testing Phase
Requirement Definition Phase
In this phase we identify the problem statement for which the web application is to be developed.
Feasibility : Is the project feasible?
(i) Check whether the project is technically feasible (is it possible to do it?).
(ii) Check whether the project is economically feasible (is it profitable?).
(iii) If feasible, proceed further, otherwise there is no need to proceed with the project.
Scope : The focus is on “what” the application must do. To define the scope of the application,
(i) Compile a detailed list with a clear description of application features.
(ii) Establish the goals that the solution must achieve.
(iii) Recognizing the limitations that are placed on the project.
Design Phase
The focus is on “how” the application is to be designed. This consists of design of –
A Map of the Web Application Site – A site map for a web application comprises crucial details about the
site’s structure, including the pages and the connections between them.
Database – Design the application database.
(i) Identify the database tables that will be required in the application.
(ii) Decide the table structures: For each table we need to identity the attributes of the tables, their data types,
the size of the columns in the tables, the relationship between tables.
Page Structure – Design the structure of page. Identify the main sections of the page like header, main content
and sidebar.
Implementation Phase
Create backend database, frontend and the connectivity between them.
Backend Database – Create the database and write SQL code defining tables, attributes and relationships, as
per the requirement of the application.
Frontend – Identify the inputs that are required to be taken from the user in the Front-End of the application.
Decide the kind of buttons you will provide to the user, to minimize the user’s typing effort, like, Radio buttons,
checkbox, list and combo box.
Data Connectivity – Establish the data connectivity between the Front-End interface and Back-End Database.
Testing Phase
Test the front end and back end of the entire programme using various example data sets. Find and fix any
application bug you can.
MCQ
1. An application that can be accessed via a web browser, over a network connection is called a
___________.
a. Web-based application
b. Server-based application
c. Both a) and b)
d. None of the above
Answer - a. Web-based application
2. Which one of the websites has an online reservation system?
a. [Link]
b. [Link]
c. [Link]
d. All of the above
Answer - d. All of the above
26
3. What are the advantages of online reservation?
a. Convenient
b. Price comparison
c. Security
d. All of the above
Answer - d. All of the above
4. What are the actions that can be taken to make a password?
a. Make a password complex, like a mix case, use numbers and special characters.
b. Never use common name, date of birth and city in the password
c. Don’t share passwords with your friends or relatives.
d. All of the above
Answer - d. All of the above
5. Give some examples of search engines.
a. Google
b. Yahoo
c. Bing
d. All of the above
Answer - d. All of the above
6. NICNET Stands for ___________.
a. National Satellite Based Computer Network
b. New Satellite Based Computer Network
c. National State Based Computer Network
d. None of the above
Answer - a. National Satellite Based Computer Network
8. NICNET is launched in _________.
a. 1986
b. 1977
c. 1987
d. 1977
Answer - c. 1987
9. DISNIC State for __________.
a. Digital Information System of the National Informatics Center
b. District Information System of the National Informatics Center
c. Digital Internet System of the National Informatics Center
d. None of the above
Answer - b. District Information System of the National Informatics Center
10. DEITY Stands for __________.
a. Department of Electric and Information Technology
b. Department of Electric and Indian Technology
c. Department of Electronics and Information Technology
d. None of the above
Answer - c. Department of Electronics and Information Technology
11. Examples of the Central initiatives for e-governance are ___________.
a. National e-Governance Plan (NeGP)
b. National e-Governance Division (NeGD)
c. e-Governance Infrastructure
d. All of the above
Answer - d. All of the above
12. Which of the following is the National Portal of India website.
a. [Link]
b. [Link]
c. [Link]
d. None of the above
Answer - c. [Link]
13. ________ website provides a single window access to information and services being provided by the
various Indian Government entities.
a. [Link]
27
b. [Link]
c. [Link]
d. None of the above
Answer - a. [Link]
14. [Link] is a Mission Mode Project under the National E-Governance Plan, designed and
maintained by ___________.
a. National Informatics Center
b. DeitY
c. MoCIT
d. All of the above
Answer - d. All of the above
15. ____________ portal is a one point source to access all Indian Government websites at all levels and
from all sectors.
a. [Link]
b. [Link]
c. [Link]
d. None of the above
Answer - b. [Link]
16. Online shopping is an ____________ where the customer can purchase goods over the Internet.
a. Banking application
b. e-Commerce application
c. Government application
d. None of the above
Answer - b. e-Commerce application
17. What are the situations where Online Shopping is useful?
a. The customer does not have enough time to visit a store and purchase goods.
b. The store where you will get what you need may be very far off.
c. The product you may require is not available at your market.
d. All of the above
Answer - d. All of the above
18. What are the different methods for making payment to the website?
a. Cash on delivery
b. Wire transfer
c. e-Voucher
d. All of the above
Answer - d. All of the above
19. Give examples of Online education sites.
a. [Link]
b. [Link]
c. [Link]
d. All of the above
Answer - d. All of the above
20. NCERT portal that provides online learning resources like _________.
a. e-Book
b. Question papers
c. Journals & Children Book
d. All of the above
Answer - d. All of the above
21. A web application is a program that is stored on a _________.
a. Web Server
b. Voice Server
d. Data Server
e. None of the above
Answer - a. Web Server
22. What characteristics are required for a new project.
a. A project requires finite resources that are required to complete the project.
b. A project has a specific time frame
28
c. A project is complete when its end objectives are achieved
d. All of the above
Answer - d. All of the above
23. What are the different phases in a Web application project?
a. Requirements Definition Phase
b. Design Phase
c. Implementation Phase & Testing Phase
d. All of the above
Answer - d. All of the above
24. _____________ In this phase we identify the problem statement for which the web application is to be
developed. Identify the scope of the problem.
a. Requirements Definition Phase
b. Design Phase
c. Implementation Phase
d. Testing Phase
Answer - a. Requirements Definition Phase
25. In the Requirements Definition Phase what are the feasibility required?
a. Check whether the project is technically feasible
b. Check whether the project is economically feasible
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)
26. In the Requirements Definition Phase, The focus is on “What” the application must do. to define the
scope of the application _____________.
a. Compile a detailed list with a clear description of application features.
b. Establish the goals that the solution must achieve.
c. Recognizing the limitations that are placed on the project.
d. All of the above
Answer - d. All of the above
27. What are the different keys required to design the application database?
a. Identify the database tables that will be required in the application
b. Each table we need to identify the attributes of the tables, their data types and size of the column.
c. Decide the table structures
d. All of the above
Answer - d. All of the above
28. _________ development means working on server-side software, which focuses on everything you
can’t see on a website.
a. Front – end
b. Back – end
c. Between – end
d. None of the above
Answer - b. Back – end
29. __________ phase helps to test applications (Front-End and Back-End) with multiple sample sets of
data.
a. Requirements Definition Phase
b. Design Phase
c. Implementation Phase
d. Testing Phase
Answer - d. Testing Phase
30. __________ is an example of a B2B e-Commerce website.
a. Supply chain management
b. Legacy computer system
c. Sustainable supply chain
d. Electronic data interchange
Answer - a. Supply chain management
31. According to the volume of transactions, it is the most widely used payment method and is quickly
convertible into other kinds of value without a middleman. Which payment mechanisms are meant by
29
this statement?
a. Plastic Card
b. Credit Card
c. Cash
d. None of the above
Answer - . Cash
32. Advantages of using an online website builder include-
a. Low cost
b. Easy to learn
c. Time taking
d. Both a) and b)
Answer - d. Both a) and b)
33. Buying and selling goods over the internet is called _________.
a. Cyber-Commerce
b. Digital-Commerce
c. E-Commerce
d. Hyper Selling
Answer - c. E-Commerce
34. The IRCT (Indian Railways reservation) is an example of _________.
a. Expert System
b. Transaction processing system
c. Management controls system
d. None of the above
Answer - b. Transaction processing system
35. Which website belongs to B2C (Business to Customer).
a. Flipkart t
b. Amazon
c. eBay
d. All of the above
Answer - d. All of the above
36. E-Commerce stands for ___________.
a. Electronic Commerce
b. Electric Commerce
c. Entertainment Commerce
d. None of the above
Answer - a. Electronic Commerce
37. Which of the following products is appropriate for online sales?
a. Electronic Item
b. Books
c. Vegetables & Fruits
d. All of the above
Answer - d. All of the above
38. Which of the following functions is related to e-Commerce.
a. Marketing
b. Finance
c. Supply Chain
d. All of the above
Answer - d. All of the above
39. What precautions we have take when performing online transactions
a. Make a password complex
b. Be cautious when you are paying amount online
c. User antivirus in you device
d. All of the above
Answer - d. All of the above
40. To make a strong password you have to use ___________.
a. Capital Letter in password
b. Use Numbers
30
c. Use Special symbol
d. All of the above
Answer - d. All of the above
Q/A
1. What is Web-application?
Answer – Web-based applications are those that can be accessed through a web browser and a network
connection. A web-based application offers the benefit of global availability around-the-clock. Web-based
applications are now utilised for a variety of tasks, including online shopping with the option of paying with
credit or debit cards, e-governance, and learning through online tutorials, quizzes, and other activities.
2. What are the advantages of online reservation system?
Answer – Online reservation systems have benefits for both the business offering the reservation services and
the customer using the system to make a reservation. We go over the benefits of using an online reservation
system –
Advantages for consumers
a. Convenient – The user/consumer can book tickets anytime anywhere – from home, office, while travelling,
etc. All the user needs is just a computer, Internet access, and a card (credit, debit, etc.) for payment.
b. Price Comparison – Online booking allows the customer to check the prices, compare them and get the best
deal.
c. Security – Most online reservation sites require the user to create their profile and provide them with a
username and password. The information thus remains secure until their password is secure.
d. Confirmation of Reservation – When a booking is done, the confirmation of the booking just takes a few
seconds. It is fast and secure.
e. Time Saving – Online reservation consumes very less time in contrast to long queues at the counter.
Advantages of providers
a. Requires Less Staffing – Less man-power is required as every task is done through computers.
b. No Spatial Restrictions – The physical location of the office does not really matter to a customer who is
reserving tickets online. So, the organization, big or small, can choose their office space depending on their
needs.
c. Global Access – Online reservation is available to anyone irrespective of their physical location.
3. What are the precautions we have to take while performing online transactions?
Answer – The precautions we have to take while performing online transactions are –
a. Make a password complex, like mix case, use numbers and special characters.
b. Be cautious not to leave passwords around and do not share them with friends.
c. Never use names of near and dear ones as passwords.
4. What is e-Governance?
Answer – The use of information and communication technology (ICT) by the government to deliver and
facilitate government services, information exchange, communication transactions, and integration of diverse
stand-alone systems and services is known as electronic governance, or e-governance.
5. What are the initiatives taken by e-Governance.
Answer – The initiatives taken by e-Governance are –
National e-Governance Plan (NeGP)
National e-Governance Division (NeGD)
e-Governance Infrastructure
Mission Mode Projects
Citizens Services
Business Services
Government Services
Projects and Initiatives
R&D in e-Governance
6. What is the purpose of National Portal of India?
Answer – The Portal’s goal is to give people and other stakeholders access through a single window to the data
and services offered by the Indian government. The different ministries and departments of the Indian
government, at the national, state, and district levels, work together through the National Portal of India. The
National Informatics Centre (NIC), DeitY, MoCIT, Government of India built and maintains this portal as a
Mission Mode Project under the National E-Governance Plan.
7. What is the purpose of India Web Directory website?
31
Answer – This portal serves as a single point of access to all websites run by the Indian Government, regardless
of level or sector. It comprises websites for several Indian states and union territories, as well as those for
judicial and legislative branches of government. Additionally, it offers details about numerous industries
including agriculture and education.
8. What are the benefits of Online Shopping?
Answer – Benefits of Online shopping are –
a. You want to send a product to your friend; you can do online shopping and provide the receiver’s address.
b. The store where you will get what you need may be very far off.
c. The money spent in travelling to the store, parking the car, etc., is much more than overhead if any in online
shopping.
d. The product you may require is not available at your market
9. Give some example of online education sites?
Answer – Some of the example of online education sites are –
a. [Link] – e which offers online courses for development of technical skills. It claims to provide projects
built by technical leaders like Google and AT & T. T.
b. [Link] & [Link] – provide high quality online courses for free, in collaboration with various
universities across the globe. They aim to provide free
online education through its partners world wide. The courses include topics from hunanities, science, and
engineering including courses at school level.
c. [Link] – NCERT portal that provides online learning resources in the form of e-books, journals, question
papers, children books, etc.
10. What are the characteristics of project?
Answer – Characteristics of project are –
a. A project has a beginning and an end. The extent of the project is defined. It has boundaries.
b. Aproject requires finite resources that are required to complete the project.
c. Aproject has a specific time frame. It has a definite beginning and end dates.
d. A project is complete when its end objectives are achieved. The objective is specific and identifiable.
11. What are the different phases in a Web application project?
Answer – The different phases of web application project are –
1) Requirements Definition Phase
2) Design Phase
3) Implementation Phase
4) Testing Phase
12. What is requirement definition phase?
Answer – We identify the issue statement for which the web application is to be developed during the
requirement definition phase. Determine the size of the issue.
13. What is design phase?
Answer – The design phase is when the “how” of the application is to design, what are the different certiries of
designing the software.
14. Explore the following sites for online shopping:
1. [Link]
2. [Link]
Answer –
[Link] – An online store and web service company, [Link] Inc. The company offers goods in a
variety of categories, including clothing, auto and industrial equipment, beauty and health care, electronics,
groceries, books, games, jeweler, kids’ and infant products, movies, music, sporting goods, toys, and tools,
among others.
[Link] – While being one of the most popular and well-established e-commerce sites online, eBay doesn’t
actually sell anything. Users can instead offer goods for sale, and other users can then place bids on those goods
in auctions. eBay recently added the ability to purchase products at face value or to make price offers for them.
15. Analyze the following scenarios and describe all the steps of the project development cycle:
(i) Online tutoring
(ii) Online matrimonial bureau
(iii) Online ticket booking
Answer –
(i) Online tutoring – An online instructor follows the same steps as a face-to-face tutor: they organize the
session, deliver it, and then, ideally, give parents a report on it.
32
(ii) Online matrimonial bureau – Online matrimony services refer to the establishment of an online
community that enables its members to communicate and exchange marriage-related information in specialized,
individualized ways.
(iii) Online ticket booking – Smart technology is used in an online booking system to eliminate the dangers of
manual entry and human mistake. By automatically updating procedures like payment, scheduling, monitoring
availability, and notification reminders, it makes booking easier for both you and your consume

Unit 3
Fundamental of Java
Java Programming
Java is a high-level, class-based, object-oriented programming language. Java Interpreter java program to Java
Bytecode. This method has the advantage that once a Java programme has been converted to bytecode, it can be
executed on any platform (such as Windows, Linux, or Mac), provided the platform is running the JVM.
Because of this, Java programmes are extremely portable and cross-platform.
Variables and Datatypes in Java
Int age=20;
here(int is data type ,age is variable,=is assignment operator , 20 is value)

What is Variable?
Variables will be used to store the program’s data. A variable is a placeholder for information whose value may
change as a result of a program’s execution. In a computer, a variable is the name of a memory region that
stores data. All data variables in Java have to be declared and initialized before they are used.
What is Data type?
When declaring variables, we have to specify the data type of information that the member will hold – integer,
fractional, alphanumeric, and so on. The type of a variable tells the compiler, how much memory to reserve
when storing a variable of that type.
Java Datatype is divided into two types –
[Link] data types – includes byte, short, int, long, float, double, boolean and char.
[Link]-primitive data types – such as String, Arrays and Classes.
Primitive data types
A reserved term is used to identify a primitive type, which is predefined by the language. The Java
programming language’s support eight primitive data types.
Data type in Java
Data Type Type of values Size
byte Integer 8-bit
short Integer 16-bit
int Integer 32-bit
long Integer 64-bit
float Floating Point 32-bit
double Floating Point 64-bit
char Character 16-bit
boolean True or False 1-bit
Java Variables Naming rules
[Link] names can begin with either an alphabetic character, an underscore (_), or a dollar sign ($).
[Link] names must be one word. Spaces are not allowed in variable names. Underscores are allowed.
“total_marks” is fine but “total marks” is not.
[Link] are some reserved words in Java that cannot be used as variable names, for example – int.
[Link] is a case-sensitive language. Variable names written in capital letters differ from variable names with the
same spelling but written in small letters.
[Link] is good practice to make variable names meaningful. The name should indicate the use of that variable.
[Link] can define multiple variables of the same type in one statement by separating each with a comma.
33
String Variable
String variables, also known as alphanumeric variables or character variables, treat their values as text. As a
result, string variables may have values that are made up of letters, numbers, or symbols.
Example –
String first_name = “Mayank”;
String last_name = “Saxena”;
Operators
In a programming language, operators are special symbols that carry out certain operations.
[Link] Operators
[Link] Operators
[Link] Operators
[Link] Operators
Athematic Operator
Operator Description Explanation Example(int a=20,b=30) Result
+ Addition Returns the sum of values of a+b 50
operands
- Subtraction Returns the difference of values a-b -10
of operands
* Multiplica tion Returns the product of values of a*b 600
operands
/ Division Returns the quotient of values of b/a 1
operands
% Modulus Returns the reminder of values of a%b 10
operands
++ Increment Increments the operand 1 a++ or ++a 21
-- Decrement Decrements the operand 1 a-- or --a 29
Relational Operators
Operator Description Explanation Example Result(int a=20,b=30)
Equal to Returns true if values of a and b are equal, a==b false
false otherwise
!= Not equal to Returns true if values of a and b are not a!=b true
equal, false otherwise
> Greater than Returns true if values of a is greater than that a>b false
of b , false otherwise
< Less than Returns true if values of a is less than that of a<b true
b , false otherwise
>= Greater than Returns true if values of a is greater than or a>=b false
equal to equal to that of b , false otherwise
<= Less than or Returns true if values of a is greater than or a<=b true
equal to equal to that of b , false otherwise
Assignment Operators
Operator Description Explanation Example Result(int
a=20,b=30)
Simple Assign value of left side operand to a=b a becomes 30
Assignment right side operand
+= Add and Add value of left side operand to right a+=b a becomes 50
Assignment side operand and assigns the result to (20+30)
the right side operand Same as a=a+b
34
-= Subtract and Subtract value of left side operand to a-=b a becomes 10
Assignment right side operand and assigns the (20-30)
result to the right side operand Same
as a=a-b
*= Multiply and Multiplies value of left side operand a*=b a becomes 600
Assignment to right side operand and assigns the (20*30)
result to the right side operand Same
as a=a*b
/= Divide and Divides value of left side operand to a/=b a becomes 0
Assignment right side operand and assigns the (20/30)
result to the right side operand Same
as a=a/b
%= Modulus and Divides value of right side operand by a%=b a becomes 20
Assignment left side operand and assigns the (20%30)
reminder to the right side operand
Same as a=a%b
Logical Operator
Operator Description Explanation Example Result(int
a=20,b=30)
&& Logical AND Returns true if values of both a and b a&&b false
are true ,false otherwise
Logical OR Returns true if values of either a and a b true
b is true ,false otherwise
! Logical NOT Returns true if values of a false, true !a false
otherwise
Selection Structures
In real life, you often select your actions based on whether a condition is true or false. Similarly in a program,
you may want to execute a part of the program based on the value of an expression. Java provides two
statements –
[Link] else Statement
[Link] Statement
The if Else Statement
The if else statement in Java lets us execute a block of code depending upon whether an expression evaluates to
true or false. The structure of the Java if statement is as below –
Syntax –
if (expression) {
statements
}
else
{ }
Question > Write a Java program to check weather age is grater then 20 not?
35
The Switch Statement
The switch statement is used to execute a block of code matching one value out of many possible values. The
structure of the Java switch statement is as follows –
Syntax –
switch (expression) {
case 1:
[Link](“Case 1”);
case 2:
[Link](“Case 2”);
case 3:
[Link](“Case 3”);
default:
[Link](“Default case”);
}
Question > Java programme to display a Switch statement example.
public class Example {
public static void main(String[] args) {
int number=30;
switch(number){
case 10:
[Link](“10”);
break;
case 20:
[Link](“20”);
break;
case 30:
[Link](“30”);
break;
default:
[Link](“Not in 10, 20 or 30”);
}
}
}
Repetition Structures
In real life you often do something repeatedly, for example, consider a task such as reading a book, first you
open the book, and then repeatedly – read a page; flip the page – until you get to the end of the book, then close
the book.
Difference between Entry control loop and Exit control loop
Entry Control Loop Exit Control Loop
In entry control loop condition is checked
In exit control loop condition is checked last
first
If the condition is false, loop body will not If the condition is false, loop body will execute at
execute least once
Example of entry control loop – For & While Example of exit control loop – Do-while
Difference between Entry control loop and Exit control loop
The While Statement
The while statement evaluates the test before executing the body of a loop. The structure of the Java while
statement is as shown –
Syntax –
while (expression)
{
36
statements
}
Question > Write a Java program to print the number from 1 to 5 using while statement.
public class WhileDemo {
public static void main (String[ ] args) {
int number = 1;
while (number <= 5) {
[Link] (“number);
number++;
}}}
The Do While Statement
The do while statement evaluates the test after executing the body of a loop. The structure of the Java do while
statement is as shown –
Syntax –
do
{
statements
} while (expression);
Question > Write a Java program to print the number from 1 to 5 using do-while statement.
public class DowhileDemo {
public static void main (String[ ] args) {
int number = 1;
do {
[Link] (“number);
number++;
} while (number <= 5);
}}
The for Statement
The for loop is the most widely used Java loop construct. The structure of the Java for statement is as below:
Syntax –
for (counter=initial_value; test_condition;change counter)
{
statements
}
Question > Write a Java program to print the number from 1 to 5 using for statement.
public class WhileDemo {
public static void main (String[ ] args) {
int number;
for (number=1; number <= 5; number++) {
[Link] (“number);
}}}
Arrays in Java
Arrays are variables that can hold more than one value, they can hold a list of values of the same type.
For example,
Normal Variable Declaration
37

Array Variable Declaration

User Defined Methods


A method in Java is a block of statements grouped together to perform a specific task. A method has a name, a
return type, an optional list of parameters, and a body. The structure of a Java method is as below –
Syntax –
return_type method_name(list of parameters separated by commas)
{
statements
return statement
}
Example – Let us write a method that given the length and breadth of a rectangle as parameters returns
the area of the rectangle.
static double rectangle_area (double length, double breadth)
{
return (length * breadth);
}
38
Object Oriented Programming
A computer programming paradigm known as object-oriented programming (OOP) arranges the architecture of
software around data or objects rather than functions and logic. An object is a data field with particular
characteristics and behaviour.
What is Class?
A class is a collection of objects with similar characteristics. It serves as a model or blueprint from which things
can be made. It makes sense as a whole. It cannot be bodily.
A class in Java can contain:
• Fields
• Methods
• Constructors
• Blocks
• Nested class and interface
Syntax to declare a class:
class <class_name>{
field;
method;
}
What is Object?
An object is an entity with state and behaviour, such as a chair, bike, marker, pen, table, or car. It could be
intellectual or physical (tangible and intangible). The banking system is an illustration of an intangible entity.
Object Definitions:
• An object is a real-world entity.
• An object is a runtime entity.
• The object is an entity which has state and behavior.
• The object is an instance of a class.
Constructors
A special method member called the constructor method is used to initialize the data members of the class (or
any other initialization is to be done at time of object creation).
The constructor has the same name as the class, has no return type, and may or may not have a parameter
list. Whenever a new object of a class is created, the constructor of the class is invoked automatically. We do
not call the constructor explicitly.
Access Modifiers
In object-oriented languages, the accessibility of classes, methods, and other members is controlled through the
use of access modifiers . Access modifiers are a particular type of syntax used in programming languages that
make it easier to encapsulate components.
Public, protected, default, and private are the four types of access modifiers in Java.
Getter and Setter Methods
A class’s private data members cannot be accessed from outside the class, but you can grant getter and setter
methods controlled access to data members outside the class. The value of a data member is returned by a getter
method.
For example we could define a getter method in the Bookclass for the price data member as given below –
double getPrice ( ) {
return price;
}
Java Libraries
A Java library is nothing more than a selection of already created classes. You can use those classes in your
code when you download them and inform your computer about them.
Java Standard Library
• Without String, Enum, Double, etc., we cannot write any Java programme. Everything we need to write
Java code is available to us through the lang library.
39
• Because util class contains the definitions of all data structures and collections, it is necessary in order to
use data structures and collections in Java.
• We require the io library in order to deal with pipes and read data from files. It enables Java
programmers to use files in their programmes.
Data Input
The data input helps to take input from the user, this input are by default string. There are three ways to read
user input into a Java programme in a command-line environment: Java BufferedReader Class, Java Scanner
Class, and Console Class.
Note – In class 12, Only Java Scanner input is given.
Syntax for taking input from the user –
Scanner user_input = new Scanner([Link]);
Question > Write a program to accept name from user and print them in the console.
import [Link];
public class Datainput {
public static void main(String[] args) {
Scanner user_input = new Scanner([Link]);
[Link](“Enter Your Name”);
String name = user_input.next();
[Link](“Your name is : ” + name);
}}
Array Manipulation
The elements of an array can be any combination of integers, floating numbers, or complex numbers, and they
all share the same underlying data type. Array manipulation helps to manipulate the data using predefine
function, from example “binarySearch()”.
We can search for a specific element in an array using the binarySearch() function of the Arrays class. The array
to be searched and the key element to be searched are the parameters required. The method returns the array’s
index, which is the location of the key. The binarySearch method gives a negative value if the key cannot be
found in the array.
Example – double[] marks = {103, 144, 256.5, 346, 387.5};
int key = 346;
int index = [Link](marks,key);
String Manipulation
Method Description Application mystring=”Hello Output
World”
Char charAt(int Return the character at the given [Link](6) W
index) index
String concat(String Concatenate the specified string at the [Link](“Today”) Hello World
str) end of this string Today
boolean contains Returns true if this string contains the [Link](“Hell”) True
(String s) specified substring
boolen endswith Test whether this string end with the [Link](“old”) False
(String suffix) given suffix
boolen equals (Object Compare this string with specified [Link](“Goodbye False
anObject) object World”)
boolen Compare this string with specified [Link](“hello true
equalsIgnoreCase object ignoring case worls”)
(String another)
Int indeOf (int c) Returns the index of the first [Link](‘W’) 6
occurrence of given substring
40
Int indexOf(String str) Returns true length of the string [Link] (“rld”) 8
Boolean isEmpty() Returns a new string after replacing [Link]() False
all occurrences of old Char in this
string with newChar
Int Length() Returns a new string after replacing [Link]() 11
all occurrences of oldstr in this string
with newstr
String replace(chae Returns a new string after replacing [Link](‘1’,’*’) He**o
oldchar, char all occurrences of old Char in this World
newchar() string with newchar
String replace (String Returns a new string after replacing [Link](“Hello”,”Yello Yellow
oldchar, String all occurrences of old Char in this w”) World
newstr) string with newchar
String toLowerCase() Convert all of the characters in this [Link] Case() hello world
String to lower case
String toUpperCase() Convert all of the characters in this [Link] Upper Case() HELLOW
String to upper case WORLD
Exception Handling
Runtime issues such as ClassNotFoundException, IOException, SQLException, RemoteException, etc. can be
handled through the Java Exception Handling mechanism. An exception is a disruptive occurrence that takes
place at run time, or during the execution of a programme, which interrupts
the regular flow of the program’s instructions.
Java provides the following keywords to handle an exception:
try – A try block surrounds the part of the code that can generate exception(s).
catch – The catch blocks follow a try block. A catch block contains the exception handler – specific code that is
executed when the exception occurs. Multiple catch blocks following a try block can handle different types of
exceptions.
Threads
A multithreaded programme can execute numerous tasks simultaneously for the best possible resource
utilisation on the computer. A multithreaded programme is made up of two or more threads, each of which is
capable of carrying out a particular task independently and concurrently.
In Java, threads can be created in two ways
1. By extending the Thread class
2. By implementing the Runnable interface
Wrapper Classes
Java’s primitive datatypes, including int, float, and others, are typically supplied by value rather than via
reference. Primitive datatypes may occasionally need to be passed by reference. When that happens, you can
use the Java wrapper classes.
These classes encapsulate the primitive datatype in an object. For instance, an int variable is held by the Integer
wrapper class.
MCQ
1. JVM Stands for ___________.
a. Java Virtual Machine
b. Java Verify Machine
c. Java Vector Machine
d. None of the above
Answer - a. Java Virtual Machine
2. Java programs are _____________.
a. Platform Independent
b. Highly Portable
41
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)
3. Java support __________.
a. Compiler
b. Interpreter
d. Assembler
e. None of the above
Answer - b. Interpreter
4. Java converts the program in __________.
a. Byte
b. Megabyte
c. Bytecode
d. None of the above
Answer - c. Bytecode
5. IDE Stands for __________.
a. Integrated Developer Environments
b. Integrated Development Environments
c. Internal Developer Environments
d. Internal Development Environments
Answer - b. Integrated Development Environments
6. Java NetBeans IDE is ________ software.
a. Close source
b. Middle source
c. Open Source
d. None of the above
Answer - c. Open Source
7. How we can write comments in Java programs.
a. Two forward slashes (//)
b. /* and */
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)
8. In Java a group of related classes is known as _______.
a. Group
b. Package
c. Method
d. None of the above
Answer - b. Package
9. In Java most common pre-built Java output methods are ___________.
a. [Link]();
b. Public class
c. Public static void main(String[] args)
d. None of the above
Answer - a. [Link]();
10. A Variable is a placeholder for data that can change its value during program execution.
a. Constant
b. Variable
c. Data type
d. None of the above
42
Answer - b. Variable
11. In Java, How many types of primitive Data Type.
a. 6
b. 7
c. 8
d. 9
Answer - c. 8
12. In Java, Which type of datatype is used to store Integer values.
a. Byte
b. Int
c. Long
d. All of the above
Answer - d. All of the above
13. Int Data Type can store ________ bit of data.
a. 8-bit
b. 16-bit
c. 32-bit
d. 64-bit
Answer - c. 32-bit
14. Float Data Type can store ________ bit of data.
a. 8-bit
b. 16-bit
c. 32-bit
d. 64-bit
Answer - c. 32-bit
15. Double Data Type can store ________ bit of data.
a. 16-bit
b. 32-bit
c. 64-bit
d. 8-bit
Answer - c. 64-bit
16. Char Datatype can store _________ bit of data.
a. 16-bit
b. 32-bit
c. 64-bit
d. 8-bit
Answer - a. 16-bit
17. Boolean Data Type can store _________ bit of data.
a. 16-bit
b. 32-bit
c. 1-bit
d. 8-bit
Answer - c. 1-bit
18. What are the naming rules we have to follow to declare a variable.
a. Variable names can begin with either an alphabetic character, Underscore or a dollar sign.
b. Space are not allowed in variable names
c. Reserved words cannot be used as a variable name
d. All of the above
Answer - d. All of the above
43
19. To store more than one character, we use the _______ data type.
a. Integer
b. Character
c. String
d. None of the above
Answer - c. String
20. ___________ are special symbols in a programming language and perform certain specific operations.
a. Operators
b. Variable
c. Datatype
d. None of the above
Answer - a. Operators
21. ++ is known as which operator.
a. Increment Operator
b. Decrements Operator
c. Assignment Operator
d. Modulus
Answer - a. Increment Operator
22. Which of the following belongs to logical operators.
a. &&
b. ||
c. !
d. All of the above
Answer - d. All of the above
23. Which of the following is an example of selection structures.
a. If else statement
b. Switch statement
c. Else if statement
d. All of the above
Answer - d. All of the above
24. The __________ in Java lets us execute a block of code depending upon whether an expression
evaluates to true or false.
a. If statements
b. For statements
c. Array Statements
d. None of the above
Answer - a. If statements
25. To combine two relational expressions in a program.
a. Logical OR
b. Logical AND
c. Logical NOT
d. None of the above
Answer - b. Logical AND
26. If inside the if is known as _________.
a. Outer If
b. Inner If
c. Nested If
d. All of the above
Answer - c. Nested If
44
27. The ____________ is used to execute a block of code matching one value out of many possible values.
a. If statement
b. Switch Statement
c. For Statement
d. None of the above
Answer - b. Switch Statement
28. The ability of a computer to perform the same set of actions again and again is called looping.
a. Looping
b. Actioning
c. Performing
d. None of the above
Answer - a. Looping
29. What are the different looping statements available in Java?
a. For loop
b. While loop
c. Do-while loop
d. All of the above
Answer - d. All of the above
30. The ________ statement evaluates the test before executing the body of a loop.
a. Goto
b. While loop
c. Do-while loop
d. All of the above
Answer - b. While loop
31. The __________ statement evaluates the test after executing the body of a loop.
a. Goto
b. While loop
c. Do-while loop
d. All of the above
Answer - c. Do-while loop
32. _________ is known as the entry control loop.
a. While loop
b. Do-while loop
c. Goto loop
d. All of the above
Answer - a. While loop
33. __________ is known as the exit control loop.
a. While loop
b. Do-while loop
c. Goto loop
d. All of the above
Answer - b. Do-while loop
34. Which condition required for executing the loop –
a. Initial value
b. Condition
c. Counter
d. All of the above
Answer - d. All of the above
35. __________ are variables that can hold more than one value, they can hold a list of values of the same
type.
45
a. Loop
b. Constant
c. Variable
d. None of the above
Answer - c. Variable
36. __________ helps to create a tab between the numbers in the print statement.
a. \tt
b. \t
c. \tb
d. \tab
Answer - b. \t
37. Array addresses always start from _________.
a. 0
b. 1
c. 2
d. 3
Answer - a. 0
38. OOP Stands for ____________.
a. Object Oriented Programming
b. Outer Oriented Programming
c. Outer Object Programming
d. Oriented Object Programming
Answer - a. Object Oriented Programming
39. Java’s most fundamental features are _________.
a. Class
b. Objects
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)
40. Function declared inside the class is known as __________.
a. Member function
b. Inner function
c. Outer function
d. None of the above
Answer - a. Member function
41. The body of class is enclosed within ____________.
a. Small braces
b. Curly braces
c. Big braces
d. None of the above
Answer - b. Curly braces
42. The variable declared outside the class is known as ___________.
a. Local variable
b. Global variable
c. Inner variable
d. All of the above
Answer - b. Global variable
43. The variable declared inside the class is known as __________.
a. Local variable
b. Global variable
46
c. Inner variable
d. All of the above
Answer - a. Local variable
44. __________ is a data member that is declared but not initialized before using, and is assigned a
default value by the compiler, usually either zero or null.
a. Class
b. Object
c. Constructors
d. None of the above
Answer - c. Constructors
45. __________ has the same name as the class.
a. Class
b. Object
c. Constructors
d. None of the above
Answer - c. Constructors
46. Data members and method members of an object are accessed using the _________ operator.
a. Comma (,)
b. Dot (.)
c. Modular (%)
d. Dollar ($)
Answer - b. Dot (.)
47. Data members of a class can be accessed from outside the class by default. Identify the access
modifiers from the below list __________.
a. Private
b. Public
c. Protected
d. All of the above
Answer - d. All of the above
48. Private data members of a class cannot be accessed outside the class however, you can give controlled
access to data members outside the class through ____________.
a. Getter
b. Setter
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)
49. To import the class from the package, you have to use ____________ keyword.
a. Insert
b. Import
c. Add
d. None of the above
Answer - b. Import
50. We can take input from the user using ___________ object.
a. Scanner
b. [Link]();
c. Both a) and b)
d. None of the above
Answer - a. Scanner
51. _________ function helps to convert string value to the integer value in Java.
a. parseInt();
47
b. parseDouble()
c. parseString();
d. None of the above
Answer - a. parseInt();
52. To sort the array of integers in ascending order _______ function required.
a. Arrange()
b. Filter()
c. Sort()
d. None of the above
Answer - c. Sort()
53. __________ function helps to convert all of the characters in lower case.
a. toLowerCase()
b. toSmallCase()
c. to BelowCase()
d. None of the above
Answer - a. toLowerCase()
54. __________ function helps to convert all the characters in Upper case.
a. toUpperCase()
b. toCaptialCase()
c. touppercase()
d. None of the above
Answer - a. toUpperCase()
55. __________ function helps to return a new string after replacing all occurrences of old string.
a. replace()
b. Change()
c. Convert()
d. None of the above
Answer - a. replace()
56. ________ function helps to return the length of the string.
a. replace()
b. isEmpty()
c. indexOf()
d. None of the above
Answer - a. replace()
57. _______ function helps to return the index of the first occurrence of a given substring.
a. length()
b. isEmpty()
c. indexOf()
d. None of the above
Answer - c. indexOf()
58. When unexpected errors come in the program it is handled by ___________.
a. Error handling
b. Exception handling
c. Both a) and b)
d. None of the above
Answer - b. Exception handling
60. Which keywords handle an exception in Java programming.
a. Try
b. Catch
48
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)
61. _________ helps to access the network services that are running on the local computer.
a. Localhost
b. Local Network
c. network
d. None of the above
Answer - a. Localhost
62. What are the different ways to create threads in Java?
a. By extending the Thread class
b. By implementing the Runnable interface
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)
63. A ______________ is one that can perform multiple tasks concurrently so that there is optimal
utilization of the computer’s resources.
a. Resources program
b. Multithreaded program
c. Class program
d. None of the above
Answer - b. Multithreaded program
64. What are the different types of passing values in Java?
a. Pass by value & not Pass by reference
b. Pass by data & Pass by address
c. Pass by String & Pass by reference
d. None of the above
Answer - a. Pass by value & not Pass by reference
65. What are the basic idea in exception handling ____________.
a. Denote an exception block
b. Catch the exception
c. Handle the exception
d. All of the above
Answer - d. All of the above
66. ___________ a file format based on the popular ZIP file format and is used for aggregating many files
into one.
a. Java ARchive (JAR)
b. Java Bin (JB)
c. Java Method (JM)
d. None of the above
Answer - a. Java ARchive (JAR)
67. JDBC Stands for ___________.
a. Java Data Connection
b. Java Database Connection
c. Java Database Connectivity
d. Java Data Connectivity
Answer - c. Java Database Connectivity
68. An ___________ is a useful mechanism for effectively identifying/detecting and correcting logical
errors in a program. When developing your Java programs.
a. Database
49
b. Assertion
c. Archive
d. None of the above
Answer - b. Assertion
Questions and Answers
1. What is Variable?
Answer – A variable is a storage location for information whose value may vary while a programme is running.
A variable is, technically speaking, the name of a storage area in the computer’s internal memory. The data
present there serves as the variable’s value.
2. What are the different Variable naming rules in Java?
Answer – The variable naming rules in Java are –
a. Variable names can begin with either an alphabetic character, an underscore, or a dollar sign.
b. Space is not allowed in variable names.
c. Reserved words are not used in variables.
d. Java is a case-sensitive language.
3. What are the different Primitive Data Types in Java?
Answer – There are eight different types of primitive data types in Java.
a. Byte
b. Short
c. Int
d. Long
e. Float
f. Double
g. Char
h. Boolean
4. What is String Variable?
Answer – String variables, also known as alphanumeric or character variables, have values that are interpreted
as text. In other words, string variables’ values could be made up of letters, numbers, or symbols.
5. What is Operator and what are the different types of Operator?
Answer – Operators are special symbols in a programming language and perform certain specific operations.
Java support –
a. Arithmetic Operators : +, -, *, /, %, ++, —
b. Relational Operators : ==, !=, >, <, >=, <=
c. Assignment Operators : =, +=, -=, *=, /=, %=
d. Logical Operators : &&, ||, !

6. Difference between Entry control loop and Exit control loop.


Answer – Difference between entry control and Exit control loop are –
Entry Control Loop –
a. Entry Control Loop tests the condition first and then executes the body of the loop.
b. If the condition is false, Entry control loop will not execute
c. Example of entry control loop are – for loop and while loop
Exit Control Loop –
a. Exit Control loop tests the condition after running a block of code.
b. If the condition is false, the Entry control loop will execute at least one time.
c. Example of entry control loop are – do-while
7. What is an Array?
Answer – Arrays are variables that can hold more than one value, they can hold a list of values of the same
type. Example – marks = new double[5];
50
8. What is the purpose of user defined methods?
Answer – User-defined functions are techniques you can use to arrange your code within a body. Once a
function has been defined, it can be used in the same way that the built-in action and parser functions are used.
Instead of being passed by value, variables are passed by reference to functions.
9. What are OOPs?
Answer – OOPs stands for Object Oriented Programming, Java is an Object Oriented Programming (OOP)
language. In an OOP language, a program is a collection of objects that interact with other objects to solve a
problem. Each object is an instance of a class.
10. What is the difference between local and global variables?
Answer – Depending on their scope, variables are divided into global variables and local variables. Local
variables can only be accessed within the function or block in which they are defined, In other hand the global
variables, which can be used worldwide throughout the entire programme.
11. What is the purpose of Constructor in Java?
Answer – A special method member called the constructor method is used to initialize the data members of the
class (or any other initialization is to be done at time of object creation). The constructor has the same name as
the class, has no return type, and may or may not have a parameter list. Whenever a new object of a class is
created, the constructor of the class is invoked automatically. We do not call the constructor explicitly.
12. What are the different types of Access Modifiers?
Answer – Access modifiers are keywords that manage a class’s fields, methods, and function. Examples of
access modifiers are Public, protected, and private.
13. What is the purpose of Getter and Setter Methods?
Answer – Private data members of a class cannot be accessed outside the class however, you can give
controlled access to data members outside the class through getter and setter methods.
Basic Java program –
14. Write a program to accept integer number from user and print the number.
import [Link];
public class HelloWorld {
public static void main(String[] args) {
Scanner reader = new Scanner([Link]);
[Link]("Enter a number: ");
int number = [Link]();
[Link]("You entered: " + number);
}
}
Output -
Enter a number: 20
You entered: 20
15. Write a program to accept two numbers from the user and find the sum of numbers.
class Example {
public static void main(String[] args) {
int n1=22, n2=44, sum;
sum = n1 + n2;
[Link]("The sum is: " + sum);
}
}
Output -
Enter two numbers
22 44
The sum is: 66
16. Write a program to swap the numbers without using 3rd variable.
public class Swap {
public static void main(String[] args) {
int n1=51, n2=48;
[Link]("First number = " + n1);
51
[Link]("Second number = " + n2);
n1=n1+n2;
n2=n1-n2;
n1=n1-n2;
[Link]("Result");
[Link]("First number = " + n1);
[Link]("Second number = " + n2);
}
}
Output -
First number = 51
Second number = 48
Result
First number = 48
Second number = 51
If Statement related program –
17. Write a program to accept number from the user and check whether number is even or odd.
import [Link];
public class Example {
public static void main(String[] args) {
Scanner reader = new Scanner([Link]);
[Link]("Enter a number: ");
int num = [Link]();
if(num % 2 == 0)
[Link](num + " is even");
else
[Link](num + " is odd");
}
}
Output -
Enter a number: 22
22 is even
18. Write a program to accept number from the user and check whether an alphabet is vowel or
consonant.
import [Link];
public class Example {
public static void main(String[] args) {
Scanner reader = new Scanner([Link]);
[Link]("Enter a character: ");
char ch = [Link]().charAt(0);
if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' )
[Link](ch + " is vowel");
else
[Link](ch + " is consonant");
}
}
Output -
Enter a character: a
a is vowel
19. Write a program to accept three numbers from the user and find the largest number.
public class Example {
public static void main(String[] args) {
Scanner reader = new Scanner([Link]);
[Link]("Enter a 1st number: ");
char n1 = [Link]();
52
[Link]("Enter a 2nd number: ");
char n2 = [Link]();
[Link]("Enter a 3rd number: ");
char n3 = [Link]();
if( n1 >= n2 && n1 >= n3)
[Link](n1 + " is the largest number.");
else if (n2 >= n1)
[Link](n2 + " is the largest number.");
else
[Link](n3 + " is the largest number");
}
}
Output -
Enter a 1st number: 7
Enter a 2nd number: 3
Enter a 3rd number: 9
9 is the largest number
20. Write a program to check leap year.
public class Example {
public static void main(String[] args) {
int year = 2022;
boolean leap = false;
if (year % 4 == 0) {
if (year % 100 == 0) {
if (year % 400 == 0)
leap = true;
else
leap = false;
}
else
leap = true;
}
else
leap = false;
if (leap)
[Link](year + " is a leap year.");
else
[Link](year + " is not a leap year");
}
}
Output -
2022 is not a leap year
21. Write a program the check weather a number is positive or negative.
public class Example {
public static void main(String[] args) {
double n1 = 18;
if (number < 0.0)
[Link](number + " is a negative number");
else if ( number > 0.0)
[Link](number + " is a positive number");
else
[Link](number + " is 0");
}
}

Output -
18 is a positive number
53
22. Write a program to check whether a character is alphabet or not.
public class Example {
public static void main(String[] args) {
char c = 'a';

if( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
[Link](c + " is an alphabet");
else
[Link](c + " is not an alphabet");
}
}
Output -
a is an alphabet
Looping statement related program –
23. Write a program to Find Factorial of a Number
n=1*2*3*4*…*n
public class Example {
public static void main(String[] args) {
int num = 10;
long f = 1;
for(int i = 1; i <= num; ++i)
{
f = f * i;
}
[Link]("Factorial of a number ", f);
}
}
Output -
Factorial of a number = 3628800
24. Write a program to print the Fibonacci series 0, 1, 1, 2, 3, 5, 8,
class Example {
public static void main(String[] args) {
int n = 10, first = 0, second = 1, sum = 0;
for (int i = 1; i <= n; i++) {
[Link](first + ", ");
sum = first + second;
first = second;
second = sum;
}
}
}
25. Write a program to check whether the string is palindrome or not.
class Example {
public static void main(String[] args) {
String str = "MADAM", r_str = "";
int strLength;
int strLength = [Link]();
for (int i = (strLength - 1); i >=0; i--) {
r_str = r_str + [Link](i);
}
if ([Link]().equals(r_str.toLowerCase())) {
[Link](str + " is a Palindrome");
}
else {
[Link](str + " is not a Palindrome");
}
54
}
}
Output -
MADAM is a Palindrome
26. Write a program to check whether a number is prime or not.
public class Example {
public static void main(String[] args) {
int num = 7;
boolean f = false;
for (int i = 2; i <= num / 2; i++) {
if (num % i == 0) {
f = true;
break;
}
}
if (!f)
[Link](num + " is a prime number");
else
[Link](num + " is not a prime number");
}
}
Output -
7 is a prime number
Switch Statement related program –
27. Write a program to design simple calculator using switch statement.
import [Link];
class Example {
public static void main(String[] args) {
char ch;
Double number1, number2, result;
Scanner input = new Scanner([Link]);
[Link]("Choose an operator: +, -, *, or /");
[Link]("1. +");
[Link]("2. -");
[Link]("3. *");
[Link]("4. /");
[Link]("Select choice");
ch = [Link]().charAt(0);
[Link]("Enter first number");
number1 = [Link]();
[Link]("Enter second number");
number2 = [Link]();
switch (ch) {
case '+':
result = number1 + number2;
[Link](number1 + " + " + number2 + " = " + result);
break;
case '-':
result = number1 - number2;
[Link](number1 + " - " + number2 + " = " + result);
break;
case '*':
result = number1 * number2;
[Link](number1 + " * " + number2 + " = " + result);
break;
case '/':
result = number1 / number2;
55
[Link](number1 + " / " + number2 + " = " + result);
break;
default:
[Link]("Invalid choice!");
break;
}
[Link]();
}
}
Output -
1. +
2. -
3. *
4. /
Select Choice +
Enter first number 4
Enter second number 6
4 * 6 = 10
Array
28. Write a program to Print an Array.
public class Example {
public static void main(String[] args) {
int[] array = {1, 2, 3, 4, 5};
for (int element: array) {
[Link](element);
}
}
}
Output -
1
2
3
4
5
29. Write a program to find the average of given array 7, 34, 55, 82, 44.
public class Example {
public static void main(String[] args) {
int[] numArray = { 7, 34, 55, 82, 44 };
double sum = 0;
for (double num: numArray) {
sum += num;
}
double average = sum / [Link];
[Link]("The average is " + average);
}
}
Output -
The average is: 44.4
String function related program –
30. Write a program to find the concatenate of two different string
public class Example {
public static void main(String[] args) {
String str1="Anurag";
String str2="Anand";
String str3=[Link](str2);
[Link](str3);
}
56
}
Output -
Anurag Anand
31. Write a program to find the length of the string
public class Example {
public static void main(String[] args) {
String str="Anurag";
int len=[Link]();
[Link](len);
}
}
Output -
6
32. Write a program to convert the string in uppercase format.
public class Example {
public static void main(String[] args) {
String str="anurag";
String upper=[Link]();
[Link](upper);
}
}
Output -
ANURAG
33. Write a program to convert the lowercase string to uppercase string.
public class Example {
public static void main(String[] args) {
String str="ANURAG";
String lower=[Link]();
[Link](lower);
}
}
Output -
anurag
Unit 4
Work Integrated Learing IT
MCQ
1. GUI stands for ____________.
a. Graphical User Interface
b. Graphic User Interaction
c. Graphic User Interface
d. None of the above
Answer - a. Graphical User Interface
2. Which codes and attributes provide an automatically feature __________.
a. IntelliSense
b. Navigate
c. Built – in support
d. All of the above
Answer - a. IntelliSense
3. _________ extends the capability of the main program.
a. IntelliSense
b. Add-ins
c. Built – in Support
d. All of the above
Answer -b. Add-ins
57
4. You can download a variety of Add-ins from ___________ websites.
a. [Link]
b. [Link]
c. [Link]
d. All of the above
Answer - d. All of the above
5. _________ are pieces of program re-used by most developers.
a. IntelliSense
b. Add-ins
c. Snippets
d. None of the above
Answer - c. Snippets
6. ________ helps to reusing the code multiple times in the webpages.
a. IntelliSense
b. Add-ins
c. Snippets
d. None of the above
Answer - c. Snippets
7. Snippets are available in which programming languages ___________.
a. CSS
b. HTML
c. JavaScript & JQuery
d. All of the above
Answer - d. All of the above
8. _________ template helps to create an attractive website.
a. PPD template
b. PSD template
c. PRD template
d. None of the above
Answer - b. PSD template
9. Extension of the photoshop file ___________.
a. .PSD
b. .DOC
c. .PDF
d. .XLS
Answer - a. .PSD
10. In the MEW software _________ is a special feature that can be used for updating an image whenever
the original photoshop image is modified.
a. Command Image
b. Compatibility Image
c. PSD Image
d. None of the above
Answer - b. Compatibility Image
11. _________ helps to apply special effects to web pages just as in presentation software.
a. Slide Transitions
b. Web Transitions
c. Page Transitions
d. All of the above
Answer - c. Page Transitions
12. Add-ins are available on the _________ menu.
a. View
b. Tools
c. Edit
d. Insert
Answer - b. Tools
13. Snippets can be accessed from ________ menu.
a. View
58
b. Tools
c. Panels
d. Insert
Answer - c. Panels
14. PSD can be imported from the _____ menu.
a. File
b. Tools
c. Edit
d. Insert
Answer - a. File
15. Page Transitions is available on the _____ menu.
a. View
b. Tools
c. Format
d. Insert
Answer - c. Format
16. DWT stands for _________.
a. Digital Web Template
b. Dynamic Web Template
c. Dynamic Web Text
d. None of the above
Answer - b. Dynamic Web Template
17. Templates help you organize the entire website to have a consistent look and feel. This is very helpful
when you work with a large number of web pages.
a. Templates
b. Image Editing
c. Embedding
d. None of the above
Answer - a. Templates
18. ________ helps to create a dynamic website with fixed positions for common elements.
a. Static Web Template
b. Dynamic Web Template
c. Auto Web Template
d. None of the above
Answer - b. Dynamic Web Template
19. SEO stands for _______________.
a. Search Ending Optimization
b. Search Engine Option
c. Search Engine Optimization
d. None of the above
Answer - c. Search Engine Optimization
20. We can get a better search ranking of our website using __________.
a. SEO
b. SOE
c. SSD
d. SSL
Answer - a. SEO
21. Search engines crawl a website using _____________.
a. Web
b. Spider
c. Reader
d. None of the above
Answer - b. Spider
22. With the help of ___________ we can Index the website in the search engine.
a. Page Title
b. Page Description
59
c. Page Keyword
d. All of the above
Answer - d. All of the above
23. Page title maximum ________ characters are displayed in search results.
a. 60
b. 70
c. 80
d. 90
Answer - b. 70
24. Page description can contain maximum ___________ characters in the search engine.
a. 128
b. 130
c. 156
d. 180
Answer - c. 156
25. Using HTML and CSS you can create __________ web page.
a. Static
b. Dynamic
c. Both a) and b)
d. None of the above
Answer - a. Static
26. If you want to create a dynamic web page you require __________ language.
a. ASP
b. PHP
c. JavaScript
d. Any one from above
Answer - d. All of the above
27. Data filled using a form can be stored in a _________.
a. Data System
b. Data Base
c. Data Container
d. None of the above
Answer - b. Data Base
28. IIS stands for _____________.
a. Internal Information System
b. Internet Information Services
c. Internet Information System
d. None of the above
Answer - b. Internet Information Services
29. The database is stored in a special folder with the name __________.
a. DB
b. Data
c. Fbdb
d. None of the above
Answer - c. Fbdb
30. ________ is the product that was replaced by Microsoft Expression Web.
a. Dreamweaver
b. Microsoft FrontPage
c. Sublime Text
d. None of the above
Answer - b. Microsoft FrontPage
31. What are the standard procedures to be followed before publishing a website.
a. Examining Structure of a website
b. Estimating Size of a website
c. Removing slow page
d. All of the above
Answer - d. All of the above
60
32. Create a visual diagram of hyperlinks of a website. This helps you understand the ____________.
a. Navigation structure
b. Broken Links
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)
33. If website size is more then the standard size it will take ________?
a. More time to load
b. Website will slowdown
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)
34. To clean up your web page for any unnecessary code is known as _________.
a. Code Sequence
b. Code Optimization
c. Code clean up
d. None of the above
Answer - b. Code Optimization
35. ________ helps the content to store in a web server to be viewed by the public.
a. Hosting
b. Uploading
c. Downloading
d. None of the above
Answer - a. Hosting
36. Web hosting providers allow publishing to upload the website through _________.
a. FTP
b. HTTP
c. SSL
d. None of the above
Answer - a. FTP
37. _________ feature helps to transfer contents of your entire website to a remote computer.
a. Web Helper
b. Web Package
c. Web Content
d. None of the above
Answer - b. Web Package
38. Give the example of Web Authoring Tools?
a. KompoZer
b. Dreamweaver
c. Both a) and b)
d. None of the above
Answer - c. Both a) and b)
39. What are the popular templates available for creating attractive websites?
a. CSS Templates
b. XHTML/CSS Template
c. PSD Template
d. All of the above
Answer - d. All of the above
Question/Answer
1. Explain the purpose of Add-ins.?
Answer – Any third-party software programming or script that is added to a programming to give it extra
features and abilities is known as an add-ins.
Some of the popular add-in websites are –
a. [Link]
b. [Link]
c. [Link]
61
d. [Link]
e. [Link]
2. What is a snippet?
Answer – Snippets are small pieces of code that most developers reuse. Snippets are useful because they allow
you to reuse the same code across several web pages or websites, it saves time and work.
3. What do you mean by PSD templates?
Answer – Photoshop Document (PSD) is an image format that allows multiple layers of graphics to be
combined into a single file. PSD templates help to design attractive websites.
You can download PSD template from –
a. [Link]
b. [Link]
4. What is page Transitions?
Answer – You can use special effects on web pages in the same way that you can in presentation software. This
aids in the presentation of special effects to visitors.
5. What is a Dynamic Web Template?
Answer – A Dynamic Web Template is based on an HTML Web page. It may include editable page layouts,
page elements, settings, formatting, styles, graphics, and specific effects. A dynamic web template’s goal is to
derive or build pages in a web site based on it in order to keep a uniform and consistent appearance and feel
throughout the site.
6. What is Search Engine Optimization?
Answer – In simple terms, it refers to the process of upgrading your website in order to boost its exposure
when consumers use Google, Bing, and other search engines to look for products or services linked to your
business.
7. How does search engine optimization work?
Answer – Bots are used by search engines like Google and Bing to crawl the web, moving from site to site,
collecting information about those sites, and indexing them.
8. What are the different factors important to rank the website?
Answer – The different factors which is important to rank a website are –
a. Page Title (Not more than 70 characters)
b. Page Description (Not more then 156 characters)
c. Keywords
d. Page Headers
e. Internal & External Links
f. ALT text in image file
9. What is frontpage Server Extensions?
Answer – FrontPage Server Extension is a software that allows the frontpage client to connect to the server.
Many web hosting servers use FrontPage Server Extensions.
10. What is a web server?
Answer – A web server is responsible for storing the website’s files, which include all HTML documents as
well as their associated assets, such as photos, CSS stylesheets, JavaScript files, fonts, and video.
11. What is a database?
Answer – A database is a collection of data that has been arranged so that it can be simply accessed and
controlled. To make it easier to access relevant information, you can organize data into tables, rows, and
columns.
12. What are the standard procedures to publish the website?
Answer – The standard procedures to publish the website are –
a. Examining Structure of a website – Check all the internal and external links before publishing.
b. Estimating Size of a website – Always reduce the size of the website, More size will create more loading
time.
c. Removing slow pages – In the website if any slow page is there remove the page or rectify the page
otherwise it will create problems for visitors.
13. What are code optimizations?
Answer – Code optimizations means to clean up unwanted program code from a website.
14. What is web hosting?
Answer – To be viewed by the general public, the content must be hosted on a web server. There are a number
of free web hosting services available that will give you free online space for your content.

You might also like