Class 8 Notes
Class 8 Notes
Question 1
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
Question 3
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
Answer
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
1. Windows
2. Java
3. Linux
4. Unix
Answer
Java
Reason — Java is a programming language.
Question 7
Answer
Question 8
Answer
Reason — Loading itself into the memory, memory management and error detection are the
functions of operating system.
Question 9
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
Answer
Question 1
Question 2
Question 3
Question 4
Question 5
Question 1
Answer
(a) Cold Booting
(b) Warm Booting
Question 2
Answer
Question 3
Answer
Question 4
Answer
Question 5
Answer
(a) IO.SYS
(b) MSDOS.SYS
(c) COMMAND.COM
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.
(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?
Answer
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.
(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
Answer
(a) CUI
(b) GUI
(c) User interacts with computer by selecting options from menu list.
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.
Question 1
Answer
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
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.
Question 3
Answer
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 is suitable for personal Multiuser Operating System is suitable
Single User Operating System Multiuser Operating System
Question 1
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.
Question 2
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 —
Question 3
Answer
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
Answer
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
Answer
Question 6
Answer
Question 7
Answer
Question 8
Answer
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
Answer
Reason — The address of a cell consists of the column letter followed by the row number.
Question 2
Answer
Reason — The sheet tab is located at the bottom left corner on the screen.
Question 3
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
1. two values
2. three values
3. any number of values
4. none of them
Answer
Reason — Max( ) function returns the highest value among all the values of the specified
cells or the range of cells.
Question 6
Answer
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
Question 8
Answer
Question 1
Question 2
Question 3
Question 4
The cell in which the cell pointer is located in a worksheet, is referred to as the active cell.
True
Question 5
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
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.
Question 1
Answer
=AVERAGE(82,67,80,74,95)
Question 2
=MAX(D3:K3)
Question 3
Answer
=SUM(7,14,21,28,35)
Question 4
Answer
=MIN(A4:A12)
Question 5
Answer
=SUM(2,3,5,7)
Question 6
Answer
=AVERAGE(E4:K4)
Question 1
=SUM ('C9':C14)
Answer
=SUM(C9:C14)
Question 2
=$B*$3*C$
Answer
=$B$3 * C$4
Question 3
Answer
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
Answer
=MAX(19,70,101)
Question 5
=ADD(24+54+77-38)
Answer
=SUM(24,54,77)-38
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:
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?
(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.
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:
(d) Which option will you select under chart element to display information along horizontal
or vertical direction?
Answer
(b) Two chart elements are Chart Title and Axis Title.
(d) One will select Axis Title to display information along horizontal or vertical direction.
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.
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:
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:
Notice that the relative reference changes but the absolute reference $F$3 remains the same.
Question 3
Mixed Referencing
Answer
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.
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.
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.
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.
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)
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:
Question 2
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.
1. Relative Referencing
2. Absolute Referencing
3. Mixed Referencing
Question 3
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
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
Answer
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.
Question 1
Naming a Worksheet
Answer
Question 2
Renaming a Worksheet
Answer
Question 3
Deleting a worksheet
Answer
Step 1 — Right-click on the sheet name on the Sheet Tab that you want to delete.
Question 4
Answer
Step 2 — Keeping the left mouse button pressed, drag the mouse to select the desired number
of cells in a row.
Question 5
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.
Question 6
Answer
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
Step 1 — Select the cell where you want to display the average price of the books.
Question 2
If the bookseller offers 10% discount, then calculate the amount to be paid to the shopkeeper.
Answer
Step 3 — Select cell D3 again and drag the cell handle from D3 till D9.
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.
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:
Chpt 3
Choose the correct option
Question 1
1. Charles Babbage
2. Md. Musa Al Khwarizmi
3. Blaise Pascal
4. Adelard de Bath
Answer
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?
Answer
Reason — Lady Ada Lovelace was the first person who created the first algorithm that could
be executed on a computer.
Question 3
1. Get
2. Set
3. Start
4. Stop
Answer
Start
Question 4
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
1. Rectangular box
2. Rhombus box
3. Parallelogram box
4. Oval box
Answer
Parallelogram box
Question 1
Question 2
Question 3
Question 4
Question 5
Question 1
Write the names and the symbols of the boxes for the given statements
To assign a number
Question 1
Answer
Question 2
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.
(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.
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:
1. Start
2. End
3. Finish
4. Stop
Answer
(d) Stop
Question 1
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
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
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
Answer
Question 2
Answer
Question 3
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.
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.
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.
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
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:
80% or more A
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:
Flowchart
Question 6
A librarian charges a fine for books, if returned late. The tariff for the fine is given below:
Draw a flowchart to calculate the fine assuming that a book is returned 'N' days late.
Flowchart
Chpt4
Choose the correct option
Question 1
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
1. ''
2. ""
3. ::
4. {}
Answer
''
Reason — A character literal represents a single character enclosed in single quotes (' ').
Question 3
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
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
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
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
1. 8
2. 64
3. 16
4. 88
Answer
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
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
Expression Explanation
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.
Question 10
1. 13
2. 14
3. 15
4. -15
Answer
-15
Expression Explanation
p = 8 + --a At this step, ++a first increments a by 1 so it becomes 8, then this incremented value is
Expression Explanation
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.
Question 1
Question 2
Question 3
The data type must be same as the value assigned to the variable.
True
Question 4
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
Question 7
Question 8
When an increment or decrement operator is used before the operand, it is known as the
postfix operator.
False
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
Question 1
(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
Answer
Output
a = 58
Explanation
a = --b + c++ + b
⇒ a = 9 + 40 + 9
⇒ a = 58
Question 3
(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
(b) a * (++b) % c;
Answer
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
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
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.
(b) System.out.println(!(p=q));
Refer to the above snippet and help him by detecting the errors so that the snippet may
execute successfully.
Answer
(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.
The not equal operator is written incorrectly. The correct not equal operator is !=.
Question 1
Define a program.
Answer
Question 2
Answer
1. Portable
2. User-friendly
3. Concise
4. Usable
5. Flexible
Question 3
Answer
Question 4
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
Answer
Question 6
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.
Question 7
How are data types classified?
Answer
Question 8
(a) Variable
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
(a) Integer
(c) A character
Answer
(a) int
(b) long
(c) char
(d) float/double
Question 10
Answer
Question 11
= ==
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
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.
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:
Question 14
(a) The differences between source code and object code 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
Answer
(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.
Question 16
Answer
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.
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.
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
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
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
Answer
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.
Question 1
Question 2
Question 3
Question 4
In a decision making program, 'if' checks whether the condition is true or false.
True
Question 5
Question 6
In an if-else statement, the condition is to be defined only with if and not with else.
True
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
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
Corrected Program
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
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:
(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:
Answer
1. Runtime error
2. Logical error
3. Logical error
4. Syntax error
Question 1
Answer
if(condition )
Statement
OR
if(condition)
{
Statement 1
Statement 2
:
:
Statement n
}
Question 2
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
Answer
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.
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.
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:
Answer
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
Answer
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.
Answer
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.
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.
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'.
Question 1
Write a program to calculate and display the value of the given expression:
(a2+b2)/(a-b),when a=20, b=15
Output
Question 2
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
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.
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;
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".
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".
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%
Write a program to input the total cost. Display the discount and amount to be paid after
discount.
if (c <= 2000)
d = 5;
else if (c <= 5000)
d = 10;
else if (c <= 10000)
d = 15;
else
d = 20;