0% found this document useful (1 vote)
4K views98 pages

Class 8 Notes

Uploaded by

abhinavikka01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
4K views98 pages

Class 8 Notes

Uploaded by

abhinavikka01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 98

Choose the correct option

Question 1

An operating system is:

1. an application software
2. a system software
3. a loader
4. None

Answer

A system software

Reason — An operating system is a system software as it manages various resources and the
overall operations of a computer. It is designed to support the various activities of the
computer in a systematic manner.

Question 2

MS-DOS is a:

1. single-user OS
2. multi-user OS
3. multi-tasking OS
4. None

Answer

Single-user OS

Reason — MS-DOS is a single-user OS as it is designed to manage the computer so that one


user can effectively perform one task at a time.

Question 3

Which of the following is not a main file in MS DOS?

1. IO.SYS
2. COMMAND.COM
3. FILE.EXE
4. MSDOS.SYS

Answer

FILE.EXE
Reason — MS DOS consists of three main files - IO.SYS, COMMAND.COM and
MSDOS.SYS.

Question 4

Windows operating system is popularly known as:

1. Character User Interface


2. Computer User Interface
3. Graphical User Interface
4. None

Answer

Graphical User Interface

Reason — Windows operating system is a graphical user interface as a Windows user


interacts with the computer through graphical features like icons, menus, windows and the
pointer.

Question 5

LINUX is a:

1. Multiprogramming OS
2. Multiuser OS
3. Multiprocessing OS
4. None

Answer

Multiuser OS

Reason — Linux is a multiuser operating system as it allows more than one user to interact
with the computer at a time. Each user can work on different set of programs and data.

Question 6

Which of the following is not an operating system?

1. Windows
2. Java
3. Linux
4. Unix

Answer

Java
Reason — Java is a programming language.

Question 7

What is the full form of GUI?

1. General Unicode Instruction


2. Grand University Interaction
3. Graphical User Interface
4. Genuine Unsubscribed Information

Answer

Graphical User Interface

Reason — The full form of GUI is Graphical User Interface.

Question 8

Which of the following is not a function of operating system?

1. Pointing an icon on the screen


2. Loading itself into the memory
3. Memory management
4. Error detection

Answer

Pointing an icon on the screen

Reason — Loading itself into the memory, memory management and error detection are the
functions of operating system.

Question 9

Which of the following is a CUI based operating system?

1. Android
2. Mac OS
3. MS DOS
4. OS 2

Answer

MS DOS

Reason — MS DOS is a CUI based operating system as the user and the computer interact
with each other using text commands.
Question 10

Which of the following is true about multiprocessing system?

1. Multiple users sharing a common CPU


2. Multiple CPUs are used
3. Multiple I/O units are used
4. None of the above.

Answer

Multiple CPUs are used

Reason — The operating system that executes multiple programs simultaneously on a


computer that has two or more CPUs available independently is called a multiprocessing
operating system.

Fill in the blanks

Question 1

The loading of an operating system in the primary memory is called booting.

Question 2

Windows software was first developed by the Microsoft Corporation.

Question 3

Device management enables the operating system to control I/O devices.

Question 4

The bottom-most part of the desktop is called the Task Bar.

Question 5

Graphical User interface allows user interaction through graphical icons.

Name the following

Question 1

Two types of booting

Answer
(a) Cold Booting
(b) Warm Booting

Question 2

Four types of windows

Answer

(a) Application Window


(b) Document Window
(c) Dialog Window
(d) Active Window

Question 3

Any three icons available on the taskbar

Answer

(a) Windows icon


(b) File Explorer icon
(c) Web browser icon (Microsoft Edge or Internet Explorer)

Question 4

Three types of an operating system

Answer

(a) Single user operating system


(b) Multi user operating system
(c) Multiprocessing operating system

Question 5

Three MS DOS files

Answer

(a) IO.SYS
(b) MSDOS.SYS
(c) COMMAND.COM

Case-Study Based Questions

Question 1

An operating system can be categorised into two modes. In one mode, a single user is
allowed to interact with the computer at a time. In other mode, multiple users share a single
CPU to carry out their tasks. When a number of users are using a CPU, their programs are
executed by allotting equal amount of time to each user or by providing high priority to a
specific job.

Based on the above case, answer the following questions:

(a) Name the mode in which a single user interacts with computer at a time.

(b) Name the mode in which multiple users work with single CPU.

(c) In which system, CPU time is equally shared among the users?

(d) In which system, high priority is given to a specific job?

Answer

(a) Single user operating system

(b) Multi user operating system

(c) Multi user operating system (Time sharing)

(d) Multi user operating system (Realtime processing)

Question 2

The user can interact with a computer in two ways. Either the user can interact using text
commands, or the users are linked with a computer through graphical illustrations.
Nowadays, people prefer using the later one because it is more user-friendly. The moment
you click an icon, a window will appear for you to work on.

Based on the above case, answer the following questions:

(a) Under what type of interface the user interacts with a computer using text commands?

1. GUI
2. CUI
3. Mobile interface
4. I/O interface

(b) Under what type of interface the user interacts with a computer through graphical
illustrations?

1. GUI
2. CUI
3. Pictorial interface
4. Direct interface

(c) What is meant by user-friendly system?

1. User interacts with computer using keyword "Friend".


2. User interacts with computer using text commands.
3. User interacts with computer using BASIC commands.
4. User interacts with computer by selecting options from menu list.

(d) What is meant by an Icon?

1. It is a pointer that moves on the computer screen.


2. It is the scroll button of optical mouse.
3. A person with outstanding performance.
4. It is the picture component of the desktop.

Answer

(a) CUI

(b) GUI

(c) User interacts with computer by selecting options from menu list.

(d) It is the picture component of the desktop.

Define the following terms

Question 1

Booting

Answer

The startup process, initiated by loading of an operating system in the Random Access
Memory (RAM), is known as booting. It is one of the most important tasks of the operating
system to keep the computer ready for the user's applications. The booting starts the moment
computer is switched on.

Question 2

Multiprogramming

Answer

It is the ability of the operating system to run more than one program at a time on a single
CPU computer. In multiprogramming, the computer handles many programs simultaneously.
Whenever the processor is idle during the execution of one process, it starts the execution of
another program immediately.

Question 3

Windows
Answer

Microsoft Windows is a Graphical User Interface (GUI) based operating system. Since in
windows, the user interacts with computer using menus, it is also known as menu-based
operating system. It manages the entire configuration of a computer system. This operating
system allows the running of multiple applications.

Question 4

Desktop

Answer

Desktop is one of the basic components of the Graphical User Interface (GUI) screen. It is the
display screen which shows icons that are frequently used or provided for our quick access.
The user navigates through these icons and access various applications. However, it can be
personalised as per our choice.

Question 5

Application Window

Answer

When the user opens any application package or program such as MS Word, MS Excel, MS
PowerPoint, etc. the window which appears on the screen is called an application window. It
is the primary window of an application that allows the user to communicate with the
application program.

Differentiate between the following

Question 1

Cold Booting and Warm Booting

Answer

Cold Booting Warm Booting

Cold Booting refers to the startup procedure of a When the computer needs to restart under
computer. This booting process starts right from software control without switching off the
the moment the computer is switched on. power, it is known as Warm Booting.

During cold boot, peripherals check is During warm boot, peripherals check is
performed. skipped.

Cold boot takes more time than warm boot. Warm boot is faster than cold boot.
Cold Booting Warm Booting

Question 2

CUI and GUI

Answer

CUI GUI

It stands for Character User Interface. It stands for Graphical User Interface.

The user performs tasks with the help of In this interface, other than keyboard, mouse or
keyboard only by typing text commands. any other pointing device can also be used.

The user has to memorise and type the The user performs tasks by selecting and clicking
commands to perform each task. the options available.

Its usage is difficult and may require


It is comparatively easier than CUI in its usage.
expertise.

MS-DOS is an example of CUI. Windows is an example of GUI.

Question 3

Single User Operating System and Multiuser Operating System

Answer

Single User Operating System Multiuser Operating System

Single User Operating System provides a platform Multiuser Operating System provides
for one user at a time. platform for multiple users at a time.

Single User Operating System may be a single user,


Multiuser Operating System may be
single task or a single user, multitasking operating
time sharing or multiprocessor system.
system.

Single User Operating System is suitable for personal Multiuser Operating System is suitable
Single User Operating System Multiuser Operating System

computers. for servers and mainframes.

For example, MS DOS. For example, LINUX.

Answer the following questions

Question 1

What is an operating system? Give an example.

Answer

An operating system is an integrated set of programs that manages various resources and the
overall operations of a computer system. It is designed to support the various activities of the
computer system in a systematic way.

For example — Microsoft Windows, Linux, etc.

Question 2

Why do we need an operating system?

Answer

An operating system is an interface between the user and the computer. The prime objective
of the operating system is to improve the efficiency of a computer system. It is also needed
for the following tasks —

1. Ensuring the smooth functioning of the various peripherals attached.


2. Supervising the various processes and applications of the computer and enabling them
to function in an efficient manner.
3. Coordinating the different hardware and software components of a computer system.
4. Managing computer's memory.

Question 3

What are the functions of an operating system? Explain.

Answer

The functions of an operating system are as follows:

1. Loading itself in the Memory — The operating system has a specific feature to load
itself in the memory and manage CPU to execute itself on its own. This process is
known as booting.
2. Processor Management — The management of a CPU by an OS is known as
processor management.
3. Memory Management — Memory management refers to the process of allocating
memory to a program and de-allocating it when it is no longer required.
4. Managing Input/Output Devices (Device Management) — The operating system
keeps track of all the devices, enables and controls the input-output (I/O) devices
attached to a computer system.
5. File Management — The operating system creates and deletes files, allows back up
of files on storage devices, manages files and folders and provides file protection.
6. Ensuring Data Security — It keeps different programs and data in such a way that
they don't interfere with each other.
7. Detecting and Correcting Errors — If the supporting hardware or software does not
work properly, then the operating system tries to rectify it and also guides the user to
take the necessary steps.
8. Loading Application programs in memory — Operating system loads various
application programs required by the user and then runs them.

Question 4

Enlist three features of MS DOS as a Character User Interface.

Answer

Three features of MS DOS as a Character User Interface are as follows:

1. In MS DOS, the user and the computer interact with each other using text commands.
2. Keyboard is used to enter input and monitor to view output. It does not display
graphics or images and does not support pointing devices like mouse.
3. The moment computer is ready to accept the user's request, a prompt will appear on
the screen where one can type the command to carry out the necessary operations.

Question 5

What is meant by multitasking? Give an example.

Answer

Multitasking refers to operating a number of tasks simultaneously. Single user, multitasking


OS allows a single user to perform multiple tasks at a time. For example, a user can listen to
songs while writing a word document simultaneously.

Question 6

What are the advantages of 'Windows' as an operating system?

Answer

The advantages of 'Windows' as an operating system are as follows:


1. It is comparatively easier to use.
2. We don't need any specialized computer education or training to use Windows.
3. Wide support for games. Almost all games run on Windows.
4. It can run on most of the processors.
5. The collection of software programs, utilities and games is relatively much larger for
Windows.

Question 7

Distinguish between an Application Window and an Active Window.

Answer

Application Window Active Window

The Windows of any application package


The window on which a user is currently working
like MS Word, MS Excel, etc. is called an
is referred to as the active window.
application window.

It is the primary window of an application At a time, several windows of various applications


that allows the user to communicate with can be opened but only one window on which the
the application program. user works can be the active window.

Question 8

What are the main features of Multiuser operating system?

Answer

The main features of Multiuser operating system are as follows:

1. A multiuser operating system allows many different users to use computer's resources
simultaneously.
2. Each user can work on different set of programs and data. In such an environment,
programs and data of more than one user are loaded into the memory and processed
by the operating system.
3. There is a central computer (CPU) that acts as a server and all the other computers are
connected to the server with the help of terminals.
4. Each user has sufficient and separate resources, so that a problem with one user does
not affect the entire community of users.
5. Multiuser operating systems run and manage all users' requests simultaneously,
ensuring that they do not interfere with each other.

Chpt 2
Choose the correct option

Question 1

In what way a cell is addressed in a worksheet?

1. Using column name followed by row number.


2. Using row number followed by column name.
3. By scrolling up and down.
4. By calculating the distance from reference cell.

Answer

Using column name followed by row number.

Reason — The address of a cell consists of the column letter followed by the row number.

Question 2

In which position, the sheet tab is located on the screen?

1. At the top left corner


2. At the top right corner
3. At the bottom right corner
4. At the bottom left corner

Answer

At the bottom left corner

Reason — The sheet tab is located at the bottom left corner on the screen.

Question 3

In what way a worksheet can be erased?

1. By right clicking the sheet name and selecting 'delete' option from the drop-down list.
2. By right clicking the sheet name and selecting 'erase' option from the drop-down list.
3. By right clicking the sheet name and selecting 'remove' option from the drop-down
list.
4. None of the above.

Answer

By right clicking the sheet name and selecting 'delete' option from the drop-down list.

Reason — A worksheet can be erased by right clicking the sheet name and selecting 'delete'
option from the drop-down list.
Question 4

Which of the following functions is used to add the values of consecutive cells?

1. total( )
2. sum( )
3. add( )
4. None of the above

Answer

sum( )

Reason — sum( ) function calculates the sum of all the values of the specified cells.

Question 5

The max( ) function is used to find the maximum of:

1. two values
2. three values
3. any number of values
4. none of them

Answer

Any number of values

Reason — Max( ) function returns the highest value among all the values of the specified
cells or the range of cells.

Question 6

Count( ) function is used to find the

1. number of elements in a range of cells.


2. frequency of an element in a range of cells.
3. number of elements starting with a specific digit.
4. number of elements ending with a specific digit.

Answer

Number of elements in a range of cells

Reason — The count function enables a user to count the number of cells in a range that
contain numbers.

Question 7
Which of the following is not a pictorial representation of data?

1. Chart
2. Graph
3. SmartArt
4. Range of cells

Answer

Range of cells

Reason — A range of cells is a group of cells that has been selected.

Question 8

What is meant by customising a chart?

1. Sending a chart to the customer


2. Modifying a chart as per requirement
3. Receiving a chart through e-mail
4. Declaring a chart title

Answer

Modifying a chart as per requirement

Reason — Customising a chart means modifying a chart as per requirement.

State True or False

Question 1

A range of cells is a group of cells that has been selected.


True

Question 2

A spreadsheet can contain only numeric data.


False

Question 3

You can insert a chart but not a clipart in a worksheet.


False

Question 4
The cell in which the cell pointer is located in a worksheet, is referred to as the active cell.
True

Question 5

You can select a range of data as per your choice in a spreadsheet.


True

Fill in the blanks

Question 1

Charts are the pictorial representation of data values stored in the worksheet.

Question 2

When the corresponding cell address changes with reference to a new cell address, it is
known as relative reference.

Question 3

By default, MS Excel provides three worksheets in a workbook.

Question 4

The built-in formulae for specific numeric/non-numeric processing are called functions.

Question 5

A range of cells is a rectangular block consisting of a few cells, an entire row, an entire
column or the whole worksheet.

Write the format of the functions used in MS Excel to


perform the following tasks

Question 1

To calculate the average of 82, 67, 80, 74 and 95.

Answer

=AVERAGE(82,67,80,74,95)

Question 2

To find the highest value of the cell references from D3 to K3.


Answer

=MAX(D3:K3)

Question 3

To calculate the sum of the first five multiples of 7.

Answer

=SUM(7,14,21,28,35)

Question 4

To determine the lowest value of the cell references from A4 to A12.

Answer

=MIN(A4:A12)

Question 5

To find the sum of all the prime numbers from 1 to 10.

Answer

=SUM(2,3,5,7)

Question 6

To find the arithmetical mean of the cell references from E4 to K4.

Answer

=AVERAGE(E4:K4)

Spot the error in each of the following

Question 1

=SUM ('C9':C14)

Answer

=SUM(C9:C14)

Question 2

=$B*$3*C$
Answer

=$B$3 * C$4

Question 3

=COUNT(9, 12, 17, 26, A$)

Answer

=COUNT(9, 12, 17, 26)

This will give the output as 4 since there are 4 numeric values given as input to the count
function.

Question 4

=AVERAGE(A1:An)/n

Answer

=AVERAGE(A1:An)

where 'n' is the row number of the cell till where the average is required.

Question 5

=MAX('19', 70, 101)

Answer

=MAX(19,70,101)

Question 5

=ADD(24+54+77-38)

Answer

=SUM(24,54,77)-38

Case-Study Based Questions

Question 1

Given below is a table containing 'Rate/gm' and 'Wt in gm' in columns A and B respectively.
Cell D1 contains GST as 5% (i.e. 0.05). The cost (including GST) of each item is to be
calculated and stored in the corresponding cells of column C as (Rate/gm) * Wt in gm * GST.
Based on the above case, answer the following questions:

(a) Which of the following represents cell D1 as absolute?

1. $D1$
2. D$1$
3. $D$1
4. D1$

(b) What will happen when cell C1 is absolute and used in the formula to find cost in the cells
from C4 to C7?

1. All cell values from C4 to C7 will become 0 (zero).


2. The cell value D1 will be shifted into the cell C1.
3. The cell value D1 will be copied into the cell C1.
4. All the cell values from C4 to C7 will occupy same non-zero values.

(c) What will be the formula to calculate the cost in column C4?

1. A4 * B4 * D1
2. A4 * B4 * $D$1
3. A4 * $B4$ * D1
4. $A4$ * $B4$ * $d4$

(d) What will be the formula to calculate the cost in column C7?

1. $A$7 * B7 * D1
2. A7 * B7 * $D$1
3. A$7$ * B$7$ * D1
4. A7 * B7 * $D1$

Answer

(a) $D$1

Reason — We add '$' sign before a column and row to make it absolute.

(b) All cell values from C4 to C7 will become 0 (zero).

Reason — The result is zero because cell C1 is empty and as a result its numeric value will
be taken as 0.

(c) A4 * B4 * $D$1.

Reason — We add '$' sign before a column and row to make it absolute. Hence the value of
GST % in cell D1 remains the same while the cost changes according to cell C4, C5...and so
on.

Note — There is a misprint in the options. Cell D1 has been incorrectly referred to as C1.
This error has been fixed in the question here.

(d) A7 * B7 * $D$1

Reason — A7 and B7, being relative references will change while $D$1 being absolute
reference will remain the same.

Question 2

Given below is a chart which shows the comparative study of the prices of TV sets of various
companies:
On the basis of the above chart, answer the following questions:

(a) What is the type of the given chart?

(b) Name any two chart elements.

(c) Name the chart element to display the title.

(d) Which option will you select under chart element to display information along horizontal
or vertical direction?

Answer

(a) The given chart is a 2D column chart.

(b) Two chart elements are Chart Title and Axis Title.

(c) Chart Title displays the title of the chart.

(d) One will select Axis Title to display information along horizontal or vertical direction.

Explain the following functions

Question 1

=SUM(C5:H5)

Answer

This function calculates the sum of the cell references from C5 to H5.

Question 2

=AVERAGE (K12:K50)

Answer

This function calculates the average of the cell references from K12 to K50.

Question 3

=COUNT (B15:B35)

Answer

This function counts the number of cells which contain numeric values, in the range of cells
from B15 to B35.

Question 4

=MAX (A4:A14)
Answer

This function finds the highest value among the cell references from A4 to A14.

Explain the three types of referencing

Question 1

Relative Referencing

Answer

In Relative Referencing, when the formula is copied to a new cell, the corresponding cell
address changes with reference to the new cell address.

For example, consider the formula '=SUM(A1:A5)' in A6 for calculating the total from A1 to
A5. Here the relative positions of the cells are specified. When this formula is copied to B6 or
C6, it will automatically get adjusted as below:

For B6, it will become =SUM(B1:B5)


For C6, it will become =SUM(C1:C5)

Question 2

Absolute Referencing

Answer

In Absolute Referencing, the address of the cells is specified in a way that it remains constant
when the formula is copied to a new cell. To keep the cell value absolute, apply the '$' sign
before the column name, as well as the row number.

For example, let us consider that cell C6 has the formula =A6*B6*$F$3. The formula takes
the relative cell values from A6 and B6, and the absolute value from the cell F3. When this
formula is copied to C7 or C8, it will automatically get adjusted as below:

For C7, it will become =A7*B7*$F$3


For C8, it will become =A8*B8*$F$3

Notice that the relative reference changes but the absolute reference $F$3 remains the same.

Question 3

Mixed Referencing

Answer

Mixed Referencing is a combination of relative and absolute referencing. In this reference,


the data of one cell is kept absolute and other is made relative and finally they are operated
together in a formula.
For example, let us consider that cell B5 has the formula =$B$3*B$4. When this formula is
copied to C5 and D5, it will automatically get adjusted as below:

For C5, it will become =$B$3*C$4


For D5, it will become =$B$3*D$4

Define the functions

Question 1

SUM ( )

Answer

This function calculates the total of all the values of the specified cells and returns the result
to the cell where the cell pointer is located.

Its syntax is:


=SUM(number1, number2, .......) where argument type is Number and return type is Number.

To find the sum of the cell values ranging from A1, A2, A3, ........ to An, the function will be
written as:
=SUM(A1, A2, A3, ......., An)
OR
=SUM(A1:An)

Question 2

AVERAGE ( )

Answer

This function takes all the values of the specified cells and returns the average of the cell
values in the active cell.

Its syntax is:


=AVERAGE(number1, number2, .......) where argument type is Number and return type is
Number.

To find the average of the cell values ranging from A1, A2, A3, ........ to An, the function will
be written as:
=AVERAGE(A1, A2, A3, ......., An)
OR
=AVERAGE(A1:An)

Question 3

MAX ( )

Answer
This function returns the highest value among all the values of the specified cells or the range
of cells.

Its syntax is:


=MAX(number1, number2, .......) where argument type is Number and return type is Number.

To know the highest of the cell values ranging from A1, A2, A3, ........ to An, the function
will be written as:
=MAX(A1, A2, A3, ......., An)
OR
=MAX(A1:An)

Question 4

MIN ( )

Answer

This function returns the lowest value among the values of the specified cells or the range of
cells.

Its syntax is:


=MIN(number1, number2, .......) where argument type is Number and return type is Number.

To know the lowest of the cell values ranging from A1, A2, A3, ........ to An, the function will
be written as:
=MIN(A1, A2, A3, ......., An)
OR
=MIN(A1:An)

Short Answer Questions

Question 1

What are the points to be taken care of while writing the format of a function in MS Excel?

Answer

The following points must be taken care of while writing the format of a function in MS
Excel:

1. Each function must begin with an 'equal to' (=) sign.


2. Parenthesis is used to indicate the opening and closing of a function.
3. Arguments are written within the parenthesis.
4. Commas are used to separate the arguments.

Question 2

What is meant by cell reference?


Answer

Every cell in a worksheet has a cell address, by which it is referred and when this address is
used in a formula, it is known as cell referencing.

MS Excel provides three different ways to refer to a cell-

1. Relative Referencing
2. Absolute Referencing
3. Mixed Referencing

Question 3

Define Sheet Tab.

Answer

In MS Excel, the tab which displays various worksheets in a workbook is called the 'Sheet
Tab'. It is located at the bottom left corner of the excel window. By default, the system
displays only one sheet named Sheet1.

Question 4

Explain the term 'Range of Cells' in a spreadsheet.

Answer

When more than one cells are selected in a worksheet, the selected cells are known as range
of cells. A range is specified by giving the addresses of the first cell and the last cell to be
included in the range.

Question 5

What do you understand by chart? Explain with reference to MS Excel.

Answer

A chart is a pictorial representation of data used to communicate information in a better way.


It helps in better visualisation, comparison and relationship between data.

MS Excel provides different types of charts such as column chart, line chart, pie chart, bar
chart, etc. from which the user can select as per his/her need.

Write all the steps to perform the following tasks in MS


Excel

Question 1

Naming a Worksheet
Answer

To name a worksheet, follow these steps:

Step 1 — Double-click the name of the worksheet on the sheet tab.

Step 2 — Enter the name and press 'Enter' key.

Question 2

Renaming a Worksheet

Answer

To rename a worksheet, follow these steps:

Step 1 — Double-click the name of the worksheet on the sheet tab.

Step 2 — Enter the new name and press 'Enter' key.

Question 3

Deleting a worksheet

Answer

To delete a worksheet, follow these steps:

Step 1 — Right-click on the sheet name on the Sheet Tab that you want to delete.

Step 2 — Select the 'Delete' option from the pop-up list.

Question 4

Selecting a partial range in a row

Answer

To select a partial range in a row, follow these steps:

Step 1 — Select the first cell.

Step 2 — Keeping the left mouse button pressed, drag the mouse to select the desired number
of cells in a row.

Step 3 — Release the mouse button.

Question 5

Selecting multiple columns in a worksheet

Answer
To select multiple columns in a worksheet, follow these steps:

Step 1 — Select or bring the mouse pointer to the column header of a column from where
consecutive columns are to be selected.

Step 2 — Press the left mouse button to select required number of consecutive columns.

Step 3 — Release the mouse button.

Question 6

Preparing a chart by using a sample data table

Answer

To prepare a chart by using a sample data table, follow these steps:

Step 1 — Select the range of cells whose data is to be represented.

Step 2 — Click the 'Insert' tab on the ribbon.

Step 3 — Click and select the type of chart (say, Column chart) from the 'Charts' group. A
drop-down list opens.

Step 4 — Select the desired chart (say, a 2-D Column). The data will be displayed in the
form of the chart selected.

MS Excel Task
You have purchased some textbooks from a bookstore, as given below:

Write the steps involved to perform the following tasks in MS Excel on the table given
above.

Question 1
Find the average price of the books.

Answer

To find the average price of the books, follow these steps:

Step 1 — Select the cell where you want to display the average price of the books.

Step 2 — Type the formula =AVERAGE(C3:C9) in the cell.

Step 3 — Press 'Enter' key.

The average price of the books will be calculated.

Question 2

If the bookseller offers 10% discount, then calculate the amount to be paid to the shopkeeper.

Answer

To calculate the amount to be paid to the shopkeeper, follow these steps:

Step 1 — Select cell D3.

Step 2 — Write the formula =C3-(C3*0.1) and press enter key.

Step 3 — Select cell D3 again and drag the cell handle from D3 till D9.

Step 4 — Select cell D10.

Step 5 — Write the formula =SUM(D3:D9) and press enter key.

Cell D10 shows the amount payable to the shopkeeper.

Question 3

Find the price of the book which had the highest price among the books you bought.

Answer

To find the price of the book which had the highest price among the books you bought,
follow these steps:

Step 1 — Select the cell where you want to display the result.

Step 2 — Type the formula =MAX(C3:C9) in the cell.

Step 3 — Press 'Enter' key.

The price of the most expensive book will be displayed.

Question 4
Calculate the total amount paid at the bookstore.

Answer

To calculate the total amount to be paid to the shopkeeper, follow these steps:

Step 1 — Select the cell C10.

Step 2 — Type the formula =SUM(C3:C9) in the cell.

Step 3 — Press 'Enter' key.

C10 will display the total amount to be paid to the shopkeeper.

Chpt 3
Choose the correct option

Question 1

Who invented the algorithm?

1. Charles Babbage
2. Md. Musa Al Khwarizmi
3. Blaise Pascal
4. Adelard de Bath

Answer

Md. Musa Al Khwarizmi

Reason — The origin of algorithm is attributed to the Persian astronomer and mathematician,
Abdullah Mohammad bin Musa Al Khwarizmi.

Question 2

Who among the following is the first to write algorithm used for computer operation?

1. Lady Ada Lovelace


2. Charles Babbage
3. Alan Turing
4. Adelard de Bath

Answer

Lady Ada Lovelace

Reason — Lady Ada Lovelace was the first person who created the first algorithm that could
be executed on a computer.

Question 3

Which of the following is used as the beginning step in an algorithm?

1. Get
2. Set
3. Start
4. Stop

Answer

Start

Reason — Start is used as the beginning step in an algorithm.

Question 4

Which of the following symbols is used to start a flowchart?

1. Oval
2. Terminal
3. Connect
4. Rhombus

Answer

Terminal

Reason — A terminal box with the word 'START' is used at the beginning of the flowchart.

Question 5

Which of the following boxes is used for displaying an output statement?

1. Rectangular box
2. Rhombus box
3. Parallelogram box
4. Oval box
Answer

Parallelogram box

Reason — The output statement is represented by a parallelogram.

Fill in the blanks

Question 1

The first symbol in a flowchart is the START symbol.

Question 2

A flowchart is a pictorial representation of a sequence of instructions that are required to


solve a problem.

Question 3

Flow lines are used to connect different boxes.

Question 4

The Decision Box is used for making decisions as well as comparisons.

Question 5

All mathematical operations are put in a Process box.

Write the names & the symbols

Question 1

Write the names and the symbols of the boxes for the given statements

Statement Name of the Box Symbol

To assign a number

To display the result

To start the process

To decide if a number is smaller than the other


Answer

Statement Name of the Box Symbol

To assign a number Process Box

To display the result Input / Output Box

To start the process Start Box

To decide if a number is smaller than the other Decision Box

Complete the following flowcharts

Question 1

A flowchart to check whether a triangle is possible or not.

Answer
Question 2

A flowchart to display the greater of the two numbers.

Answer
Case-Study Based Questions

Question 1

As a homework assignment, your teacher has given a flowchart (shown below) to find and
display the square and cube of a positive number. The execution must be terminated, if a
negative number is entered.
The above flowchart has some errors which are indicated with (1), (2), (3) and (4). Answer
the following questions to give the correct result.

(a) What will be the correct representation of the box in (1)?

(b) What will be the correct logic for the variable N in (2)?

(c) Out of the flow lines (3) and (4), which one is undesirable?
(d) When all the corrections are made, what will be the output, if the input value is taken as
12?

Answer

(a) The correct representation of the box in (1) is a parallelogram or input/output box.

(b) The logic for the variable N in (2) will be - If N>0?

(c) Flow line (4) is undesirable.

(d) The output will be 144, 1728.

The corrected flowchart is shown below:


Question 2

Anuj, a class 9 student, has designed the following flowchart to input a positive number and
check and display whether the number is a single digit number, a double digit number or a
triple digit number. To assess his brother who is in class 8, he hides four statements in the
flowchart.
Based on the above case and the given flowchart, answer the following questions:

(a) Which of the following statements will be filled in place of (A)?

1. Display Single digit number


2. Display Double digit number
3. Display Negative number
4. Display odd number

(b) Identify (B) from the following:


1. N >= 100
2. N <= 100
3. N < 100
4. N > 100

(c) Which of the following statements will be filled in place of (C)?

1. Display Single digit number


2. Display Double digit number
3. Display Negative number
4. Display odd number

(d) Identify (D) from the following:

1. Start
2. End
3. Finish
4. Stop

Answer

(a) Display Single digit number

(b) N < 100

(c) Display Double digit number

(d) Stop

The complete flowchart is shown below:


Write algorithms for the following

Question 1

To go for a class picnic

Answer

Step 1: Start
Step 2: Decide the picnic venue, date and time
Step 3: Decide the picnic activities
Step 4: Hire a vehicle to reach to the venue and comeback
Step 5: Go to the picnic venue on the decided date
Step 6: Do the activities planned for the picnic
Step 7: Come back to school in the hired vehicle
Step 8: Stop

Question 2

To celebrate New Year

Answer

Step 1: Start
Step 2: Prepare a guest list for New Year party
Step 3: Decide the venue, food menu, games and fun activities for the party
Step 4: Invite the guests for the party
Step 5: On New Year eve, get ready and enjoy the party
Step 6: Stop

Question 3

To make tea/coffee

Answer

Step 1: Start
Step 2: Boil water in a saucepan
Step 3: Add tea to boiling water
Step 4: Add sugar to boiling water
Step 5: Add milk to boiling water
Step 6: Boil this water with all the ingredients for 2 mins
Step 7: Sieve the tea in a cup
Step 8: Stop

Question 4

To celebrate Teachers' Day

Answer

Step 1: Start
Step 2: Decide the activities for teachers' day like dance performances, plays, etc
Step 3: Form groups of students and assign the decided activities from step 2 to each group
Step 4: Decide the practice timings for each group
Step 5: Each group to practice as per the timings decided in step 4
Step 6: Invite the teachers to Teachers' Day celebrations
Step 7: Perform the activities planned in step 2 on Teachers' Day
Step 8: Stop
Answer the following questions

Question 1

What is a flowchart? What are the features of a flowchart?

Answer

A flowchart is a pictorial representation of various steps involved in a process. It is used to


depict flow of an algorithm. It is constructed with the help of boxes and arrows (flow lines).
As a flowchart depicts the flow of operations, any error in logic can be easily detected.

The features of a flowchart are as follows:

1. It is an easy method of communication.


2. It is independent of any programming language.
3. It is the key to correct and accurate programming.
4. It helps to plan and design a new system.
5. It clearly indicates the task to be performed at each level.

Question 2

What is an algorithm? What are its characteristics?

Answer

An algorithm is defined as a sequence of instructions written in a step by step manner to get


the desired results. It helps to develop the fundamental logic of a problem and is an effective
method to solve different problems.

Some characteristics of an algorithm are as follows:

1. Each step of an algorithm must be precisely defined.


2. An algorithm must contain blocks that will help to solve problems more efficiently
and logically.
3. It should accept a set of inputs and produce a defined output.
4. It must terminate after a finite number of steps.
5. It should be independent of any computer programming language.

Question 3

Define the following and draw their symbols:

(a) Process Box

Answer
A process box is used to represent all types of mathematical operations and assignment of
values. It is rectangular in shape. Thus, arithmetic operations like addition, subtraction,
multiplication and division can be shown in this box.

(b) Terminal Box

Answer

This box is used to indicate the beginning (START) and the end (STOP) of a process. It is an
oval or a rounded rectangle. A terminal box with the word 'START' is used at the beginning
of the flowchart and a box with the word 'STOP' is used at the end of the flowchart.

(c) Input/Output Box

Answer

These boxes are used to represent the input/output operations of a process. The I/O box is
represented by a parallelogram. All the commands required to be taken or given are put into
these boxes. Thus, statements like INPUT, PRINT etc., are used in these boxes.

(d) Decision Box

Answer

The decision box is used to represent the statements which can either result in a True/False
(Yes/No) condition. It is in a shape of a diamond or a rhombus. If the statement results in
True (Yes) then the statements following the 'true' condition are implemented, otherwise the
statements following the 'false' condition are implemented.
Write algorithms & draw flowcharts

Question 1

Accept the length of two different line segments and check whether they are equal or
unequal. Display the message accordingly.

Algorithm

Step 1: Start
Step 2: Accept the length of the two line segments as l1 and l2.
Step 3: If l1 and l2 are equal, then display 'Line Segments are equal'.
Step 4: If l1 and l2 are not equal, then display 'Line Segments are not equal'.
Step 5: Stop

Flowchart
Question 2

Accept the age of a person and check whether he/she is eligible to vote or not. A person is
eligible to vote only when he/she is 18 years or more.

Algorithm
Step 1: Start
Step 2: Accept the age of the person.
Step 3: If age is greater than or equal to 18, then display 'You are eligible to vote'.
Step 4: If age is less than 18, then display 'You are not eligible to vote'.
Step 5: Stop

Flowchart
Question 3

Accept three numbers and check whether they are 'Pythagorean Triplets' or not. Display the
message accordingly.
(Hint: Use Pythagoras Formula for a Right-angled Triangle: h = p2+b2)

Algorithm

Step 1: Start
Step 2: Take 3 numbers as input (Say A,B,C)
Step 3: If A2 = B2 + C2, display 'Pythagorean Triplets'
Step 4: If B2 = A2 + C2, display 'Pythagorean Triplets'
Step 5: If C2 = A2 + B2, display 'Pythagorean Triplets'
Step 6: If no condition of Step 3,4,5 match, display 'Not Pythagorean Triplets'
Step 7: Stop

Flowchart
Draw flowcharts for the following

Question 1

In a cricket match, a viewer carries a laptop in the stadium every day to keep record of the
runs made by each batsman. When a player comes to bat, the viewer enters the previous runs
made by the player. Further, he enters the runs scored for each ball. When the runs entered on
a ball is -1, it means the player is out. The laptop then displays the runs made by the player in
the current innings as well as the total. The process continues until all the players are out.
Draw a flowchart for the task stated above.

Flowchart
Question 2

Accept a number and check:

(a) whether the number is divisible by 2 and 5.

(b) whether the number is divisible by 2 but not by 5.

(c) whether the number is divisible by 5 but not by 2.

Display the message accordingly.

Flowchart
Question 3

Input three angles of a triangle and check whether a triangle is possible or not. If possible,
then check whether it is an 'Acute-angled Triangle', 'Obtuse-angled Triangle' or a 'Right-
angled Triangle'.

Flowchart
Question 4

Accept the name and marks obtained by a student in Computer Project. Display the grades as
per the table given below:

Marks obtained Grade

80% or more A

60% or more but less than 80% B

40% or more but less than 60% C

Less than 40% No Grade

Flowchart
Question 5

Input the quantity purchased and the rate. Calculate the total purchase price and display it
along with the gift to be presented. The gifts to the customers are given as under:

Amount of Purchase (in ₹) Gift

100 and above but less than 500 A key ring

500 and above but less than 1000 A leather purse

1000 and above A pocket calculator

The flowchart will end with a 'Thank you' message.

Flowchart
Question 6

A librarian charges a fine for books, if returned late. The tariff for the fine is given below:

No. of days Fine

For the first ten days 40 paise per day

Eleven to twenty days 60 paise per day

More than twenty days 80 paise per day

Draw a flowchart to calculate the fine assuming that a book is returned 'N' days late.

Flowchart
Chpt4
Choose the correct option

Question 1

Character literal is assigned to a:

1. char variable
2. char type literal
3. string variable
4. string literal

Answer

char variable

Reason — A character literal represents a single character enclosed in single quotes (' ') and
it is assigned to char type variable.

Question 2

A character literal is enclosed in:

1. ''
2. ""
3. ::
4. {}

Answer

''

Reason — A character literal represents a single character enclosed in single quotes (' ').

Question 3

A set of characters is assigned to a:

1. String variable
2. Static variable
3. Char variable
4. None

Answer

String variable
Reason — A string data type represents a set of characters enclosed within double quotes. A
set of characters is assigned to a String variable.

Question 4

The statement n += 4 is equivalent to:

1. ++n
2. n=n+4
3. n+1
4. None

Answer

n=n+4

Reason — Here, += is a Shorthand operator. It can be used to write a Java expression into
short form provided same variables are used after and before the assignment sign (=).

Question 5

What will be the output of a++, if int a= -1;?

1. 1
2. -1
3. 0
4. none

Answer

-1

Reason — a++ uses an increment postfix operator which works on the principle- 'Action then
change'. Hence, first the value of a is printed and then it is incremented.

Question 6

If int a=25, b=5, c=0; what value is stored in c when c = a%b?

1. 5.0
2. 5
3. 0
4. none

Answer

0
Reason — The expression uses mod operator (%) which returns the remainder after the
operation. Here c = 25 % 5 which results in 0 as when 25 is divided by 5, we get the quotient
as 5 and remainder as 0.

Question 7

What will be the result of m in the expression m*=8 if m=8; ?

1. 8
2. 64
3. 16
4. 88

Answer

64

Reason — m*=8 is equivalent to m=m*8 ⇒ m = 8 * 8 = 64.

Question 8

double c;
int x,y,z;
x=5; y=10; z=11;
c=x*y+z/2;
The value stored in c is:

1. 55.0
2. 55.5
3. 55
4. none

Answer

55.0

Reason — Putting the values of variables in the expression:


c=x*y+z/2
c = 5 * 10 + 11 / 2
c = 50 + 5
c = 55.0 [∵ c is of double type, hence its value will be 55.0 not 55]

Question 9

int m,p; m=5; p=0; p= m-- + --m; The output will be:

1. 11
2. 10
3. 8
4. 12

Answer

Reason — Putting the values of variables in the expression:

Expression Explanation

p = m-- + --m This is the given expression. Initial value of m is 5.

At this step, current value of m (which is 5) is used in the expression and then value of
p = 5 + --m
m is decremented to 4. Current value of m becomes 4 after this step.

--m first decrements the current value of m (which is 4) by 1 so m becomes 3. After


p=5+3
that, this decremented value of 3 is used in the expression.

p=8 This is the final result of the expression.

Question 10

int a=7, p=0, q=0;


p= ++a + --a;
q-=p;

The output of q will be:

1. 13
2. 14
3. 15
4. -15

Answer

-15

Reason — Evaluating the given expressions:

Expression Explanation

p = ++a + --a This is the first expression. Initial value of a is 7 and p is 0.

p = 8 + --a At this step, ++a first increments a by 1 so it becomes 8, then this incremented value is
Expression Explanation

used in the expression.

At this step, current value of a (which is 8) is decremented by 1 and this decremented


p = 8 + 7 = 15
value of 7 is used in the expression.

q-=p
⇒q=q-p
Shorthand operator -= subtracts p from q and assigns the result back to q.
⇒ q = 0 - 15
⇒ q = -15

Question 11

What will be the output of 'a' and 'b' in the expression b = a++, if int a, b; a=10?

1. 10,10
2. 10,11
3. 11,10
4. 11,11

Answer

11,10

Reason — The given expression will result in b=10 and a=11 as the postfix operator will first
use the value and then increment it. So, the output of a and b will be 11, 10.

State True or False

Question 1

Java is known as an Object-Oriented Programming (OOP) language.


True

Question 2

The comment line of the program is ignored during execution.


True

Question 3

The data type must be same as the value assigned to the variable.
True
Question 4

An integer value can be assigned to a double type variable.


True

Question 5

The letters 'ln' in the statement System.out.println() directs the cursor to move to the next line
after displaying the value.
True

Question 6

The variables used in Java program are called reserved words.


False

Question 7

Literals remain unchanged throughout the execution of a program.


True

Question 8

When an increment or decrement operator is used before the operand, it is known as the
postfix operator.
False

Write the Java expressions for the following

Question 1

ab + bc + ca

Answer

a*b+b*c+c*a

Question 2

a2 + ab - b2

Answer

a*a+a*b-b*b

Question 3

ut + 1/2at2
Answer

u * t + (1.0 / 2) * a * t * t

Question 4

(a+b)3

Answer

(a + b) * (a + b) * (a + b)

Question 5

2(lb + bh + lh)

Answer

2 * (l * b + b * h + l * h)

Question 6

a2 + b2

Answer

a*a+b*b

Predict the output

Question 1

If m = 5 and n = 2, predict the output values of m and n, when:

(a) m -= n;

(b) n = m + m/n;

Answer

(a) m -= n;

Output

m = 3
n = 2
Explanation

m -= n
⇒m=m-n
⇒m=5-2
⇒m=3
Value of n is unchanged so it is 2.

(b) n = m + m/n;

Output

m = 5
n = 7

Explanation

n = m + m/n;
⇒ n = 5 + 5/2;
⇒ n = 5 + 2; [∵ 5/2 is integer division so result is 2]
⇒n=7
Value of m is unchanged so it is 5.

Question 2

What will be the output of the variable 'a'?

int a=0, b=10, c=40;


a= --b + (c++) + b;

Answer

Output

a = 58

Explanation

a = --b + c++ + b
⇒ a = 9 + 40 + 9
⇒ a = 58

Question 3

What will be the output of the following, if x = 5 initially?

(a) 5 * ++x;

(b) 5 * x++;
Answer

(a) 5* ++x;

Output

30

Explanation

5* ++x
⇒ 5* 6 [∵ ++x will first increment x to 6 and then use it in the expression]
⇒ 30

(b) 5* x++;

Output

25

Explanation

5* x++
⇒ 5* 5 [∵ x++ will first use the current value of x in the expression which is 5. After that
x is incremented to 6]
⇒ 25

Question 4

Evaluate the following expressions:

If the values of the variables are a = 2, b = 3, and c = 9.

(a) a - (b++) * (--c);

(b) a * (++b) % c;

Answer

(a) a - (b++) * (--c);

Output

-22

Explanation

a - (b++) * (--c)
⇒2-3*8 [∵ b++ uses current value of b in expression and then increments it, --c
decrements c to 8 and then uses this 8 in the expression]
⇒ 2 - 24
⇒ -22

(b) a * (++b) % c;

Output

Explanation

a * (++b) % c
⇒2*4%9 [∵ ++b increments b to 4 then uses it in the expression]
⇒8%9
⇒8

Question 5

If a = 5, b = 9, calculate the value of a in the following expression:


a += (a ++) - (++ b) + a

Answer

Output

Explanation

a += a++ - ++b + a
⇒ a = a + (a++ - ++b + a)
⇒ a = 5 + (5 - 10 + 6) [∵ a++ will first use current value of a then increment it to 6. ++b will
increment b to 10 and use the incremented value. As a++ incremented a to 6 so the value of
last a in the expression is 6]
⇒a=5+1
⇒a=6

Case-Study Based Question

Question 1

The logical operators are used in between two conditions, which results in either 'True' or
'False' depending on the outcome of different conditions. Java uses three logical operators
viz. AND, OR and NOT. Your friend has created a Java snippet that contains some errors due
to which he is not able to execute it.

The program snippet created by him is as shown below:

int p=11, q=12, r=15;


(a) System.out.println ((p==q) AND (q!=r));

(b) System.out.println(!(p=q));

(c) System.out.println (p!==q);

(d) System.out.println ((p!=q) OR (q!=r));

Refer to the above snippet and help him by detecting the errors so that the snippet may
execute successfully.

Answer

(a) System.out.println ((p==q)&&(q!=r));

The symbol of AND operator (&&) should be used in the expression.

(b) System.out.println(!(p==q));

'=' is an assignment operator. Using it in the expression p=q will assign the value of q to p.
We use equality operator '==' to compare the values.

(c) System.out.println (p!=q);

The not equal operator is written incorrectly. The correct not equal operator is !=.

(d) System.out.println((p!=q) || (q!=r));

The symbol of OR operator (||) should be used in the expression.

Answer the following questions

Question 1

Define a program.

Answer

A program is defined as a set of instructions or commands in a specific programming


language that instructs the computer to perform a specific task.

Question 2

What are the characteristics of a program? Name them.

Answer

The characteristics of a program are as follows:

1. Portable
2. User-friendly
3. Concise
4. Usable
5. Flexible

Question 3

Who developed Java?

Answer

James A. Gosling developed Java programming language in 1991.

Question 4

Java is case sensitive. Explain.

Answer

Java is case sensitive. It means that as a programming language, the uppercase and lowercase
letters are distinguished by the language and treated differently.

Question 5

Mention at least four features of Java.

Answer

The four features of Java are as follows:

1. Java programs are both compiled and interpreted.


2. Java programs are platform independent.
3. Java is based on the concepts of objects. Hence, it is also known as object-oriented
programming (OOP) language.
4. Java is case sensitive. As a programming language, the uppercase and lowercase letters are
distinguished by the language.

Question 6

What is meant by Java keywords? Explain.

Answer

Java keywords or reserved words are the words which carry a special meaning for the system
compiler. These words are basically used for writing a Java statement in the program. Such
words cannot be used for naming a variable in the program.

Some keywords are case, switch, int, float etc.

Question 7
How are data types classified?

Answer

The Data Types in Java are classified as below:

Question 8

Define the following:

(a) Variable

(b) Floating literal

(c) String literal

(d) Character literal

Answer

(a) Variable — A variable is a named memory location which stores a value. The value of a
variable can change depending upon the circumstances and problems in a program.
For example, add, emp_name, etc.

(b) Floating literal — Floating literal or Real literal are the fractional numbers. They are also
called floating-point constants because the placement of decimal point can be after any digit
of the numbers. For example, 24.6, -42.514, 0.0072, etc.

(c) String literal — A string is a set of alphanumeric characters. It may be a word, a sentence
or a paragraph enclosed in double quotes (" ").
For example, "Understanding Computer Studies", "Year 2021", "10% per annum", etc.
(d) Character literal — All letters in uppercase or lowercase, digits and special symbols can
be termed as character literals. A character literal represents a single character enclosed in
single quotes (' ').
For example, 'I', 'd', '3', '*', etc.

Question 9

Write down the data type of the following:

(a) Integer

(b) Long Integer

(c) A character

(d) A fractional number

Answer

(a) int

(b) long

(c) char

(d) float/double

Question 10

What is an operator? Name the different types of operators.

Answer

An operator is basically a symbol or a token which performs arithmetical, logical or relational


operations to give meaningful results. The values which are involved in the operation, are
termed as operands.

The three types of operators are as follows:

1. Arithmetical Operators — They are further divided as follows:


i. Unary Arithmetical Operators — This operator is further categorised in two ways:
a. Unary plus (+) and Unary minus (-) Operators
b. Unary Increment (++) and Decrement(--) Operators — They can be used as
prefix operators or postfix operators.
ii. Binary Arithmetical Operators — For example, +, -, *, / etc.
2. Relational Operators — For example, <, >, <>, != etc.
3. Logical Operators — Logical operators are !(NOT), &&(AND) and ||(OR).

Question 11

State the difference between = and ==.


Answer

= ==

It is the assignment operator used for It is the equality operator used to check if a variable is
assigning a value to a variable. equal to another variable or literal.

E.g. int a = 10; assigns 10 to variable a. E.g. if (a == 10) checks if variable a is equal to 10 or not.

Question 12

What is meant by a constant? Explain with an example.

Answer

Constants or literals are the constant values used in a Java program. While writing a program,
you can use some values which remain fixed throughout the execution of the program. Such
values are called literals or constants.

For example, consider the statement x = x + 20;


In this statement, 20 is a constant as 20 remains the same throughout the execution of the
program.

Question 13

What are the rules to be followed while naming a variable in Java programming?

Answer

The rules to be followed while naming a variable in Java programming are as follows:

1. A variable may have any number of characters.


2. It may contain letters, digits and a underscore.
3. It must not start with a digit or special character.
4. It must not contain spaces, punctuation marks or any symbol.
5. The underscore can be inserted in between the characters to separate the words, in case a
variable includes multiple words.
6. Variable name should be meaningful which specifies what it represents.

Question 14

Distinguish between the following:

(a) Source code and Object code

(b) Compiler and Interpreter


Answer

(a) The differences between source code and object code are as follows:

Source code Object code

Source code is a set of statements in a High-Level Object code is a set of statements in


programming language. Machine Language.

Object code is understood by the


Source code is understood by human/programmer.
processor.

Source code is not machine specific. It is machine specific.

(b) The differences between compiler and interpreter are as follows:

Compiler Interpreter

It converts the entire source program into It converts the source program into the object program,
the object program at once. one line at a time.

It displays errors for the whole program It displays the errors, one line at a time, and only after
together after compilation. correction, the control goes to the next line.

Question 15

Explain the following:

(a) Arithmetical operator

(b) Relational operator

(c) Logical operator

(d) Arithmetic expression

Answer

(a) Arithmetical operator — Arithmetical operators are used to perform mathematical


operations on its operands. These calculations may include addition, subtraction,
multiplication, division and modulus. Operands of arithmetic operators must be of numeric
type. We can apply arithmetical operators like +, -, *, / and % respectively to carry out these
calculations.
As an example consider the below statement:
int a = 10 + 20;
Here, the addition arithmetic operator, represented by the symbol + will add 10 and 20. So
variable a will be 30.
Arithmetical operators can be categorised as follows:

1. Unary Arithmetical Operators — This operator is further categorised in two ways:


i. Unary plus (+) and Unary minus (-) Operators
ii. Unary Increment (++) and Decrement(--) Operators — They can be used as prefix
operators or postfix operators.
2. Binary Arithmetical Operators — For example, +, -, *, / etc.

(b) Relational operator — Relational operators are used to determine the relationship
between the operands. Relational operators compare their operands to check if the operands
are equal to ( == ), not equal to ( != ), less than ( < ), less than equal to ( <= ), greater than
( > ), greater than equal to ( >= ) each other. The result of an operation involving relation
operators is a boolean value — true or false.
Example:
int a = 8;
int b = 10;
boolean c = a < b;
Here, as a is less than b so the result of a < b is true. Hence, boolean
variable c becomes true.
(c) Logical operator — These operators are used in between two conditions and results in
either 'True' or 'False' depending on the outcome of different conditions. Java uses logical
operators AND (&&), OR (||) or NOT (!).
For example, if a=10, b=8, c=20; then, the result of (a>b)&&(c>b) will result in true as both
the conditions are true.

(d) Arithmetic expression — An Arithmetic expression is an expression that contains


variables, constants and arithmetical operators together to produce meaningful results.
For example, a + b * c - d is an arithmetic expression with variables a, b, c and d being of
numeric type.

Question 16

Differentiate between the following:

(a) Arithmetical and Logical operator

(b) Logical AND (&&) and Logical OR (||)

(c) Prefix and Postfix operator

Answer

(a) Arithmetical and Logical operator

Arithmetical Operator Logical Operator

Arithmetic operators are used to Logical operators operate on boolean expressions to combine
perform mathematical operations. the results of these boolean expression into a single boolean
Arithmetical Operator Logical Operator

value.

+, -, *, /, etc. are a few examples of


&&, ||, ! are a few examples of Logical Operators
Arithmetic operators.

(b) Logical AND (&&) and Logical OR (||)

Logical AND (&&) Logical OR (||)

The AND operator results in true, if both the The OR operator results in true, if either of the two
conditional expressions are true. conditions is true, otherwise it will result in false.

For example, if a=8, b=13; the expression ((a > For example, if a=8, b=13; the expression ((a > 10) || (b
10) && (b > 10)) will result in false. > 10)) will result in true.

(c) Prefix and Postfix operator

Prefix operator Postfix operator

When an increment or decrement operator is When an increment or decrement operator is used


used before the operand, it is known as prefix after the operand, it is known as the postfix
operator. operator.

Prefix operator works on the principle of 'Change Postfix operator works on the principle of 'Change
before the action'. after the action'.

The value of a variable will change before the The operand will be affected after performing the
operation takes place. operation.

Example:
Example: int a = 99;
int a = 99; int b = a++;
int b = ++a; After the execution of these two statements, a will
After the execution of these two statements, both have the value of 100 and b will have the value of
a and b will have the value of 100. 99.

Chpt 4 unit2
Choose the correct option

Question 1

Which of the following is a valid comment in Java language?

1. /*comment*//
2. /* comment
3. //comment
4. */ comment */

Answer

//comment

Reason — In Java, the comment statements are written using double slash (//).

Question 2

Which of the following is used to enclose a set of statements to form a compound statement
in Java program?

1. Parenthesis
2. Brackets
3. Curly brackets
4. All of them

Answer

Curly brackets

Reason — A set of two or more statements placed within curly brackets and executed
together is called compound statement.

Note — Here, there is a misprint in part (3). Curly bracket has been misprinted as square
brackets.

Question 3

Which of the following operators is essentially required while writing if statement?

1. Arithmetic
2. Relational
3. Bitwise
4. All of them

Answer
Relational

Reason — In if statement, to test whether a condition is true or not, Relational operators are
used.

Question 4

Due to which of the following errors, a program does not provide correct result although it
has no grammatical mistake?

1. Logical
2. Syntax
3. Type mismatch
4. None of the above

Answer

Logical

Reason — Logical error occurs when the logic is incorrect. Thus, the program does not
produce the desired result although it is syntactically correct and compiles and executes fine.

Question 5

A Java statement is given as:


if((a!=b)&&(a==c))

Which of the following statements is true?

1. b is the smallest number


2. b is the greatest number
3. a is the smallest number
4. Both (a) and (b)

Answer

Both (a) and (b)

Reason — The if condition checks that a and b are unequal and a and c are equal. Both these
conditions should be true then only if statement will execute. If a and b are unequal and a and
c are equal then b will either be the smallest number or the greatest number.

Question 6

Which of the following logical operators results in true when all the connecting conditions
are true?

1. !
2. ||
3. &&
4. !=

Answer

&&

Reason — Logical AND results in true when all the connecting conditions are true.

State True or False

Question 1

Java programs can be compiled and executed on BlueJ platform.


True

Question 2

In assignment, the data values are readily available in Java program.


True

Question 3

The control skips some lines in a normal flow of control.


False

Question 4

In a decision making program, 'if' checks whether the condition is true or false.
True

Question 5

You can't assign data values in the main( ) function.


False

Question 6

In an if-else statement, the condition is to be defined only with if and not with else.
True

Predict the output of the given snippets, when executed

Question 1

int x = 1,y = 1;
if(n>0)
{
x=x+1;
y=y+1;
}
What will be the value of x and y, if n assumes a value (i) 1 (ii) 0?

Answer

Output

(i) When n is 1:
x is 2 and y is 2

(ii) When n is 0:
x is 1 and y is 1

Explanation

When n is 1, if (n>0) is true. So the statements x=x+1; and y=y+1; are executed making the
values of x and y as 2.
When n is 0, if (n>0) is false. Statements x=x+1; and y=y+1; are not executed so values of x
and y remain 1.

Question 2

int b=3,k,r;
float a=15.15,c=0;
if(k==1)
{
r=(int)a/b;
System.out.println(r);
}
else
{
c=a/b;
System.out.println(c);
}

Output

Syntax Error

Explanation

There are 2 syntax errors in this program:

1. Variable k is not initialized with any value before using it in the if check.
2. The statement float a=15.15 has a syntax error. We are trying to assign a double literal
to a float variable. The correct statement will be float a=15.15f.
Correct the errors in the given programs

Question 1

class public
{
public static void main(String args{})
{
int a=45,b=70,c=65.45;
sum=a+b;
diff=c-b;
System.out.println(sum,diff);
}
}
Answer

Errors in the snippet

1. Name of the class can't be public as public is a keyword.


2. Argument of main function should be an array of Strings.
3. We cannot assign 65.45 to c as c is an int variable and 65.45 is a floating-point literal.
4. Variable sum is not defined.
5. Variable diff is not defined.
6. println method takes a single argument.

Corrected Program

class A //1st correction


{
public static void main(String args[]) //2nd correction
{
int a=45,b=70;
double c=65.45; //3rd correction
int sum=a+b; //4th correction
double diff=c-b; //5th correction
System.out.println(sum + " " + diff); //6th correction
}
}

Question 2

class Simplify
{
public static void main(String args[])
{
int a,b,c,d;
a=10,b=5,c=1;
c=2a+2b;
d=(a+b)2;
p=c/d;
System.out.println(c , d , p);
}
}

Answer

Errors in the snippet

1. Multiple variable assignment statements cannot be separated by a comma. Semicolon


should be used instead.
2. The line c=2a+2b needs an operator between 2 and a, 2 and b.
3. The line d=(a+b)2 needs an operator between (a+b) and 2.
4. Variable p is not defined.
5. println method takes a single argument.

Corrected Program

class Simplify
{
public static void main(String args[])
{
int a,b,c,d;
a=10;b=5;c=1; //1st correction
c=2*a+2*b; //2nd correction
d=(a+b) / 2; //3rd correction
int p=c/d; //4th correction
System.out.println(c + " " + d + " " + p); //5th correction
}
}
Case-Study Based Question

Question 1

It is possible that the user may not be able to write an error-free program at one go. Due to
this reason, debugging is significant. Debugging is used to eliminate errors from a program.
Some of the examples describing the errors are given below:

(a) A number divided by zero.

(b) The user has applied multiplication sign, instead of division sign.

(c) Sum of p and q is to be divided by their difference using the statement p+q/p-q.

(d) While writing a Java statement, the user forgot to terminate the statement using
semicolon.
Based on the above case, answer the following questions:

1. What is the type of error in (a)?


i. Syntax Error
ii. Logical error
iii. Runtime error
iv. Execution error

2. What is the type of error in (b)?


i. Logical error
ii. Syntax error
iii. Compiler error
iv. Execution error

3. What is the type of error in (c)?


i. Logical error
ii. Syntax error
iii. Runtime error
iv. Execution error

4. What is the type of error in (d)?


i. Syntax error
ii. Logical error
iii. Runtime error
iv. Compilation error

Answer

1. Runtime error
2. Logical error
3. Logical error
4. Syntax error

Answer the following questions

Question 1

Write the syntax of 'if' statement.

Answer

The syntax of 'if' statement is as follows:

if(condition )
Statement

OR
if(condition)
{
Statement 1
Statement 2
:
:
Statement n
}

Question 2

What is a compound statement? Give an example.

Answer

A set of two or more statements which are executed together and are placed within curly
brackets { } is called compound statement.

For example,

int n=5;
if(n>0)
{
System.out.println(n);
n=n-1;
}
In this snippet, the statements System.out.println(n); and n=n-1; are compound statements
as they will be executed only when the condition of if is true.

Question 3

Define the following:

(a) Normal flow of control

(b) Conditional flow of control

Answer

(a) Normal flow of control

It is a sequential movement of the control from one statement to another from beginning to
the end of the program. It is the simplest way of executing a program, where there is no
restriction on flow of control during the process.

(b) Conditional flow of control

Sometimes, it may happen that a statement or a set of statements is executed only when a
given condition results in true. However, if the condition results in false, then these
statements are ignored and the control moves forward to the next statement of the program.
This type of flow of control is known as the conditional flow of control and the statements
are known as the decision making statements.

It can be achieved by using the following statements:

1. if statement
2. if-else statement
3. if-else-if statement

Question 4

Write down the syntax of the following with reference to Java Programming:

(a) to accept an integer value using main( )

(b) to accept a fractional number using main( )

Answer

(a) public static void main(int variable_name)


(b) public static void main(float variable_name)

Question 5

What are the different types of errors that may occur during the execution of a program?

Answer

Logical errors and Run-Time errors occur during the execution of the program.

Question 6

Distinguish between Syntax error and Logical error.

Answer

Syntax Errors Logical Errors

Syntax Errors occur when we violate the rules of Logical Errors occur due to our mistakes in
writing the statements of the programming language. programming logic.

Program compiles and executes but doesn't


Program fails to compile and execute.
give the desired output.

Logic errors need to be found and corrected


Syntax Errors are caught by the compiler.
by the people working on the program.
Question 7

Explain the following:

(a) if-else construct

(b) if-else-if construct

Answer

(a) if-else construct

In if-else construct, the user defines the statements to be executed when the condition results
in true or false. If the given condition results in true, the statements in the 'if' block are
executed and if the given condition results in false, the statements in the 'else' block are
executed.

The syntax of if-else construct is as follows:

if(condition)
Statement 1 //executed if condition is true
else
Statement 2 //executed if condition is false
(b) if-else-if construct

It is used when more than one condition are to be evaluated and only one of them is true.

The syntax of if-else-if construct is as follows:

if(condition 1)
Statement 1 //executed if condition 1 is true
else if(condition 2)
Statement 2 //executed if condition 2 is true
else
Statement 3 //executed if both conditions 1 and 2 are false
When 'condition 1' is 'True' then it will execute statement 1. In case 'condition 1' is false, the
control will move to 'else if' part and will check 'condition 2'. If it is true, the control will
execute 'Statement 2' otherwise it will execute 'Statement 3'.

Solutions to unsolved programs

Question 1

Write a program to calculate and display the value of the given expression:
(a2+b2)/(a-b),when a=20, b=15

public class KboatEvalExp


{
public static void main(String args[])
{
int a = 20, b = 15;
double result;
result = (a * a + b * b) / (a - b);
System.out.println("Result = " + result);
}
}

Output

Question 2

Write a program to calculate the gross salary of an employee when


Basic Salary = Rs.8600
DA = 20% of Salary
HRA = 10% of Salary
CTA = 12% of the Salary.
Gross Salary = (Salary + DA + HRA + CTA)
Display the basic and gross salary.

public class KboatSalary


{
public static void main(String args[]) {
int sal = 8600;
double da = 20 / 100.0 * sal;
double hra = 10 / 100.0 * sal;
double cta = 12 / 100.0 * sal;
double gross = sal + da + hra + cta;
System.out.println("Gross Salary = " + gross);
}
}
Output

Question 3

Write a program to accept Principal, Rate and Time. Calculate and display the interest
accumulated for the first year, second year and the third year compound annually.

Sample Input:
Principal = ₹5,000, Rate = 10% per annum, Time = 3 years

Sample Output:
Interest for the first year: ₹500
Interest for the second year: ₹550
Interest for the third year: ₹605

public class KboatInterest


{
public static void main(double p, double r, int t) {
double i1 = p * r * 1 / 100.0;
double amt = p + i1;
System.out.println("Interest for the first year: " + i1);

double i2 = amt * r * 1 / 100.0;


amt = amt + i2;
System.out.println("Interest for the second year: " + i2);

double i3 = amt * r * 1 / 100.0;


amt = amt + i3;
System.out.println("Interest for the third year: " + i3);
}
}
Output

Question 4

A shopkeeper announces two successive discounts 20% and 10% on purchasing of goods on
the marked price. Write a program to input marked price. Calculate and display the selling
price of the article.

public class KboatSuccessiveDiscount


{
public static void main(double mp) {
double d1 = mp * 20 / 100.0;
double amt1 = mp - d1;
double d2 = amt1 * 10 / 100.0;
double amt2 = amt1 - d2;

System.out.print("Selling Price = " + amt2);


}
}

Output

Question 5

Write a program to input two unequal numbers. Display the numbers after swapping their
values in the variables without using a third variable.
Sample Input: a=23, b= 56
Sample Output: a=56, b=23
public class KboatNumberSwap
{
public static void main(int a, int b) {
a = a + b;
b = a - b;
a = a - b;

System.out.println("Numbers after Swap:");


System.out.println("a = " + a + "\t" + "b = " + b);
}
}

Output
Question 6

Write a program to input the temperature in Celsius and then convert it into Fahrenheit. If the
temperature in Fahrenheit is more than 98.6°F then display "Fever", otherwise "Normal".

public class KboatTemperature


{
public static void main(double cel) {

double far = 1.8 * cel + 32;

if (far > 98.6)


System.out.println("Fever");
else
System.out.println("Normal");
}
}

Output
Question 7

Write a program to accept the marks, obtained in five different subjects (English, Physics,
Chemistry, Biology, Maths) by a student and find the average marks. If the average is 80 or
more, then display he/she is eligible to get "Computer Science', otherwise "Biology".

public class KboatMarks


{
public static void main(int eng, int phy, int chem,
int bio, int math)
{
double avg = (eng + phy + chem + bio + math) / 5.0;

if (avg >= 80) {


System.out.println("Eligible for Computer Science");
}
else {
System.out.println("Eligible for Biology");
}
}
}
Output

Question 8

'Mega Market' has announced festival discounts on the purchase of items, based on the total
cost of the items purchased:
Total cost Discount

Up to ₹2,000 5%

₹2,001 to ₹5,000 10%

₹5,001 to ₹10,000 15%

Above ₹10,000 20%

Write a program to input the total cost. Display the discount and amount to be paid after
discount.

public class KboatDiscount


{
public static void main(double c) {
int d = 0;

if (c <= 2000)
d = 5;
else if (c <= 5000)
d = 10;
else if (c <= 10000)
d = 15;
else
d = 20;

double disc = c * d / 100.0;


double amt = c - disc;

System.out.println("Discount: " + disc);


System.out.println("Amount to be paid: " + amt);
}
}
Output

You might also like