Professional Documents
Culture Documents
Oswaal ISC Question Bank Class 12 Computer Science Book For 2023
Oswaal ISC Question Bank Class 12 Computer Science Book For 2023
Best Seller k i
WN
m
_
OSWAAL BOOKS ®
tuaBnra IMUR
etraptii
*
ISC
¥ ¥
5] r#j
•
{ U
s®6
Kj
QUESTION
BANK
Chapterwise & Topicwise
O
4 SOLVED
PAPERS
CLASS 12
xJJL *
COMPUTER
SCIENCE
/
X
i m
Latest Board
•••• • Mind Maps
Paper
••••••••
•<
y S ta ®
Examiners ’ Concept Videos
| Comments & for blended
jg) i Answering Tips | Learning
r
Best Seller FOR
2023 EXAM
•i OSWAAL BOOKS
. taaisiacaiB caw c-rcwcn
ISC
QUESTION
Chapterwise
BANK
& Topicwise
SOLVED
PAPERS
CLASS 12
. j ~ COMPUTER SCIENCE
Strictly as per the Revised Syllabus Released on
20th May 2022 Issued by CISCE
••
••••••
•
••••
•••
•••
•••
••
•••• ••• •
•••••••••••
is
Examiners ’ Concept Videos
Comments & for blended
Learning
IS 7th EDITION YEAR 2022- 23
pill ISBN (0) (8) (
SYLLABUS t
"978-93-5595-137- 3"
ISC-INDIAN SCHOOL
^ )
CERTIFICATE EXAMINATION
COVERED r
©
PUBLISHED BY
«OSWAAL BOOKS &
LEARNING PVT. LTD.
COPYRIGHT
RESERVED 1 / 11, Sahitya Kunj, M.G. Road,
Agra - 282002, (UP) India
BY THE PUBLISHERS
All rights reserved . No part of
this book may be reproduced, 1 / 1 , Cambourne Business Centre
stored in a retrieval system, Cambridge, Cambridgeshire
or transmitted, in any form or CB 236DR United kingdom
by any means , without written
permission from the publishers.
The author and publisher will
gladly receive information 0562 - 2857671
enabling them to rectify any
error or omission in subsequent
editions.
contact@oswaalbooks.com
DISCLAIMER
•Oswaal Books, hasanyexercised due care and caution in collecting all the data before publishing this book.
In spite of this if , inaccuracy
omission or printing error occurs with regard to the data contained in this
book, Oswaal Books will not be held responsible or liable.
• All the names, characters and incidents depicted in this book by the author are fictitious. The sole
purpose is to explain the given concept to the students. They have no relation with any event, person,
religion, caste or political establishments.
• The opinions, discussions, views and recommendations are solely those of the authors and not of
Oswaal Books.
(3)
Get Unlimited Access to
Free Resources
at: oswaalbooks.com / free-resources /
/T •? 22£LKS£
S
«
'
£
I I (4)
Step 3: You are here!
Enjoy this unlimited treat of
FREE resources.
LET THE ADVENTURE BEGIN!
m
India is currently one of the youngest economies in the
world. Hence, it's imperative for our education system to
churn out more learners than ever before. Considering the
Banking on current learning mindset of students CISCE has introduced
Better Systems the curriculum for classes XI & XII containing academic
"Improvise, Adapt, overcome" has content, syllabus for examinations with learning outcomes,
been the mantra of education pedagogical practices and assessment guidelines. The Board
boards and schools everywhere. will conduct the annual scheme of assessment at the end of
Conducting lectures as well as the Academic session 2022- 23 as per the given curriculum.
assessments online was still pretty
uncommon in our country. But To score well in Exams students need to start by acquiring the
now teachers and students have latest and most relevant study material. The focus should be
got familiar with the new ways. on conceptual clarity rather than mugging up facts. Students
The intention of shifting from rote should find out their preparation level by conducting
learning to competency-based regular self-assessments and practicing questions from this
development will prove beneficial question bank. Breaking down the syllabus in a systematic
to the coming generations; and in way right from the beginning will help students learn better
turn, to the country. and secure a high score.
Benefits of studying from Oswaal Question Banks for ISC exams include
(5)
CISCE CIRCULAR 2022-23
Gerry Arathoon
Chief Executive & Secretary
(6)
SYLLABUS
Boolean algebra; operations AND, OR and NOT; 3. Implementation of algorithms to solve problems
truth tables. The students are required to do lab assignments in
(c) Basic theorems of Boolean algebra (e.g. duality, the computer lab concurrently with the lectures.
idempotence, commutativity, associativity, Programming assignments should be done such that
distributivity, operations with 0 and 1, complements, each major topic is covered in at least one assignment.
absorption, involution); De Morgan's theorem and Assignment problems should be designed so that
its applications; reducing Boolean expressions they are sufficiently challenging. Students must
to sum of products and product of sums forms; do algorithm design, address correctness issues,
Karnaugh maps (up to four variables). implement and execute the algorithm in Java and
Verify the laws of Boolean algebra using truth tables. debug where necessary.
Inputs, outputs for circuits like half and full adders, Self explanatory.
(7)
SYLLABUS
.
4 Programming in Java (Review of Class XI Sections B searching, finding maximum/minimum, sorting
and C) techniques, solving systems of linear equations,
Note that items 4 to 13 should be introduced almost substring, concatenation, length, access to char in
simultaneously along with classes and their definitions . string, etc.).
While reviewing, ensure that new higher order problems Storing many data elements of the same type requires
are solved using these constructs. structured data types - like arrays. Access in arrays is
.
5 Objects constant time and does not depend on the number of
(a ) Objects as data (attributes) + behaviour (methods); elements. Address calculation ( row major and column major ),
object as an instance of a class. Constructors. Sorting techniques ( bubble, selection, insertion ). Structured
data types can be defined by classes - String. Introduce
(b) Analysis of some real-world programming
the Java library String class and the basic operations on
examples in terms of objects and classes.
strings (accessing individual characters, various substring
(c) Basic input/output using Scanner from JDK; input/
operations, concatenation, replacement, index of operations ).
output exceptions. Tokens in an input stream,
11 . Recursion
concept of whitespace, extracting tokens from an
input stream (String Tokenizer class). Concept of recursion, simple recursive methods
(e.g. factorial, GCD, binary search, conversion of
.
6 Primitive values, Wrapper classes, Types and casting
representations of numbers between different bases).
Primitive values and types: byte, int, short, long, float,
Many problems can be solved very elegantly by observing
double, boolean, char. Corresponding wrapper classes
that the solution can be composed of solutions to ' smaller'
for each primitive type. Class as type of the object.
versions of the same problem with the base version having a
Class as mechanism for user defined types. Changing
known simple solution. Recursion can be initially motivated
types through user defined casting and automatic type
by using recursive equations to define certain methods. These
coercion for some primitive types.
definitions are fairly obvious and are easy to understand. The
.
7 Variables, Expressions
definitions can be directly converted to a program. Emphasize
Variables as names for values; named constants that any recursion must have a base case. Otherwise, the
(final), expressions (arithmetic and logical) and their computation can go into an infinite loop.
evaluation (operators, associativity, precedence).
The tower of Hanoi is a very good example of how recursion
Assignment operation; difference between left hand
gives a very simple and elegant solution where as non-
side and right hand side of assignment.
recursive solutions are quite complex.
.
8 Statements, Scope
SECTION C
Statements; conditional (if, if else, if else if, switch
Inheritance, Interface, Polymorphism, Data structures.
case, ternary operator), looping (for, while, do while,
12. Inheritance, Interfaces and Polymorphism
continue, break); grouping statements in blocks, scope
and visibility of variables. (a ) Inheritance; super and derived classes; member
access in derived classes; redefinition of variables
.
9 Methods
and methods in subclasses; abstract classes; class
Methods (as abstractions for complex user defined
Object; protected visibility. Subclass polymorphism
operations on objects), formal arguments and actual
and dynamic binding.
arguments in methods; different behaviour of primitive
Emphasize inheritance as a mechanism to reuse a class
and object arguments. Static method and variables. The
by extending it . Inheritance should not normally be
this Operator. Examples of algorithmic problem solving
used just to reuse some methods defined in a class but
using methods (number problems, finding roots of
only when there is a genuine specialization (or subclass )
algebraic equations etc.).
relationship between objects of the super class and that of
.
10 Arrays, Strings
the derived class.
Structured data types - arrays (single and multi-
b
( ) Interfaces in Java (conceptual)
dimensional), address calculations, strings. Example
Emphasize the difference between the Java language
algorithms that use structured data types (e.g.
(8)
SYLLABUS
construct interface and the word interface often used to Examiner. A printout of the program listing including
describe the set of method prototypes of a class. output results should be attached to the answer
13. Data structures script containing the algorithm and handwritten
(a) Basic data structures (stack, queue, dequeue); program. This should be returned to the examiner. The
implementation directly through classes; definition program should be sufficiently documented so that the
through an interface and multiple implementations algorithm, representation and development process
by implementing the interface. Conversion of Infix is clear from reading the program. Large differences
to Prefix and Postfix notations. between the planned program and the printout will
Basic algorithms and programs using the above data result in loss of marks.
structures. Teachers should maintain a record of all the assignments
(b) Single linked list (Algorithm and programming), done as part of the practical work through the year and
binary trees, tree traversals (Conceptual). give it due credit at the time of cumulative evaluation
at the end of the year. Students are expected to do a
The following should be covered for each data structure:
Linked List ( single ): insertion, deletion, reversal, -
minimum of twenty five assignments for the year.
(9)
SYLLABUS
Following are the recommended specifications as of now: is that it should run the operating system and Java
The Facilities: programming system 0ava compiler, Java runtime
• A lecture cum demonstration room with a environment, Java development environment ) at
MULTIMEDIA PROJECTOR/ an LCD and O.H.E acceptable speeds.
attached to the computer. • Good Quality printers.
• A white board with white board markers should be Software:
available. • Any suitable Operating System can be used.
• A fully equipped Computer Laboratory that allows one • JDK 6 or later.
computer per student. • Documentation for the JDK version being used.
• Internet connection for accessing the World Wide Web • A suitable text editor. A development environment with
and email facility. a debugger is preferred (e.g. BlueJ, Eclipse, NetBeans).
• The computers should have a minimum of 1 GB RAM BlueJ is recommended for its ease of use and simplicity.
and a P IV or higher processor. The basic requirement
( 10 )
Assessment of Practical File Assessment of the Practical Examination
(To be evaluated by the Visiting Examiner only) TOTAL MARKS (Total
Marks are to be added and
Visiting Ex- entered by the Visiting Ex-
Unique Identification
Internal Algorithm Java Program Hard Copy Output
Evaluation aminer with internal aminer )
S. No. Number (Unique ID ) of ( printout)
10 Marks 5 Marks Documenta-
the candidate
tion
1.
2.
3.
4.
M
M
5.
6.
7.
8.
9.
10 .
i
Examination Paper 2020
• Passing objects to functions
• Interfaces
Circular queue operations for push() and pop() operations
• Degree of and its implementation using inheritance
• Properties aofnode in a binary tree
• Dual and Compliment of a Boolean expression
zero
• Infix to prefix notation
• Output using recursion
• Circular queue
• Concept of inheritance with interface and super class
• Degree of a node in a Binary tree
• Properties of zero in Boolean algebra
•
Examination Paper 2019
• Interface
Propositional statements for Converse and Contrapositive.
• Complexitydefinition .
• Output using recursive function
and comparing 2
0(n ) and 0(2“).
• K MAPS (grouping, redundant .groups, map rolling, place value).
• Recursive technique.
- -
»
• Passing objects to functions.
• Queue operations for push() and pop() operations.
• Size of a binary tree.
•
Examination Paper 2018
• Extracting
Wrapper classes
• Recursive technique
digits from a number without using the % operator.
• methods. : >Passing objects to functions. > Stack operations for push() and pop(
• Complexityand Classes
• Returning value of the base case in recursive output
• Complement properties
• Recursive technique
• Passing objects to functions
• Queue operations for adding and removing elements
•Examination Paper 2016
• The symbols 'L' and 'V' from propositional logic
• 'fall through' condition in switch case ()
( 12 )
Topics Found Difficult by Candidates
I ( 13 )
Concepts in which Candidates got Confused
i
- (grouping, redundant groups, map-rolling, place value)
• Recursive Drawing XOR gate using NOR gate
•Examination Paper technique
2019
•• Use of single instance variable
Propositional statements .
for multiple operations in various functions.
•• Size and Siblings of a tree
Link list and Queue .
( 14 )
Suggestions for Students
> => Apart from Textbook learning, surfing the net (Wikipedia, School net, etc.) and other reliable
resources would be helpful to gather knowledge on the latest concepts and enhancements
in programming. Proper definitions, output programs, algorithms, etc. can be downloaded
directly from the internet.
|
=> Prepare a summary for each chapter or use high lighters to highlight the important terms and
definitions.
> => Revise of the entire syllabus thoroughly.
Relate everything taught in class with Real Life Environment examples which helps in
remembering / recall of the concepts learnt.
> => Practical work on the computer is necessary on regular basis to understand the syntax and
to correct errors.
=> Answers and definitions should be short and precise and according to the marks allocated.
Solve ISC previous years’ question papers.
>=> Underline/ Highlight Important words and terms.
>=> Show working at the side of each question, wherever required.
|
=> Mention laws while reducing a Boolean Expression. Practice one form of K-Map with proper
place value for both SOP and POS.
> => In programming documentation is compulsory and should be mentioned with each program.
>=> Declare the class with data members and member functions.
>=> Expand or define each function according to the instructions given by the side of each
function.
|
=> Do not memorise the program, try to understand the logic.
> => Practice constructors with every program. Treat each function of a class as a separate program.
=>
> Do your preparations section-wise following the scope of the syllabus.
=> Revise and integrate the concepts studied in Class XI with the Class XII syllabus.
=> Avoid selective study.
=> Give equal importance to all the topics mentioned in the syllabus.
=>
|
Practise each topic/sub-topic with as many examples as possible.
Gather knowledge of the subject comprehensively with latest concepts and improved
techniques in programming using reliable resources like text books, Wikipedia etc.
=> Download directly proper definitions, output programs, algorithms etc. from the net.
=> Prepare summary for each chapter or use high lighters to recognize the important terms and
definitions.
=> Understand all key terms/important words, definitions etc. comprehensively and learn.
( 15 )
Suggestions for Students
=> Practise on the system on a regular basis to understand the syntax and to correct the errors.
=> Always write laws while reducing a Boolean expression.
=> Practise one form of K-Map with proper place value for both SOP and POS.
=> Mention documentation with each program.
=> Declare the class with data members and member functions.
=> Expand or define each function according to the instructions given by the side of each function,
t# Practise constructors with every program.
=> Understand the logic of a program instead of memorising it.
=> Solve previous years’ ISC question papers.
=> Always show workings, wherever required, on the side of each question.
=> Always answer to any question as per the requirement of the question.
( 16 )
HEAR IT FROM OUR HAPPY READERS!
Suresh Kalanki
Aashito
Mayank Singh
( 17 )
Exclusive School Books Suppliers
OUR DISTRIBUTORS
M/s Pragnya, 8847888616, 9437943777,
ANDHRA PRADESH BHUBANESHWAR
Padmalaya, 9437026922
Nova Publisher 8L Distributors, (0612) 2666404, Cheap Book Store, 9872223458, 9878258592, Subhash Book
JALANDHAR Depot, 9876453625,
City Book Shop, 9417440753
Shri Durga Pustak Mandir, 9334477386, Sharda Pustak Bhandar,
RAJASTHAN
9334259293
DUMKA Vidyarthi Pustak Bhandar, 9431310228 ALLAHABAD Mehrotra Book Agency, (0532) 2266865, 9415636890
HUBLI Renuka Book Distributors, 0836- 2244124, 9513355124 GORAKHPUR Atul Pustak Bhandar, 9935210622, Central Book, 9935454590
ERNAKULAM Academic Book House, (0484) 2376613 MEERUT Ideal Book Depot, (0121) 4059252, 9837066307
JOMER SRINILAYAM H & C Store, (0484) 2351233 NOIDA Prozo Distribution Pvt Ltd., 9318395520/8882170255
KOTTAYAM H & C Store, (0481) 2304351, Book Centre, (0481) 2566992 VARANASI Bokaro Student Friends, (0542) 2401250, 8299344607
TRIVANDRUM Academic Book House, (0471) 2333349, 9447063349, Gupta Books, 9918155500, 8707225564
CALICUT Aman Book Stall, (0495) 2721282, DEHRADUN Brothers Pustak Bhandar, 9897833882, Mittal Book, 9837223825
PUNE Natraj Book Depot, (020) 24485054, 9890054092, SILIGURI Agarwal Book House, (0353) 2535274, 9832038727
ODISHA
£-
o
CUTTACK A. K. Mishra Agencies, 9437025991, 9437081319
( 18 )
ISC SEMESTER-2 EXAMINATION
Computer Science
Solved Paper - 2021-22
Class-12th
Maximum Marks: 35
Time allowed: One and a half hours
Candidates are allowed an additional 10 minutes for only reading the paper.
They must NOT start writing during this time.
Answer all questions in Section A, Section B and Section C.
While answering questions in Section A and B, working and reasoning may he
indicated briefly, wherever required.
The intended marks for questions or parts of questions are given in brackets [ ].
All working, including rough work, should be done on the same sheet as the rest of the answer.
Section-A
Question 1
(i) The concept in Java to perform method overloading and method overriding is called: [1]
(a) inheritance (b) Polymorphism
(c) data abstraction (d ) encapsulation
(ii) The interface in Java is a mechanism to achieve: [1]
(a) encapsulation (b) overriding
(c) polymorphism (d ) abstraction
(iii) System.out.println ("Computer Science" last Index Of ('E'));
,
(i) State the siblings of the nodes C and E. Also, state the predecessor node( s ) and successor node( s ) of node B. [2]
(ii) Write the in-order traversal of the left sub tree and the pre-order traversal of the right sub tree. [2]
20 Oswaal ISC Question Bank Chapterwise & Topicwise, COMPUTER SCIENCE Class-XII
Section-C
. I
Each program should be written in such a way that it clearly depicts the logic of the problem
This can be achieved by using mnemonic names and comments in the program.
( Flowcharts and Algorithms are not required.)
The programs must be written in Java.
Question 5.
(i) Design a class Unique, which checks whether a word begins and ends with a vowel. [6]
Example: APPLE, ARORA etc.
The details of the members of the class are given below:
Class name : Unique
Data members/instance variables:
word stores a word
len to store the length of the word
Method/Member functions:
Unique( ) default constructor
void acceptword ( ) to accept the word in UPPER CASE
boolean checkUnique( ) checks and returns 'true' if the word starts and ends with a
vowel otherwise returns 'false'
void display( ) displays the word along with an appropriate message
Specify the class Unique, giving details of the constructor, void acceptword( ), boolean check Unique( ) and
void display( ). Define the main( ) function to create an object and call the functions accordingly to enable the
task.
OR
(ii) Design a class NoRepeat which checks whether a word has no repeated alphabets in it.
Example: COMPUTER has no repeated alphabets but SCIENCE has repeated alphabets.
The details of the class are given below:
Class name : NoRepeat
Data members/instance variables:
word to store a word
len to store the length of the word
Method/Member functions:
NoRepeat(String wd) parameterized constructor to initialize word = wd
boolean check( ) checks whether a word has no repeated alphabets and returns
true else returns false
void pm( ) displays the word along with an appropriate message
Specify the class NoRepeat, giving details of the constructor(String), boolean check( ), and void pm ( ). Define
the main( ) function to create an object and call the functions accordingly to enable the task.
Question 6.
(i) A class CalSeries has been defined to calculate the sum of the series: [6]
2
sum = 1 + x + x + x 3
+ xn
Some of the members of the class are given below:
Class name : CalSeries
Data members/instance variables:
x integer to store the value of x
n integer to store the value of n
sum integer to store the sum of the series
Member functions/methods:
CalSeries( ) default constructor
void input( ) to accept the values of x and n
int power(int p, int q) return the power of p raised to q ( p1!) using recursive
technique
void cal( ) calculates the sum of the series by invoking the method
powerQ and displays the result with an appropriate message
I SOLVED PAPER - 2021-22 21
Specify the class CalSeries, giving details of the constructor, void input( ), int power(int,int) and void cal( ).
Define the main( ) function to create an object and call the member function accordingly to enable the task,
(ii) Design a class Revno which reverse an integer number.
Example: 94765 becomes 56749 on reversing the digits of the number.
Some of the members of the class are given below:
Class name : Revno
Data member/instance variable:
num to store the integer number
Member functions/methods:
Revno() default constructor
void inputnum() to accept the number
int reverse (int nn) returns the reverse of a number by using recursive technique
void display() displays the original number along with its reverse by
invoking the method reverseQ
Specify the class Revno, giving details of the constructor, void inputnum ( ), int reverse(int ) and void display().
Define the main () function to create an object and call the functions accordingly to enable the task.
Question 7.
A super class Item has been defined to store the details of an item sold by a wholesaler to a retailer. Define a
subsclass Taxable to compute the total amount paid by the retailer along with service tax.
Some of the members of both the classes are given below:
Class name : NoRepeat
Data members/instance variables:
name to store the name of the item
code integer to store the item code
amount stores the total sale amount of the item (in decimals)
Member functions/methods:
Item (...) parameterized constructor to assign value ot the data members
void show( ) to display the item details
Class name Taxable
Data members/instance variables:
tax to store the service tax (in decimals)
totamt to store the total amount (in decimals)
Member functions/methods
Taxable(...) parameterized constructor to assign values to the data
members of both classes
_
void cal tax( ) calculates the service tax @ 10.2% of the total sale amount
calculates the total amount paid by the retailer as (total sale
amount + service tax)
void show( ) to display the item details along with the total amount
Assume that the super class Item has been defined . Using the concept of inheritance, specify the class Taxable,
giving details of the constructor, void cal_tax( ) and void show ( ).
The super class, main function and algorithm need NOT be written.
22 Oswaal ISC Question Bank Chapterwise & Topicwise, COMPUTER SCIENCE Class-XII . I
ANSWERS
Section-A char cl = word.charAt(0);
char c2 = word.charAt(len-l);
1. ( i) Option (b) is correct. if (vowel.indexOf (cl ) > = 0 &&vowel.indexOf (c2)
(ii) Option (b) is correct. > = 0)
(iii) Option (c) is correct return true;
(iv) String str ="SIMPLICITY".substring(6); else
(v) LIFO used in Stack and FIFO used in Queue. return false;
(vi) Output will be : 325 }
(vii) In recursive function, time complexity is much public void display(){
higher than non-recursive function. System.out.println("Word =" + word);
boolean flag = checkUnique();
Section-B if (flag)
Question 2. System.out.println("Word is unique");
else
Finite recursion Infinite recursion
System.out.println("Word is not
In thiskind of In this type of unique");
recursion the process recursion, it does not }
terminates after a terminate after a finite public static void main (String [ ] arg){
finite number of number of recursive Unique obj = new Unique();
recursive calls. calls. obj.acceptword ();
Question 3. obj.display();
P * (Q - R) + S }
}
= P * (- QR) + S (ii) import java.util.Scanner;
= (* P (- QR)) + S public class NoRepeat
= + * P - QRS {
Question 4.
String word;
(i) Sibling of node C is B, and sibling of node E is D. int len;
Predecessor node of B is (D) and successor node public NoRepeat(String wd ){
of B is G. word = wd;
(ii) Inorder traversal of left sub tree is : D B G E len = word.lengthQ;
Pre-order traversal of right sub tree is: C F HI }
private boolean check(){
Section-C for(int i = 0;i < len;i + + ){
Question 5. int c = 0;
(i) import java.util.Scanner; for(int j = 0;j < len;j + + ){
public class Unique if (word.charAt(i) = = word.charAt( j))
C+ +;
{
}
String word;
if (ol)
int len;
return false;
public Unique(){ }
word = ""; return true;
len = 0; }
} public void prn(){
public void acceptword(){ System.out.println("Word =" + word);
Scanner sc = new Scanner(System.in); boolean flag = check();
System.out.println("Enter a word"); if (flag)
word = sc.nextLine(); System.out.println("No repeated character
word = word.toUpperCase(); found");
len = word.lengthQ; else
} System.out.println("Repeated character
found");
private boolean checkUnique(){ }
String vowel ="AEIOU";
void main(String [ ] arg){
I Scanner sc = new Scanner(System.in);
SOLVED PAPER - 2021 -22
u
WRITING YOUR NOTES
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16 .
17.
18.
19.
20.
Section A
CHAPTER
1 BOOLEAN
ALGEBRA
B (a) Propositional logic, well formed formulae, truth values and
interpretation of well formed formulae (WFF ), truth tables, satisfiable,
unsatisfiable and valid formulae. Equivalence laws and their use in
'simplifying WFFs. ( b ) Binary valued quantities; basic postulates of Boolean algebra; operations AND, OR
'and NOT; truth tables, ( c ) Basic theorems of Boolean algebra (e.g. Duality, idempotence, commutativity,
'associativity, distributively, operations with 0 and 1, complements, absorption, involution ); De Morgan' s
[theorem and its applications; reducing Boolean expressions to sum of products and product of sums forms;
!Karnaugh maps (up to four variables ).
[
-
*Note These Concepts are only for your reference. Questions from these parts will not be asked in the Final Examination.
Im
Propositional Logic Topic - 1
Concepts covered: Propositional Logic;
Topic -1 NegationConjunctionJDisgunctionConditional;
Propositional Logic
.
Page No 01
bi-conditional;truthtable;equivalencelawsof
propositions. Topic-2
Theorems and Postulates of
Boolean Algebra
.
Page No 12
A"
Additive, 0 + p = p
Identity (Idempotent La n
r w) g
Boolean laws P +P= P
£aivo/ Cn {p . p=p I
£
Multiplicative, l.p- p fi?
Additive, l + p = l o '
P + P -l .
*I
{.= p p' 0 p
a&
a 82
p + q=q+ p
1
p.q = q.p (p+ ql -p' q
- 7J
{ (p q)' = p’+ q'
- n
m
Z
n
p + (q + r ) = ( p + q ) + r
p.(q.r ) = (p.q).r ST
Converting 1 to 0
}
(Sum terms are called maxterms) (Product terms are called minterm )
eg. (P + Q + R ), (P’ + Q + R') eg. (PQ.R), (F.Q.R )-
0
tSuins) Jo'imt of {Boolean
Ixp'ienion
(Disjunction of minterms)
(Conjunction of maxterms) , ,
, eg. S1= EQ.R + F.Q .R + PQ'.R’
eg. P1= (A + B + C).(A + B' + C').(A' + B + C).(A' + B + C)
S2= Z(l,3,6,7)
/
P2= 71(2,3 5,7)
co
O
O
(A way of representing each term as a maxterm or (only the term numbers are used) G
>
a minterm not contains all the variables) eg. 1 Cardinal form of A'.B' + A'B + AB is Z(0,l,3) Z
eg. 1 A' B’ + A'B + A.B >
eg. 2 Cardinal form of (A + B + C'XA + B' + C'MA' + B' + C) 5
eg. 2 (A + B + C).(A + B' + C).(A' + B' + C) m
is 71(1,3,7) co
£
Trace the Mind Map (f
First Level Second Level
^
Third Level
CO
4 .
Oswaal ISC Question Bank Chapterwise & Topicwise, COMPUTER SCIENCE Class- XII
I
I
v
£
4£
£ o
I!
iffi
£ S »5 M D
l l III
I1 I ? S
I
V%
2 pair
An arrangement of variables of
CD' C'D CD CD' an exp such that simplication can
A'B' :1 1 l i| be done by minimising the terms.
eg - A'B 0 0 0 0
'
AB :T r 0 0
AB' :l 1 0 0
Developed by
8& JCaxnaugA’a Map Mr. Maurice Karnaugh
CD ' ' C'D CD CD' O
ME %
A'B' I 1 l i; 31- Map
e - g. A'B 1 1 1 l:
#
AB 0 0 0 0 Variables A B B [0] B [11
AB' 0 0 0 0 B [0] B' [1] A' [0] A'B' A' B 1
A B 0
K-Map of sum of A[l ] AB'
A [0] A + B A + B' 2
AB 3
0 1 Product Form (SOP)
A [1] A + B A + B'
2
K-Map of Product B'C' B'C BC BC '
B +C B +C B + C' B' + C' B' + C of Sum Form (POS) [0 0] [01] [Oil [101
A [001 [01] [11] [10] A'B'C' A'B'C A'BC A'BC '
A + B + C A + B + C' A + B' + C ' A + B' + C A' [0]
A [0] 0 1 3 2
0 1 3 2 AB'C' AB'C ABC ABC '
A [1]
A' + B + C A' + B + C' A' + B' + C ' A' + B' + C 4 5 7 6
A' [l]
4 5 7 6
• asDisjunction (OR): It is represented by 'OR' or V symbol. Let R and S be two propositions. Then R v S is read
I
R or S.
For Example,
R: She is a player.
S: She is a dancer.
R v S: She is a player OR dancer.
• Conditional (=> ): A —> B is called a conditional statement. It is also read as 'A implies B'.
For Example,
A: You will do hard work.
B: You will get success.
A —> B: If you will do hard work, then you will get success.
• Biconditional (<=>): A o B is known as biconditional statement or proposition. ' o ' or '<=>' shows equivalence
relation between two propositions.
For example:
A: She is smart.
B: She is beautiful.
A —> B: She is smart as well as beautiful.
• Truth Table: A table used to determine all possible truth values regarding a proportional value. A single
proposition contains two possible values as 'True' for correct and 'False' for incorrect value. True value (denoted
by 1) or false value (denoted by 0) are called 'truth values'.
We can determine the truth values of the various connections as follows:
|Key Terms
> Logic means some rules which can be applied over an expression to find its optimal solution.
> Mathematical logic is used in designing the circuits in the computer system.
> Propositional logic is a declarative statement with two possible values either 'True (01)' or 'False (0)' but not both.
> AND (A), OR (V), Not ( ~ ), conditional ( —>) and biconditional (<->) are logical connectives. With the help of these
connective, compound statements are created.
> If there are n-variables in the expressions, then it contains 2n possible combination of their values.
> Tautology: A compound statement having all its possible values become True.
> Contradiction: A compound statement that is always False.
> Contingency: A compound statement that is neither True nor False.
> Argument: An argument is valid if it is a tautology.
> Syllogism: Logical process of drawing conclusion from given propositions.
Answering Tip
Answering Tip
w Students should learn all the propositional logic
; !r - Learn Proposition logic using all the terms that
are required, especially the terms conjunction,
with appropriate symbols and truth tables. i j disjunction, negation, implications and
' ! biconditional.
Q. 3. Draw the truth table to prove the proportional
logic expression.
(X => Y) A (Y => X ) = X <=> Y
Q. 7. Using a truth table verify: [ISC 2013] #
p = (p A ~ q) v (p A q)
( ~ P => q) A
0
[ISC Specimen Question Paper 2016]
Q. 8. If (X => Y) then write its
Q. 4. Verify the following proposition with the help of
a truth table. (i ) Converse (ii) Contrapositive [ISC 2012]
P - ( ~ P A Q) = P - Q [ISC 2015] Ans. (i ) Converse Y » X —
Ans. Proof of P v ( ~ P A Q) = P v Q (ii) Contrapositive Y X
L.H.S. R.H.S. Q. 9 . Using truth table, verify whether the following is
true or false: [ISC 2011]
P Q ~P ~P A Q P V ~P A Q PVQ
L.H.S. R .H.S.
0 0 1 0 0 0
(p ^ q) = (q => p)
0 1 1 1 1 1 Ans.
1 0 0 0 1 1
p q p => q q p q => p
I I o o I I
0 0 1 1 1 1
Q. 5. Differentiate between a proposition and WFF. 0 1 1 0 1 1
[ISC 2014]
1 0 0 1 0 0
Ans. Proposition: A statement that can have only two
possible answers (True or False). 1 1 1 0 0 1
WFF: It is a proposition which is satisfiable or L.H.S. R .H.S.
valid . [ISC Marking Scheme, 2014]
Q. 10. Using a truth table, verify if the following
proposition is valid or invalid [ISC 2013]
( =* ) ( => ) = ( => )
a b A b c a c
Examiner's Comment
Ans.
w A number of candidates gave the full form of WFF. —
a b c a > b b -> c (a » b) A (b -»c) (a > c) —
Some candidates wrote the same definition for —
both. 0 0 0 1 1 1 1
0 0 1 1 1 1 1
0 1 0 1 0 0 1
Answering Tip
o l l l l l l
w More practice should be given in the chapter of l 0 0 0 1 0 0
propositional logic and the various terms used 1 0 1 0 1 0 1
must be learnt with examples.
1 1 0 1 0 0 0
Q. 6. Write the truth table for a 2-input conjunction and 1 1 1 1 1 1 1
disjunction in a proposition. [ISC 2014] Hence , the given proposition is invalid.
These questions are for practice and their solutions are available at the end of the chapter
10 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Q. 11. Verify if, p • ( ~ p + q') = (p => q) ' using truth (ii) The truth table for p <=> q, i.e., bi-directional
I
table. [ISC 2010] between p and q.
Ans. Here, we have two input variables, i.e., p and q. To q p«q
P
satisfy this expression, take L.H.S. = p • ( ~ p + q ')
and R.H.S. = ( p => q) ' 0 o I
Now, formed the truth table, o I o
p q ~p q' ( ~ p + q ) p ( ~ p + q ) p => q (p ^ q) '
’
I o o
o0 1 1 1 0 1 0
1 1 1
01 1 0 1 0 1 0
Q. 13. Using the truth table verify p • q + p • q ' = p.
10 0 1 1 1 0 1
Ans. Given expression is p • q + p • q' = p
11 0 0 0 0 1 0 Here, we have two input variables, i.e., p and q.
L.H.S. R.H.S. To satisfy the given expression, we take
From the above truth table, we can see that both L.H.S. = p • q + p • q "
L.H.S. and R.H.S. possess same truth values. So, and R.H.S. = p
expression is verified. Now let us form the truth table.
Q. 12. Draw the truth tables of the propositional logic
expression p => q and p <=> q. [ISC 2008] p q p q q' p q' -
p q + p q' -
Ans. Here, we have two input variables, i.e., p and q. 0 0 0 1 0 0
(i) The truth table for p => q, i.e., implication
between p and q. 0 1 0 0 0 0
p q p => q 1 0 0 1 1 1
0 0 1 1 1 1 0 0 1
0 1 1
1 0 0 R.H.S. L.H.S.
1 1 1 So, p • q + p • q ' = p Hence Proved.
Q. 14. Using the truth table, prove that ( A + B ) ' + ( A + B ') ' = A '. [ISC 2006]
Ans. Given expression, (A + B) ' + (A + B ') ' = A '
Here, we have two input variables, i.e., A and B.
To satisfy this expression, we take L.H.S. = (A + B) ' + (A + B ') ' and R.H.S. = A'
Now, let us form the truth table,
A B A+B (A + B ) ' B' A + B' (A + B ') ' ( A + B) ' + (A + B ') ' A'
0 0 0 1 1 1 0 1 1
0 1 1 0 0 0 1 1 1
1 0 1 0 1 1 0 0 0
1 1 1 0 0 1 0 0 0
L.H.S. R.H.S.
From the above table, we can see that both L.H.S. and R.H.S. possess same truth values. Hence, it is proved.
Q. 15. Prove that [(p' + q) • (q' + r)]' + (p' + r) = 1 [ISC 2006]
Ans. Here, we have three input, i.e., p, q and r. Now, let us form the truth table.
p q r P q ' p + q q ' + r ( p ' + q) ( q ' + r ) l ( p ' + q ) - ( q + nr p ' + r [(p ' + q) (q ' + r)]' + ( p ' + r)
0 0 0 1 1 1 1 1 0 1 1
0 0 1 1 1 1 1 1 0 1 1
0 1 0 1 0 1 0 0 1 1 1
0 1 1 1 0 1 1 1 0 1 1
1 0 0 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1 1 1
1 1 0 0 0 1 0 0 1 0 1
1 1 1 0 0 1 1 1 0 1 1
I BOOLEAN ALGEBRA 11
(a=>b) a => 1 0 1 0 1 0 0 0
I
a b c a=>b a => c (b.c )
.(a=>c) (b Ac) 1 1 0 1 0 0 0 0
0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1
0 0 1 1 1 1 0 1 L.H.S. R.H.S.
0 1 0 1 1 1 0 1 From the above table, we can see that both L.H.S.
0 1 1 1 1 1 1 1 and R.H.S. possess same truth values. So, it is a
1 0 0 0 0 0 0 0 valid proposition.
Q. 6. State whether the following expression is a tautology or contradiction with the help of truth table.
[ISC 2010]
(X » Z ) • [(X => Y) • (Y => Z)1
Ans. For the above equation, we have three inputs for truth table, i.e., X, Y and Z.
Truth table for given expression is
X Y Z X => Y Y => Z (X => Y) • (Y => Z) X«Z (X <=> Z) • [(X => Y) • (Y => Z) ]
0 0 0 1 1 1 1 1
0 0 1 1 1 1 0 0
0 1 0 1 0 0 1 0
0 1 1 1 1 1 0 0
1 0 0 0 1 0 0 0
1 0 1 0 1 0 1 0
1 1 0 1 0 0 0 0
1 1 1 1 1 1 1 1
From the above truth table, we can clearly see that all the values of last column are neither all l 's nor 0's. Hence,
the given expression is neither tautology nor contradiction.
Revision Notes
> Boolean Algebra is an algebra given by George Boolean which uses 0 and 1 as binary variables, and three basic
operations OR, AND and NOT.
> Laws of Boolean Algebra
S. No. Theorem /Laws Expression Dual
1. Identity law A+0 =A A 1=A
•
> Principle of Duality: It states that a Boolean relation can be obtained by changing OR by AND and Vice-versa.
For example,
(i) Dual of X + Y • Z is X • (Y + Z).
-
(ii) Dual of O is always 1 and Vice versa.
I BOOLEAN ALGEBRA 13
|Key Terms
> Basic Postulates:
A+0=0+A=A 0 + l = l;a + 0 = 0
A.l = 1 A A = A 0 A1 = 0 ;1 + 1 = 1
A + A = A; A.A = A
A + A- = 1; A.A = 0
(A) = A
> De Morgan's Theorem: The complement of the sum of variables is equal to the product of the complement of the
variables.
> (A + B) = A . B or (A . B) = A + B
Ans. Simplify :
[(X ' + Y) -(Y ' + Z)]' + (X ' + Z)
= (X ' + Y) ' + (Y' + Z) ' + ( X' + Z)
= XY' + YZ' + X ' + Z
w
I Answering Tip
Students should learn to find out the principle of
duality in the order of their precedence.
= X ' + XY' + Z + YZ'
= (X ' + X)- (X ' + Y') + (Y + Z)-(Z + Z') Q. 9. State Associative law and prove it with the help of
= X' + Y' + Z + Y a truth table.[ISC, Specimen Question Paper 2016]
= 1 as ( Y + Y' = 1) Ans. Associative law states that
[ISC Marking Scheme 2020] i.e., X + (Y + Z) = (X + Y) + Z
Q. 5. State the principle of Duality. [ISC 2017] Truth table for X + (Y + Z) = (X + Y) + Z
Ans. Principle of duality states: X Y Z Y + Z X + Y X + ( Y + Z ) ( X + Y) + Z
(1) Change all 0's to l's and l's to 0's. 0 0 0 0 0 0 0
0 0 1 1 0 1 1
(2) Change all to ' + ' and ' +' to
0 1 0 1 1 1 1
Q. 6. Find the complement of the following Boolean 0 1 1 1 1 1 1
expression using De Morgan's law. [ISC 2017] 1 0 0 0 1 1 1
F(a, b, c ) = (b + c) + a
' 1 0 1 1 1 1 1
Ans. ((b' + c) + a)' = (b' + c)' • a' 1 1 0 1 1 1 1
1 1 1 1 1 1 1
= b • d a'
Both the columns X + (Y + Z) and (X + Y) + Z are
Q. 7. State involution law and prove it with the help of
identical.
a truth table. [ISC 2016]
Ans. Involution Law states that the double complement of Q. 10. Find the dual for the Boolean equation:
a variable returns the same variable, i.e., AB ' + BC' + 1 = 1
(A') ' = A [ISC, Specimen Question Paper 2016]
Truth Table Q. 11. Minimise F = XY + (XZ ) ' + XY 'Z using Boolean
A A '
(A )' ' laws. [ISC, Specimen Question Paper 2016]
0 1 0 Ans. F = XY + (XZ) ' + XY 'Z
1 0 1 = XY(Z + Z ') + (XZ) ' + XY 'Z
[ISC Marking Scheme, 2016] = XYZ + XYZ ' + (XZ) ' + XY 'Z
= XYZ + XY 'Z + XYZ ' + (XZ) '
Examiner's Comment = XZ(Y + Y ') + XYZ ' + (XZ) '
= XZ + (XZ) ' + XYZ '
w This part was well answered by most of the [ •• (Y + Y ') = 1]
candidates. Some candidates mentioned laws = 1 + XYZ ' [ v (XZ + XZ ) = 1]
involving complementation. Others proved by F =1 [ •.• 1 + XYZ ' = 1]
laws instead of truth table. Some drew truth table Q. 12. Simplify ( A + C)(A + A - D) + A - C + C
of 2 variables. [ISC 2015]
Q. 8. Find the dual o f Y - X + X ' + l = l [ISC 2016] Ans. (A + C) (A + AD) + AC + C
Ans. (Y + X) • X ' •
0=0 (A + C)A + AC + C
[ISC Marking Scheme, 2016] A + AC + AC + C
A+C [ISC Marking Scheme, 2015]
Examiner's Comment
Examiner's Comment
w This was well attempted by most candidates. A
few candidates did not put brackets in the dual w Most of the candidates answered well. Some
equation Some changed the complement also, reduced the expression in one step without
showing the working. In a few cases, the laws
which was not required. O's and l's were not
were used incorrectly. Some candidates were
interchanged in some cases. unable to open the brackets in the expression.
These questions are for practice and their solutions are available at the end of the chapter
16 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Distributive law:
I
Answering Tip A + B • C = (A + B) • (A + C)
w
Examiner's Comment
A number of candidates proved both the laws of
De Morgan.
A few candidates mentioned some other law.
n w
Examiner's Comment
Some candidates were not clear with the
POS form of expression and wrote the SOP
expression. Actual meaning and features of
Some wrote 'Break the line and change the sign'
canonical expression were not clear to many
which is not the law, but a way to remember the
candidates.
law.
Q. 16. State the principle of duality. Write the dual of
Answering Tip - -
(P + Q ') R 1 = P R + Q ' R - [ISC 2013]
Ans. Principle of duality states that starting with a
w All the laws of Boolean algebra must be practiced Boolean relation another Boolean relation can be
and proved with the help of truth table. derived by
(1) Change all 0’s to l’s and l’s to 0’s.
Q. 14. Verify the following expression using Boolean (2) Change all to ' + ' and ' + ' to
laws. Also, mention the law used at each step of Dual of (P + R • 1 = P • R + Q' R
Q) ' • -
simplification. [ISC 2015]
=> (P • Q') + R + 0 = (P + R) • (Q ' + R)
-
- - - -
X Y Z + X Y' Z + X Y Z ' = X - (Y + Z ) Q. 17. Minimize the expression using Boolean laws.
Ans. X - Y - Z + X - Y - Z + X - Y - Z
' '
F = (A + B ) • (B + CD) ' [ISC 2013]
= X • (Y + Z)
L.H.S. = X - Y - Z + X Y' - Z + X - Y - Z '
Ans. F = (A + B )- (B + CD)
' '
0 1 0 1 1 1 1
= x ' y ' (z '
+ z ) + x '
y (z + z' ) 4- xy' z
= x y (l ) 4- x y( l ) 4- xy z
' ' ' '
0 1 1 1 1 1 1
(by complement law)
1 0 0 1 1 0 1
= x y + x y 4- xy z
' ' ' '
0 0 0 0 0 0 0 1 1 1 0 0 0 0
1 0 0 0 0 0 0 0
0 1 0 1 0 0
1 0 1 1 0 1 1 1
1 0 0 1 1 1
1 1 0 1 1 0 1 1
1 1 1 1 1 1
1 1 1 1 1 1 1 1
Q . 22. If X = A BC + AB C + ABC 4- A BC', then find
the value of X, when A = 1, B = 0 and C = 1. L.H.S. R.H.S.
[ISC 2010] From the above table, L.H.S. = R.H.S.
Ans. A = 1 => A = 1 = 0
' ' - -
x (y + z ) = x y + x - z
B = 0 => B ' = 0 ' = 1 The law stated in the given expression is called
C = 1 => C ' = 1' = 0 distributive law.
These questions are for practice and their solutions are available at the end of the chapter
18 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Q. 26. Given F = A + (B + C)-(D' + E) = x ' + (y " + z ") - (y ' + z ')
I
Find F ' and show the relevant working in steps. (by demorgan law)
[ISC 2009] F = -
x ' + (y + z) (y ' + z ')
Ans. Given function is, (by involution law)
F = A + (B + C) (D ' + E) - Q. 30. Simplify the following Boolean expression using
We need to find the complement of F, i.e., F '. laws of Boolean algebra. At each step, state clearly
First of all, we will simplify F the law used for simplification. |§|[ISC 2007]
F = A + (B + C) (D ' + E) - F = x-y(x-y + yz)
F = (A + B + C) (A + D ' + E) - Q. 31. State the DeMorgan's laws. Verify any one of
(by distributive law) them using the truth table. [ISC 2007]
Now, complement of F, Ans. DeMorgan's laws state that,
(F ') = [(A + B + C) (A + D ' + E)] ' - (i) Law 1: The complement of sum of literals is
= (A + B + C) ' + (A + D ' + E) ' equal to the product of individual complement
(by demorgan’s law) of literals, i.e., (x + y) ' = x ' y ' -
= A 'B 'C '
+ 'D "E '
A (ii) Law 2: The complement of product of literals
(by demorgan’s law) is equal to the sum of individual complement
= A 'B 'C '
+ A 'DE ' -
of literals, i.e., (x y) ' = x ' + y '
(by involution law) Now, we will verify the law 1 using the truth table
F = A B C + A DE '
' ' ' ' ' as:
Q . 27. Simplify the following Boolean expression and
(x + y) ' = x' y' -
state clearly the laws used for the simplification x y x + y (* + yr
.
x' yl x ' y ' -
at each step. o 0 0 1 1 1 1
xy + xz + xyz [ISC 2008] 0 1 1 0 1 0 0
Ans. Given Boolean expression is, 1 0 1 0 0 1 0
F = xy + xz + xyz = xy + xyz + xz 1 1 1 0 0 0 0
= xy(l + z) + xz (by absorption law) L.H.S. R.H.S.
= xy(l) + xz (by basic postulates) From the above table, it is verified that,
= xy + xz L.H.S. = R.H.S.
F = x(y + z) (by distributive law) Q. 32. Find the complement of
Q. 28. State the two complement properties of Boolean -
F(a, b, c, d) = [a + { (b + c) (b ' + d ' ) }] [ISC 2007]
algebra. Verify any one of them using the truth Ans. Given function is,
table. [ISC 2008]
Ans. According to the complement properties of
F(a, b, c, d) = [a + {(b + c) (b ' + d ')}] -
On applying demorgan's theorem,
Boolean algebra, (i) x + x ' = 1 (ii) x x ' = 0 - -
F ' = a ' {(b + c) (b ' + d ')}' -
Now, will verify the complement law using truth
table as:
-
= a ' {(b + c) ' + (b ' + d ') '}
(by demorgan's law)
X x' x + x' - -
= a (b c + b " d ")
' ' '
-
0 1 1 (by demorgan's law)
- -
Q. 34. Simplify a b + a ' c + b c using the laws of - 0 1 0 1 0 0 0 0
Boolean algebra. At each step, state clearly the 0 1 1 1 0 0 0 0
law used for simplification. [ISC 2006]
1 0 0 0 0 0 0 0
Ans. Given expression is,
1 0 1 1 1 0 1 1
F = a b + a' c + b c - - -
F = b(a + c) + a ' c (by distributive law) - 1 1 0 1 1 1 0 1
--
= a' b a + a' b c + b c a + b c c -- -- -- 1 1 1 1 1 1 1 1
(by distributive law) L.H.S. R.H.S.
--
= a' a b + a' b c + a b c + b c -- -- - So, it is verified from the truth table that
,
(by idempotence law) - -
x (y + z) = x y + x z. -
-
= 0 b + a' b c + a b c + b c -- -- - Q.36. What is the application of Boolean Algebra in
(by zero property) computer science? [ISC 2005] #
= 0 + a' b c + a b c + b c -- -- - Q.37. Reduce the following expression to its simplest
(by zero property) form using laws of Boolean Algebra. At each step
--
= a b c + b c(a + 1) = a ' b c + b c 1
'
- -- -- clearly state the law used for simplification .
(by basic postulates) AB + ABC + AC + BC
= a' b c + b c -- - [ISC 2005]
= b c(a ' + 1) -(by basic postulates)
Ans. Given expression is,
= b c1 --
F = bc - ( . b c 1 = b c) -- - - - F = AB + ABC + AC + BC
. .
Q 35 State the distributive law. Verify it using the truth Now, we will simplify the given expression by
table. [ISC 2005] using Boolean laws as below:
Ans. The distribution law states that, F = AB + ABC + AC + BC
(i) x + yz = (x + y) (x + z) - = AB + ABC + A + C + BC
-
(ii) x (y + z) = x y + x z - - (by demorgan's law)
Now, we will verify the first law using truth table = AB + A + ABC + C + BC
as follows:
(by commutative law)
x + yz = (x + y) (x + z) - = AB + A(1 + BC) + C + BC
X y z yz x + yz x + y X + z ( x + y) ( x + z ) - (by distributive law)
0 0 0 0 0 0 0 0 = AB + A-l + C + BC
0 0 1 0 0 0 1 0 (by basic postulate)
0 1 0 0 0 1 0 0 = AB + A + C + BC (by identity law)
0 1 1 1 1 1 1 1 -
= [(A + A) (B + A)] + [(C + C) (C + B)] -
1 0 0 0 1 1 1 1 (by distributive law)
1 0 1 0 1 1 1 1 -
= 1 (B + A) + 1 ( + B)
C -
1 1 0 0 1 1 1 1 (by complement law)
These questions are for practice and their solutions are available at the end of the chapter
20 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class- XII
Ans. Given expression, = x' + z + 1
I
(z + x)(z + x + y) = (z + x)(z + y) = X ' + l (z + 1 = 1 )
Take L.H.S. = (z + x)(z + x + y) =1
= (z + x)(z + x) + (z + x)y (x ' + 1 = 1) = R.H.S.
(by distributive law) Q. 2. State the complement properties. Find the
= zz + zx + xz + xx + zy + xy complement of the following expression using
(by distributive law) DeMorgan's law: 0 [ISC 2006]
= z + zx + xz + xx + zy + xy AB + A + BC
'
= + + + ' - [a + a 'b = a + b]
x ' xy ' z yz = x '(y ' + y) + xy '
= x ' + y' + z + y = x '(l) + xy ' (by complement law)
= x ' + z + y' + y = x '
+ xy '
= (x '
+ x) • (x ' + y ')
These questions are for practice and their solutions are available at the end of the chapter
I = l -(x ' + y ') (by complement law)
BOOLEAN ALGEBRA
= A-[AB + AC + BBC + BCC]
21
= (x + y )
' '
(by distributive law)
L.H.S. = R.H.S. = A-[AB + AC] (by complement law)
Q. 5. (a) State the principle o£ duality. [ISC 2011] = AAB + AAC (by complement law)
Ans. Principle of duality states
=0
(1) Change all 0 's to l 's and l 's to 0 's.
Q. 8. State the dual form of the following expression
(2) Change all '-' to ' +' and ' +' to
Dual of (P + Q) ' • R • 1 = P - R + Q ' • R xy(xyz + x + xz) <§) [ISC 2005]
=> (P - Q ') + R + 0 = (P + R) (Q ' + R) - Long Answer Type
(b) Give the dual of the following: <©> Questions -I (5 marks each)
- -
(A ' B) + (C l) = (A ' + C) (B + C) -
Ans. (A + B) • (C + 0) = (A ' C) + (B C)
'
- - Q. 1. Reduce the Boolean expression to the simplest
Q. 6. Minimise the following expression. At each step forms.
state clearly the law used. (i) { (C- D)' + A} + A + (CD) + ( A- B )
Y = (A + B ) - ( B + CD) '
[ISC 2009]
'
(ii) A-{ B + C( A - B + A -C)'} [ISC 2011]
Ans. Given expression is, Ans. (i ) Given expression
Y = (A + B) (B + CD) ' - F = (C-D) ' + A + A + -
(C D) + (A- B)
= (A + B) B (C + D) -- (demorgan's law)
F = 1 + A + A + A -B
= (A + B)(BC + BD) (distributive law)
(by complementary law)
= ABC + ABD + B BC + B.BD -
= ABC + ABD + BC + BD (P P = P) - F = 1 + A + A- B (by unit property)
= ABC + BC + ABD + BD F = 1 + A- (l + B)
= BC(A +1) + BD(A +1) (P +1 = 1) F =1+ A (by absorption law)
= BC + BD F =1
= B(C + D) (ii) Given expression,
Q. 7. Reduce the following Boolean expression to the F = A-{B + C(A- B + A-C)'}
simplest form. => F = A-{B + C(A-B)'.(A-C)'}
A -[( B + C) - ( AB + AC)] [ISC 2008] (by demorgan's law)
Ans. Given Boolean expression, F = A-{B + C(A' + B')- (A' + C')}
F = A -[(B + C)- (AB + AC)] (by demogran's law)
= A -[(B + C)-(AB-AC)] F = A-{B + C(A'-A' + A'-C' + B'-A' + B'C')}
(by demogran's law) (by distributive law)
= A -[(B + C)- ((A + B)(A + C))] F = A-{B + C(A' + A'-C' + A'- B' + B'C')}
(by demogran's law) (by idempotent law)
= A -[(B + C)- (A-A + A-B + A- C + B- C)] F - - -
= A {B + A'C + A'C'C + A' B' C + B'-C'-C)}
(by distributive law) (by distributive law)
= A-[(B + C)- (A + AB + AC + BC)] F = A-{ B + A'-C + 0 + A' - B'-C + 0}
(by idempotent law) (by complementary law)
= - C) ( -
A [(B + (A 1+ B) + AC + BC)] F = A- B + A-A'-C + A'-A- B'-C
(by distributive law) (by distributive law)
= A-[(B + C)- (A + AC + BC)] F = A- B + 0 + 0 (by complementary law)
(by absorption law) F = A-B (by identity law)
= A-[(B + C)- (A + BC)] Q. 2. Verify if,
(by absorption law)
- - -
x y z+x y z+x y z+x y z - - -
= A-[(B + AC + BCC)]
= x-y + y-z + z-x
(by distributive law)
These questions are for practice and their solutions are available at the end of the chapter
22 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
At each step state the law used for simplification = (x - z + x)y + x - y - z
I
clearly. [ISC 2007] (by distributive law)
Ans. L.H.S. =x y z+x y z+x y z+x y z = (x + z)y + x y z ( v A + AB = A + B)
• •
I Topic- 3
Revision Notes
Forms of Representing Boolean Expressions
Conceptscovered: Minterms; Maxterms; SOPform; POSform;Canonicalforms
>
>
A Boolean expression results either true or false i.e., a Boolean value. It is also called as comparing expression,
conditional expression, and relational expression. In Boolean expression two important terms are Minterms and
Max terms.
A Boolean expression is an expression that results in either true or false. In Boolean expression, a single variable
—
or its complement is called literal.
> Minterms two or more literals joined by AND operator are known as minterms. For example, xy, x'y, x'y' and xy'
are minterms for two literals and x and y.
> Maxterm two or more literals jointed by or operator are known as maxterms. For examples, x + y, x' + y', x' + y
and x + y' are maxterms for two variables x and y.
Maxterm () Minterm
x y z
Term Symbol Term Symbol
x+y+z mo x'y'z' Mo
0
0
0
0
1
0 0
1
0
x + y + z'
x + y'+ z
m
m?
. x'y'z
x'yz'
Mi
ML
0 1 1 x + y' + z' mq x'yz ML
1 0 0 x' + y + z m4 xy'z' ML
1 0 1 x' + y + z' HU xy'z M
1 1 0 x'+ y' + z ms xyz' ML
1 1 1 x' + y' + z' m7 xyz M7
> Canonical Expression: A Boolean expression composed entirely of either minterms or maxterms.
> Sum-Of-Products (SOP) form: A Boolean expression represented purely as sum of minterms is said to be in SOP
form.
> Product Of Sum (POS) form: A Boolean expression represented purely as product of maxterms is said to be in
canonical POS form.
> Canonical SOP and POS Forms: When each term of a logic expression contains all variables, It is said to be in the
canonical form.
> Conversion from SOP Expression to Canonical SOP Expression:
The following procedure is used to convert SOP expression into canonical SOP expression
.
1 Check the missing variable in each term.
—
.
2 Perform AND operation with (e.g. with X + X if x is missing) terms, which have missing variables.
.
3 Expand all terms and remove the duplicate terms such that X + X = X o r X + X + X = X.
.
4 The produced SOP expression is the canonical SOP expression.
I> Conversion from POS Expression to Canonical POS Expression:
BOOLEAN ALGEBRA 23
The following procedure is used to convert POS expression into canonical POS expression
.
1 Check the missing variables in each term.
—
.
2 Perform Or operation with (e.g. with X X if x is missing) missing variables.
.
3 Expand all terms and remove the duplicate terms such that X X = X or X X X = X.
.
4 The produced POS expression is the canonical POS expression.
> Conversion from SOP Expression to Canonical POS Expression:
The following procedure is used to convert the SOP expression into canonical POS expression
. —
1 Check the given SOP expression is canonical SOP expression or not, if not then convert it into canonical SOP
expression. If it is already in canonical SOP expression then continue to step 2.
.
2 Use the duality theorem to convert SOP into canonical POS such that:
(i) Change every OR sign ( + ) to AND sign (•).
(ii) Change every AND sign (•) to OR sign ( + ).
(iii) Change normal variable (A) into complement variable (A) and vice versa.
.
3 The produced expression is the canonical POS expression.
> Conversion from POS Expression into Canonical SOP Expression:
The following procedure is used to convert POS expression into canonical SOP expression:
.
1 Check the given POS expression is canonical POS expression or not, if not then convert it into canonical POS
expression. If it is already in canonical POS expression then continue step 2.
.
2 Use the duality theorem to convert POS expression into canonical SOP expression such that:
(i) Change every OR sign ( + ) to AND sign (•).
(ii) Change every AND sign (•) to OR sign ( + ).
(iii) Change normal variable (A) into complement variable (A) and vice versa.
.
3 The produced expression is the canonical SOP expression.
|Key Terms
> -
Sum of Products (SOP): Sum of minterms is known as Sum Of Products (SOP) form. Example, xy' + x'y is a SOP
form.
> - -
Product of Sum (POS): Product of maxterms is known as Product Of Sums (POS) from. Example, (x + y) (x' + y)
is a POS form.
> Miniterm is a product of all literals and maxterm is a sum of literals.
> Canonical from: If an expression is represented in its maxterms or minterms.
> Cardinal form: If an expression is represented in its decimal equivalent of its terms.
\CD
_
F(A, B, C, D) = 2(0, 1, 2, 8, 10, 14)
__ G Graduate in any discipline
AB\ CD CD CD CD M Graduate in Mass Communication
AB. m o
T; •i
1 3 S
P Aggregate percentage of 75 and above
Record of Literary Skills
AB 4 5 7 6 (In all the above cases 1 indicates yes and 0
indicates no).
AB 12 13 15 ljl4
Output: X [1 indicates eligible and 0 indicates not
AB; 1 J: 8 9 11
J "
eligible for all cases].
10
I Draw the truth table for the inputs and outputs
BOOLEAN ALGEBRA 25
and other position produced 0. So SOP expression
given above and answer the following questions: will be the Option (A) is correct.
[ISC Sem-1 Paper 2021-22] Q. 12. What will be the complement of the above SOP
Q. 11. What will be the SOP expression for X(G,M,P,S)? expression?
(A) S(5,6,11,13,14,15) (A) 5(5,6,11/13,14,15)
(B ) P(5,6,11,13,14,15) (B ) P(5,6,11,13,14,15)
(C) S(0,1,2,3,4,7,8,9,10,12) (C) S(0,1,2,3,4,7,8,9,10,12)
(D) P(0,1,2,3,4,7,8,9,10,12) (D) P(0,1,2,3,4,7,8,9,10,12)
Ans. Option (A ) is correct. Ans. Option (D) is correct.
Explanation: After draw the truth table at the Explanation: After complementing the SOP
position of 5, 6, 11, 13, 14, 15 produced 1 as output expression it will produce POS expression for this
reason Option (d ) will be the correct option.
These questions are for practice and their solutions are available at the end of the chapter
26 Oswaal ISC Question Bank Chapterwise & TopLcwLse, COMPUTER SCIENCE, Class- XII
Q. 8. Convert the following cardinal form of expression
I
Examiner's Comment into its canonical form
F(P, Q, R) = P(l, 3) [ISC 2013]
w Almost all candidates answered this part correctly. Ans. Given expression is
Some candidates interchanged the maxterms with
the minterms. F(P Q, R) = P(l, 3)
It is clear that, the function F is in POS form and
contains two maxterm,
Answering Tip i.e., F(R Q, R) = MJ M3 -
To convert it into canonical form, we need to find
w Students should learn to device the maxterms the expression of the maxterm as:
and minterms from a given truth table. Their use P Q R Maxterm Expression
in expression must be explained to students.
0 0 0 Mo P+Q+R
0 0 1 Mj P + Q + R'
Q. 6. Convert the Boolean expression F(X, Y, Z ) = X'Y'Z
0 1 0 M2. P + Q' + R
+ X'YZ' + XYZ into its cardinal form.
0 1 1 M3. P + Q' + R'
ill
[ISC Specimen Question Paper 2016]
1 0 0 M4 P' + Q + R
Q. 7. Convert the following expression into its
1 0 1 M5 P' + Q + R'
canonical POS form.
1 1 0 Nk P' + Q' + R
F( A, B) = ( A + B ) A' [ISC 2014]
1 1 1 M7 P' + Q' + R'
Ans. (A + B ) A ' From the above table,
(A + B ) (A ' + B.B1) -
F = MJ M3
(A + B ) (A ' + B) (A1 + B') F = (P + Q + R')-(P + Q' + R')
[ISC Marking Scheme, 2014] -
Q. 9. Given F(x, y, z) = (x' + y') (y + z')
Detailed Answer: Write the function in canonical product of sum
Given expression is, form [ISC 2012]
F(A, B) = (A + B) A' Ans. Given function is,
As we know, in given expression there must be
two maxterms but in one term a variable is missing
-
F(x, y, z) = (x' + y') (y + z')
like, = (x' + y' + 0)-(0 + y + z')
F(A, B) = (A + B) A' -
= (x' + y' + zz ') (xx ' + y + z')
(by complement law)
Maxterm
F(A, B) = (A + B) (A' + (BB'))
, , ' '
-
F(x y z) = (x + y + z) (x' + y' + z' )
•(x + y + z ' )-(x' + y + z ')
(BB' = 0, complementary law) (by distributive law)
= + B) (A' + B) (A' + B')
(A
Q . 10. If A = 1 B =
, 0, C =1 and D = 1, find its
(distributive law)
The canonical POS form is, (i) Maxterm
F(A, B) = (A + B) (A' + B) (A' + B') (ii) Minterm [ISC 2011]
Ans. (i) The maxterm corresponding to the given
value of the variables will be:
Examiner's Comment = A+ B+C + D
(ii) The minterm corresponding to the given
w Some candidates were not familiar with the
values of the variables will be:
SOP expression. Actual meaning and features
of canonical expression were not clear to many = ABCD
candidates. Q. 11. Convert the following function into its canonical
sum of product form
F(x, y, z) = S (0, 1, 5, 7) [ISC 2010]
Answering Tip Ans. Given function is,
F(x, y, z) = (0, 1, 5, 7)
w Do more practice for solving SOP and POS type of So, the canonical form, of function F will be:
Boolean expression. Both canonical and cardinal F = m0 + m1+ m5+ m7
forms should be practical.
= 000 + 001 + 101 + 111
So, F(x, y, z) = x'y'z + x'y'z + xy'z + xyz
These questions are for practice and their solutions are available at the end of the chapter
I
Q. 12. For the given truth table where A, B, C are inputs 0 1 1 m3 ovw
BOOLEAN ALGEBRA
M3 o+v+w
27
1 0 0 1
= S (0, 1, 3, 5)
Now, it is known that the complement of a
1 0 1 0 minterm is equal to its corresponding maxterm
1 1 0 1 F = M2.M4.M6.M7
1 1 1 0 So, the canonical POS form of F is,
Write,
-
D = (o + v + w) - (o + v + w) - (o + v + w) (o + v + w)
1
Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
00 0 M4 A + B+C = (L.U + M + P) -
( .. A. A'
I
= 0)
1 01 1 Ms. A + B+C = (0 + M + P) (by complement law)
1 1 0 1 Me A + B+C
F = (M + P) (by identity law)
This is the simplified form of F.
1 1 1 0 M7 A + B+C
To find the POS form for F, we need to find Q. 2. What are maxterms? Convert the following
maxterms for which the value of F is 0 and these function as a product of maxterms.
are Mj, M2, M4 and M7. F(P, Q, R) = (P + Q). (P' + R') 0 [ISC 2010]
So, F = Mj. M2. M4. M7 Q. 3. Simplify the following expression and convert it
F = (A + B + C).(A + B + C).(A + B + C).(A + B + C) to its canonical POS form.
Q.18. What is the canonical form of Boolean expression? ((x.y ) + z). (y + (z\ x) ) [ISC 2009]
State the two types of canonical forms. [ISC 2005] Ans. Given expression is,
Ans. A Boolean expression is in canonical form when it F = (x. y + z) (y + z'. x)
is composed entirely of Minterms and Maxterms.
F = (x + z). (y + z). (y + z'). (y + x)
There are two types of canonical forms: (by distributive law)
(i) Canonical SOP expression = (x + z). (y + z). (y + z'). (x + y)
(ii) Canonical POS expression (by communicative law)
Now, we will convert F into canonical form,
Answer Type
<&\ Short
Questions-II (4 marks each)
F = (x + 0 + z).(0 + y + z).(0 + y + z').(x + y + 0)
(z + yy' + z).(xx' + y + z)(xx' + y + z')(x + y + zz')
Q. 1. Convert the following cardinal expression into its (by distributive law)
canonical form and reduce it using Boolean laws. F = (x + y + z).(x + y' + z).(x + y + z)(x’ + y + z)
F (L, M, O, P) = P (0, 2, 8, 10) (x + y + z').(x' + y + z')(x + y + z)(x + y + z')
[ISC 2011] (by complement law)
Ans. Given function is, = (x + y + z).(x + y + z).(x + y + z).(x + y' + z).
F(L, M, O, P) = P (0, 2, 8, 10) (x' + y + z).(x' + y + z').(x + y + z').(x + y + z')
It is clear that the function F is in POS form and F = (x + y + z).(x + y' + z).(x' + y + z).(x' + y + z')
contain the maxterm 0, 2, 8 and 10. •(x + y + z')
I TopiC-4
Revision Notes
Karnaugh Map (K-map)
Conceptscovered:KamaughmapiRedudngabooleanexpressionintoitscanomcal
form using K-map
> Karnaugh Map (K-map) Method: It is a most popular method for simplification of Boolean expressions of two
variables, 3-variables, 4-variables and so on. It is a graphical display of the fundamental products in a truth table.
It is a rectangle made up of certain number of squares, each square representing a maxterm or minterm.
These questions are for practice and their solutions are available at the end of the chapter
I Representation of K-maps:
BOOLEAN ALGEBRA 29
, vB B B BCBC BC BC BC
A \ Q 1 A \ 00 01 11 10
A A 0
° o 2 0 1 3 2
A 1 A 1
2 3 4 5 7 6
2-VariablesK-map 3-Variables -map
K
CD CD CD CD
AB \ op pi ii ip
AB 0
°
AB 01
0 l 3 2
4 5 7 6
AB 11
12 13 15 14
AB 10
8 9 11 10
4-Variables K-map
> -
Possible combinations 2n cells for n variables:
— -
2 variables K-map (4 cells): AB, AB, AB, AB.
— -
3 variables K-map (8 cells): ABC, ABC, ABC, ABC, ABC, BC, ABC, ABC
>
—- -
4 variables K-map (16 cells): Take combination as shown in the k-map
K map Simplification Rules: K-map uses the following rules for the simplification of expressions by grouping
expressions together in the form of Octet, Quad and Pair.
Some rules are as follows:
• Groups must contain 1, 2, 4, 8, or in general 2n cells.
• That is if n = 1, a group will contain two l's since 21 = 2.
A
B 1
0 •' 1 1 Group of 2
1 0 0
• Groups may not include any cell containing a zero It means we cannot make a pair of 0 and 1
. .
• Groups may be vertical or horizontal, but not diagonal
B B
.
A \ B B A \ B B
A o i/ n'
'
A m I
A 7T A o:M
Incorrect Pattern Correct Pattern
• Each groups should be as large as possible i.e., Octet
(8 adjacent l's), Quad (4 adjacent l's) and pair (2 adjacent l's)
OC r. 'D. J
Incorrect Pattern Correct Pattern
• Groups may overlap as shown above in the correct pattern.
• - -
In a K map, first find out all possible Octet group, then Quad group and at the end make pairs. Then you will
found the optimal solution or simplest form of given expression.
30
•
Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE Class-XII
Each group should be as large as possible.
. I
A
BN BO 01 11 10
0 1 1 1 1
1 1 1
[10] AB 0 0 0 0
8 9 11 10
= B'
..
Q 1 Given the Boolean function:
,
Octet2 (m0 + m + m 4 + m 5 + m8 + m 9 + m12 + m13)
F(A, B, C, D)
= 2 (0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13,14). = C'
Reduce the above expression by using 4 variable - Quad (m8 + m10 + m12 + m14) = AD'
Karnaugh map, showing the various groups (i.e.
Hence, F (A, B, C, D) = B' + C' + AD'
octal, quads and pairs). [ISC 2020]
[ISC Marking Scheme, 2020]
Ans.
Q. 2. Given the Boolean function:
CD' C'D CD CD'
= 7t( 3, 4, 6, 9, 11, 12, 13, 14, 15 ).
F( A, B, C, D)
0 -t 3 2 Reduce the above expression by using 4-variable
A'B' 1 1 1 1 Karnaugh map, showing the various groups (i.e.
A'B
4
1
5
1
7
0
6
0
octal, quads and pairs). [ISC 2020] < ) ®
Q. 3. Minimise the following Boolean expression using
12L 13 15 14 the Karnaugh map.
AB 1 1 0 1
9 11 10
F( A,B,C) = ABC + ABC + ABC + ABC
8 [ISC 2014]
AB’ 1 1 1 1
These questions are for practice and their solutions are available at the end of the chapter
32 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE Class-XII . I
Ans. \BC BC BC BC BC
B'C' B'C BC BC' As|
Quad-1
A'
0 1 T 2 A 1
0 0 1 1
0 1 3 2
4 5 7 6
A 0 0 1 1
A 1 1
[ISC Marking Scheme, 2014] 4 5 7 6
Quad. 1 = m2 + m3 + m6 + m7 = B
So, minimised Boolean expression is:
Examiner's Comment F(A, B, C) = B
Q. 4. Reduce the following expression,
w Almost all candidates answered this part correctly
F(A, B, C) = S (0, 1, 2, 3, 4, 5, 6, 7)
except for a few who did not use the K map for - Also, find the complement of the reduced
reducing but used the laws instead K map plotting - expression. [ISC 2011]
was not correct in some cases. Ans. Given expression is,
F(A, B, C) = S(0, 1, 2, 3, 4, 5, 6, 7)
-
Now, draw the K map according to the given
Answering Tip minterms
BC
A BC BC BC BC
w Do practice in minimizing Boolean expressions 0 1 3 2
- -
using k maps. 3 variable k maps should also be A I 1 1 1
1 Octet
practiced for short answers. 3
4 5 7 6
A 1 I
Detailed Answer: 1 1
7
Given expression is,
F(A,B,C) = ABC + ABC + ABC + ABC
In a three variables K map octet means given -
function will produce output 1, i.e., tautology,
Here, we have three inputs A, B and C. So, while i.e., F (A, B, C) = 1
-
draw the K map, we need 2" = 23= 8 squares. the complement of F, i.e.,
F = 1' = 0
..
Q 5 Reduce the following three input function into its
simplest form .
-
F(x, y, z) = S (0, 1, 3, 5) [ISC 2006] #
These questions are for practice and their solutions are available at the end of the chapter
I BOOLEAN ALGEBRA
(P' + Q ' + R)
(bar) means Now, we can see that X = Y, hence the dual of
4 Marks Questions expression P 'QR ' + PQ 'R + P 'Q 'R is equal to
.
4 Contingency: The propositions that have some the complement of PQ 'R + Q (P 'R ' + PR ').
combination of 0's and l's in their truth table .
30 Given boolean expression is
column are called contingency. - -
F = x y(x y + y z) -
Contradiction: The propositions having only 0's in - - - -
= (x y)(x y) + (x y)(y z)
their truth table column are called contradiction. (by distributive law)
Tautology: The propositions having only l's in
their truth table column are called tautologies.
- - -
= (x y) + (x y)(y z) (by idempotent
law)
TOPIC- 2 F = xy - (by absorption law)
36. Boolean algebra plays a vital role in computer
2 Marks Questions
science for designing logic circuits and simplifying
.
3 Find the dual of : circuits. In boolean algebra, the variable can take
(A ' + 0) • (B ' + 1) = A' only two variables, i.e., either true (1) or false (0)
and hence, it is compatible with binary arithmetic
Dual = A' * 1 + B' * 0 = A' used in simplifying the designing of computer
[ISC Marking Scheme, 2020] hardware.
.
10 Boolean equation 4 Marks Questions
L.H.S. = AB ' + BC ' + 1 .
2 Complement properties:
On applying the duality A + A ' = 1 and A A ' = 0 -
= (A + B') • (B + C ') 0 - Complement of AB ' + A ' + BC
= (A + B') 0 = 0 - = (AB ' + A ' + BC) '
On applying the duality -
= (AB ') ' (A ') ' (BC) ' -
R.H.S. = 0 = (A ' + B)-A (B ' + C ') -
L.H.S. = R.H.S.
.
8 Given that,
-
F = xy (xyz + x + xz)
15. (XY 'Z + XY + YZ ') Dual of F = (x + y) + (x + y + z)-(x)-(x + z)
(X ' + Y + Z ') • (X ' + Y ') • (Y ' + Z) = (x + y) + (x + y + z)-(xx + xz)
or (X ' + Y + Z ') • (Y ' + X 'Z) (by distributive law)
[ISC Marking Scheme, 2014] = (x + y) + (x + y + z)-(0 + xz)
(by complement law)
34 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
(x + y) + (x + y + z)-xz .
I
=
_ _ _Jby identity law) 5 Given that
F(A, B, C) = n(2, 3, 4, 7)
= (x + y) + (xxz + xyz + xzz) F = 71(0, 1, 5, 6)
_ _ (by distributive law) = M0 My M5, M6
/
_ ^_
F = (F')' = (Mo. M y M5. M6)'
= -
(x + y) + (xz + xyz + x 0)
F = Mo'. M' j. M'5. M'6
_ (by complement law)
It is known that the complement of a maxterm is
= (x + y) + (xz + xyz + 0)
equal to its corresponding minterm.
(by basic postulates)
F = m0 + mj + m5+ m6
= (x + y) + (xz + xyz)
F = 2(0, 1, 5, 6) Hence proved.
(by identity law)
F = x + y + xz (by absorption law)
TOPIC-4
TOPIC-3 2 Marks Questions
2 Marks Questions
.
3 Now A. A = 0, similarly, C.C' = 0 2.
so, (B + C') = (B + C' + A.A) C+D C + D1 C + D’ C+ D
= (B + C' + A) (B + C' + A1) 0 1
[Treating B + C' as a single variable] 3 2
A +B 1 1 0 1
and (A' + B) = (A' + B + C.C')
= (A' + B + C)(A' + B + C') + 5 7 6
[Treating A' + B as a single variable]
A + B' 0 1 1 0
F (A, B, C) = (B + C').(A' + B) 12 13 15 14
A' + B’ 0 0 0 0
= (B + C' + A)(B + C' + A')(A' + B + C)
(A' + B + C') 8 9 11 10
= (B + C' + A)(A' + B + C')(A' + B + C) A' + B 1 0 0 1
[(B + C' + A')(A' + B + C) = (A' + B + C')]
.
6 Given expression, There are two quads and one pair:
F(X, Y, Z) = X'Y'Z + X'YZ' + XYZ Quad 1: (M4M6M12M14) = B' + D
= 001 + 101 + 111 Quad 2: ( M9M11M13M15) = A' + D'
(putting 0 for complements and 1 for the terms)
Pair: (M3Mn) = B + C' + D'
= m| + m2 + m7
(converting each of these to decimal equivalents) Hence F(A, B, C, D) = (B' + D) • (A' + D')
F in cardinal form, • ( B + C' + D' )
F(X, Y, Z) = S(l, 2, 7) [ISC Marking Scheme, 2020]
.
13 Given function is, .
5 Given expression is,
F (x, y, z) = 11(2, 4, 6, 7) F (x, y, z) = S(0, 1, 3, 5)
As we knew, SOP and POS both are complement i.e., F = m0 + nri] + m3 + m5
to each other. As we know,
Hence, sum of product of F(x, y, z) m0 = x'y'z'
= complement of P (2,4,6,7) mi = x'y'z
i.e., = S(0, 1, 3, 5) m3 = x'yz
4 Marks Questions m5 = xy'z
.
2 Maxterms: It is the sum of all literals within the F = x'y'z' + x'y'z + x'yz + xy'z
yz
logic system. yz yz yz yz
X
Given function is,
F(P Q, R) = (P + Q).(P' + R')
To convert the function F into product of X 1
0
in 1 3 3 2
maxterms, we need to add missing variable in
these terms as,
F(P Q, R) = (P + Q).(P' + R') X 1
= (P + Q + 0).(P' + 0 + R') 4 5 7 6
= (P + Q + RR').(P' + QQ' + R')
(by complement law)
Pair 1 = xy
= ( P + Q + R ).(P + Q + R') Pair 2 = xz
, (P' + Q + R').(P' + Q' + R')
Pair 3 = yz
(by distributive law)
-
. . F(R Q, R) = Mo . Mj . M5 . M7 So reduced expression will be x'y' + x'z + y'z.
,
I
SELF ASSESSMENT PAPER 1 -
Maximum Marks: 25 Timing: 1 Hour
.
1 What is a proposition? [1]
2. Find minterm designation of xyz. [1]
3. Find maxterm designation of ( u' + v' + w) [1]
4. Find the dual of following:
(a + b) (b + c) (a + c) [1]
.
5 What are different types of connectives used in propositional logic? [2]
6. Prepare truth table for the following algebraic expression.
xy + x'y' + xz [2]
. = (a + b) (c' + a') (b + d ) Find F'.
7 If F ; [2]
8. Convert (x + z)(z + y) into conical pos form. [2]
9. Draw the truth table for a boolean function F defined on three input variables X, Y and Z such that the output is
1 if and only if number of 1 inputs is odd. Also express canonical sum of product form. [2]
.
12 Given: X (A, B, C, D) = 7t(0, 2, 6, 8, 10, 14). Use k-map to reduce this function X using the given POS form. [5]
n
COMPUTER
HARDWARE
-
Iuggp (a ) Elementary logic gates (NOT, AND, OR, NAND, NOR, XOR, XNOR)
and their use in circuits, ( b ) Applications of Boolean algebra and logic
gates to half adders, full adders, encoders, decoders, multiplexers, NAND,
NOR as universal gates.
I
Logic Gates Topic- 1
. Concepts covered: AND, OR , Not logic
TopiC-1 gates; Universal logic gates; XOR , XNOR
Logic Gates
.
Page No 36
gates; Realisation of logic gates using
Topic-2
universal gates.
Designing Simple Logic
Circuits
.
Page No 48
Topic- 3
Revision Notes
Combinational Circuits
. .
Page No 70
> A logic gate is an electronic circuit which operates on one or more signals
to produce an output signal.
> Every logic gate produces signals in the form of 0 and 1. If any gate acts as a open circuit, output for the given
inputs are not produced.
• types of Logic Gates:
The logic gates represent electronic circuits in Boolean algebra. There are two types of logic gates namely:
1. Fundamental or Elementary Logic Gates
2. Universal Gates
1. Fundamental Logic Gates: AND, OR and NOT gates are called fundamental logic gates.
(i) AND Gate: This logic gate contains at least two inputs and one output. It will give output when all
inputs are enabled in the form of 1.
A B X = A.B
0 0 0
P
^JAND ) X = A.B 0
1
1
1
0
1
0
0
1
(ii) OR Gate: This logic gate contain at least two inputs and single output. It enables or gives output if any
one of the inputs are enabled in the form of 1.
A B X =A+B
0 0 0
A
B
X = A+B 0 1 1
1 0 1
1 1 1
,
^3
A
>A©B = AB + AB
A B A©B
0 0 0
0 1 1
£agic Qatea
1 0 1
1 1 0
Universal Gates
AOB = AB + AB
A B AOB
0 0 1
0 1 0
1 0 0
NAND
1 1
I
Combining the different gates
in a circuit
I
CO
00
Truth Table
9
y Sum Carry
I
txf Mux.
-.
e% o o 0
o n
0f two bits l l
a
(D
in
Truth Table
Sl So Y
§
CD
0 CD
A"
0 n
l
Io
1
Ii
Truth Table I
12 y z Sum Carry £
13 0 0 0 0
s?
0 1 1 0
o '
1
1
0
1
1
0
0
1
*sI
0
0
0
1
1
0
0
1 s2
1 0 0 1
1 1 1 1
2
30
Rm
Sum Z
xffiy® z n
Truth Table
Carry n
D2 Dl Do ST
x.y + z(x ®y)
0 0 1
0 0 1
0
1
1 0
o o 0
0
1 1
Truth Table
x y. Do Dl
{ >
* O— D -
o
0
1
l
o
0
l
[ 0
0
I
JL
o
1
1.
0
l
0
1.
1
D D‘ —
Trace the Mind Map
First Level Second Level ^
Third Level Logic diagra*1 .
^
I COMPUTER HARDWARE
(iii) NOT Gate: It has only single input and single output. It acts as inverter.
39
A A
A or A'
0 1
1 0
2. Universal Gates: NAND and NOR gates are known as universal gates. With the help of these gates all
fundamental gates can be created.
(i) NAND Gate: It is a universal logic gate. It is the combination of NOT and AND gate. All possible
outputs in NAND Gate is opposite of the outputs of AND gate.
A B X
0 0 1
A — NAND, X = (A . B)'
0 1 1
B — 1 0 1
1 1 0
(ii) NOR Gate: It is also a universal logic gate. It is combination of NOT gate and OR gate. All possible
outputs in NOR gate is opposite of the outputs of OR gate.
A B X
0 0 1
A X = (A + B)'
INOR ] 0 1 0
B
1 0 0
1 1 0
• Others Specific Logic Gates:
. -
1 Exclusive OR (X OR) Gate: It is a digital logic gate that gives a True (1) output when the number of True
inputs is odd.
X-OR gates are used to implement binary addition in computer. The algebraic notation used to represent
the XOR operation is X = A ® B
A B X
0 0 0
A X= A©B
|X OR 0 1 1
B or
X = A'B + AB’ 1 0 1
1 1 0
2. -
Exclusive NOR Gate: It is combination of Not gate and XOR gate. It is the logical complement of the XOR
gate. It gives a True (1) output when all of its inputs are True (1 or High) or when all of its inputs are false
(0 or Low). The algebraic notation used to represent the XNOR operation is S = A © B
A B X
0 0 1
A X = AOB
XNOR) or 0 1 0
B
X = A'B' + AB 1 0 0
1 1 1
• Realisation of Logic Gates using NAND Gate:
OR Gate
• Realisation of Logic Gates using NOR Gate: r
r
A'
A
(A + B)'
A X = (A + B)
B
OR Gate
|Key Terms
> Elementary Logic Gates are NOT, AND, OR Gates
> Universal Gates are NAND gate and NOR gate because with the help of these gates, fundamental/elementary
gates can be created.
> AND Gate: Two inputs (at least) and one output is required for AND gate. If both inputs are true (1), then output
will be true, otherwise false (0).
> OR Gate: At least two inputs and single output is required for OR gate. It is represented by ' + ' symbol in logical
expressions when any input out of the given inputs in True (1), then output will be True (1), otherwise False (0).
>
> NAND Gate: Complement of AND gate values is termed as NAND gate. It is also called universal gate.
—
NOT Gate: It acts as inverter. If input is True (1), then output is False (0) and vice-versa. It is shown by ' ' or ' ' '.
..
Q 4 From the logic circuit diagram given below, find
output 'F' and simplify it. Also, state the law
(i) Name the basic gate which is represented by the represented by the logic diagram. [ISC 2014]
diagram. [ISC, 2020] Q<
Ans. OR gate [ISC Marking Scheme, 2020]
(ii) What will be the value of X when A =1 and B = 0?
Ans. 1 [ISC Marking Scheme, 2020]
..
Q 2 Draw the logic circuit of a NAND gate using R
NOR gates only. [ISC, 2016]
Ans. ( P + Q ) ( P + R ) = P + Q.R Distributive Law
[ISC Marking Scheme, 2014]
Examiner's Comment
w Some candidates were not clear about the circuit i
and drew vague diagrams, but using NOR gates. ]
B w
Examiner's Comment
This part was well answered by most of the
candidates. Some candidates did not mention
Answering Tip the law, but wrote the expression correctly. Some
wrote only the intermediate expression.
w Logic gates and logic circuits must be practiced
with almost every expression, especially with
universal gates. Answering Tip
..
Q 3 Draw a logic circuit for (A + B ) (C + D) C
[ISC 2015]
- w Do practice for deriving an expression from a
logic circuit and also recognize the law used. Step
by step solving; of a circuit should be practiced.
Ans. Logic circuit for (A + B) (C + D) C -
A-
Detailed Answer:
B
From the logic diagram,
We have three input variables, i.e., Q, P, R. To find
the output F,
(i) We can see that Q and P input variables
formed one OR gate and P and R input
C variables formed another OR gate.
D- (ii) On the output of both OR gate, an AND
[ISC Marking Scheme, 2015] operation, is being performed.
To simplify this expression,
F = (Q + P)(P + R)
Examiner's Comment F = QP + QR + PP + PR
(by distributive law)
w Some candidates interchanged the gates i.e., OR
gate with AND gate and vice versa.
F = QP + QR + P + PR
(by idempotent law, i.e., PP = P)
These questions are for practice and their solutions are available at the end of the chapter
44 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
F = QP + QR + P (by absorption law) Simplify,
I
F = P + QR (by absorption law) X' = [A- (A + B) B(B + C')]'
Logic diagram represented distributive law. = [(AA + AB) (BB + BC')]'
Q. 5. Draw the truth table and logic circuit tor a 2 input (by distributive law)
XNOR gate. [ISC 2012] 0 = [(A + AB) (B + BC')]'
Q. 6. Name the logic gate tor the following circuit (by idempotent law)
diagram and write its truth table. [ISC 2011] = [AB] ' (by absorption law)
A B
= NAND gate
Since, NAND is a universal gate. Hence, the
(A + B)1 (A + B)" = A + B
complement of given expression is a universal gate.
Q. 9. Answer the following question related to the gate
given below: [ISC 2009]
Ans. In the given circuit diagram there are two NOR Input
gates ^ Output
First NOR gate B
A B
(i) What is the output of the above gate if input
A = 0, B = 1?
ii
( ) What are the values of the inputs if output
= 1?
Ans. (i) The output of the NOR gate is 0.
will produce output X = (A + B)' and this output is if inputs A = 0 and B = 1
being provided as input, to second NOR gate, i.e.,
(ii) A = 0, B = 0
Q. 10. State the dual for the following expression and
also draw the logic gate diagram for the dual
expression obtained using NOR gate only.
and second NOR gate being a single input NOR
gate will work as a NOT gate only. Hence, it will
P = AB + CD 0 [ISC 2009]
produce Y = X', i.e., Q. 11. Draw the logic gate diagram and truth table for
XOR gate. [ISC 2007]
= [{A + B}]' (by involution law)
\
=A+B x F = (x © y)
Hence, the given circuit diagram is just an OR
gate.
Q. 7. Draw the logic circuit of NOR using NAND gate Ans. Here, x and y are the inputs and F represents the
only. [ISC 2010] output of XOR. The truth table XOR is:
Ans.
x y F =x®y
X 0 0 0
ix' y')'r f = ((x’ y yy 0 1 1
1 0 1
y-
I I o
F = ((x '-yyr = (x '-y ') The algebraic expression is F = x © y = x'y + xy'
(by involution law) Q. 12. What is meant by a logic gate? State any one
= (x + y) ' application of a logic gate circuit. [ISC 2007]
Q. 8. Prove that the complement of A ( A + B ) B (B + C') Ans. Logic Gate: A logic gate is simply an electronic
is a universal gate. [ISC 2009] circuit, which operates no one or more input
Ans. Given expression, say signals to produce an output signal. Logic gates can
be constructed from diodes, transistor and resistor
-
X = A (A + B) B(B + C')
connected in such a way that circuit output is the
Its complement
result of a basic logic operations, performed on
-
X' = [A (A + B) B(B + C')]'
the input. Logic gates are used on bitwise Boolean
These questions are for practice and their solutions are available at the end of the chapter
I operations. The most popular application of logic
COMPUTER HARDWARE
Q. 15. Write the SOP expression corresponding to the
45
gate is switch. following truth table and draw its logic gate
Q. 13. Name the Universal Gates. [ISC 2007] diagram. 0
[ISC 2006]
Ans. Universal Gates: Combinations of NOR gate A B C F
and NAND gates may be arranged to create any
0 0 0 0
other possible combination of gates, making them
'universal gate'. 0 0 1 0
The NAND and NOR gates are said to be the 0 1 0 1
universal logic gates. These two gates can be used 0 1 1 1
to create all other logic gates.
1 0 0 0
NAND NOR 1 0 1 0
1 1 0 1
1 1 1 1
Q. 16. Using NOR gates only, draw AND, OR and NOT
x y z = (x-y) ' X y z = (x + y) '
gate. [ISC 2005]
o o I o o I Ans. (i) Construction of AND gate using NOR gate:
o I I o I o
I 0 1 1 0 0
1 1 0 1 1 0
Boolean expression Boolean expression
z = -
( x y) ' z = (x + y) '
(ii) Construction of OR gate using NOR gate:
. .
Q 14 Why is the NOR gate regarded as a universal
x
gate? Draw the logic gate symbol and make the (x + y)' x+ y =z
truth table for the two input NOR gates.
y*-
[ISC 2006]
Ans. NOR Gate is regarded as a universal gate because (iii) Construction of NOT gate using NOR gate
it can be used to construct many other gates like Here, we have only one input variable x and
AND, OR, NOT. it inverse using NOT gate produce x'. It passes
NOR gate means NOT OR, i.e., the NOR function through NOR, then the output will be:
is complement of OR function as shown:
F = (x + y)’
Answer Type
F = (x + y) '
<&\ Short
Questions- II (4 marks)
Q. 1. Draw the circuit of a two input XOR gate with the
help of NOR gates. [ISC 2020]
[Here, x and y are two inputs and F is output]
Ans. XOR gate using only NOR gates: Expression for
The truth table for 2-input NOR is:
XOR in POS: F = (A' + B') (A + B)
x y z = (x + y )'
o o I
o 1 0
1 0 0
1 1 0
[ISC Marking Scheme 2020]
These questions are for practice and their solutions are available at the end of the chapter
46 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE Class-XII
Q. 2. Derive a Boolean expression for the logic circuit
. I
given below and reduce the derived expression, Answering Tip
using the Boolean laws: [ISC 2015]
A- w Drawing of logic circuits using universal gates
must be learnt. Proving of universality of gates
B-HX must be learnt.
-X
c-»ri>o — Q. 4. Define universal gates. Give one example and
show how it works as an OR gate ?
Ans. 1. - -
(A' B' C')
| § [ISC, Specimen Question Paper 2016]
|
2. - -
(A' B' C')'
Q. 5. Derive a Boolean expression for the logic diagram
3. - - -
(A' B' C')' C given below and simplify it. [ISC 2014]
4. - - - - -
(A' B' C')' C + (A' B' C')'
-
(A + B + C) C + (A + B + C)
-
(A + B + C) (C + 1)
A+B+C [ISC Marking Scheme, 2015]
Examiner's Comment
w Most of the candidates answered this part correctly.
Some candidates gave incomplete answers. A few
candidates could not reduce the expression. Some
wrote the answer directly without mentioning the
intermediate points. Ans. The output will be:
(A + AB)(B + BC)(C + AB)
=> - -
A(1 + B) B(l + C) (C + AB)
Answering Tip --
A B (C + AB)
ABC + ABAB
ABC + AB
Do practice for deriving expression for any circuit
diagram and then reducing it. => AB(C + 1) = AB
[ISC Marking Scheme, 2014]
B*
(AB) . (AC) = AB + AC Answering Tip
w More practice should be done in deriving
expressions from a circuit diagram and simplifying
it. Laws must be implemented for minimizing
expressions.
[ISC Marking Scheme, 2015]
These questions are for practice and their solutions are available at the end of the chapter
I Answer the following questions:
COMPUTER HARDWARE
Q. 9. Consider the following truth table where A and B
47
(i) Write the SOP expression for D. are two input and X is the output
(ii) Write the POS expression for B. A B X
(iii) Draw a logic diagram for the SOP expression 0 0 0
derived for D using only NAND gates. 0 1 1
Ans. (i) x'y + xy' 1 0 1
-
(ii) (x + y) (x' + y) (x' + y') - 1 1 0
(iii) (i) Name and draw the gate for the given truth
table. [ISC 2012]
X' (ii) Write the POS of X (A, B ).
Ans. (i ) XOR gate
x'y + xy1
y'
-
(ii) POS expression is (A + B) (A' + B')
Q. 10. Show with the help of a logic diagram how a
..
Q 7 Minimize the following expression using Boolean NAND gate is equivalent to an OR gate .
laws §
( > [ISC 2011]
--
Q (Q' + P) R (Q + R ) Q. 11. Draw the truth table representing a 2 input XNOR
Also draw the logic gate for the reduced gate and derive its SOP expression along with its
expression. [ISC 2012] logic gate diagram. [ISC 2010]
Ans.
.
Ans Given expression is,
F = Q (Q' + P) -R - (Q + R) Truth Table for XNOR gate
o CH
as output when the output when the inputs
input combination combination has odd
has even number of number of Is.
Os
Logic Diagram of a 3 input XNOR gate:
F
Cl
Truth table for 3 input XNOR gate:
Q. 13. Draw the logic gate diagram for the Boolean A B C X
function. [ISC 2006] 0 0 0 0
= (A' + B) (B' + C)
F(A, B, C) 0 0 1 1
Making use of NOR gates only. 0 1 0 1
F(A, B, C) = (A' + B) (B' + C) 0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
fA' + B)(B' + C)
Expression: X = A © B 0 C
[ISC Marking Scheme, 2016]
Examiner's Comment
Long Answer Type w Some candidates were confused between XNOR
-
Question I (5 marks each) and XOR gates and interchanged the answers.
Some were confused with the 3 input XNOR truth
Q. 1. Differentiate between XNOR and XOR gates. table.
Draw the truth table and logic diagrams of 3
input XNOR gates. [ISC 2014]
Ans.The differences between XNOR and XOR gate are Answering Tip
as follows:
XNOR XOR w More practice should be done for understanding
the various gates (AND, OR, NOT, XOR, XNOR,
Logically equivalent Logically equivalent to NAND and NoR). Students should be told that in
to an inverted an exclusive OR. i.e., if odd number of inputs, XOR, and XNOR outputs
XOR, i.e., XOR gate both inputs are 1 then are same and in even number of inputs XOR is
followed by a NOT output is 0 (reverse of the complement of XNOR.
gate. inclusive OR)
m
>
Revision Notes
The K-map is a systematic way of simplifying Boolean expressions. With the help of the K-map method, we can
find the simplest POS and SOP expression, which is known as the minimum expression.
• The K-map provides a cookbook for simplification.
• The K-map method is used for expressions containing 2, 3, 4, and 5 variables.
I • There are the following steps used to solve the expressions using K-map:
COMPUTER HARDWARE 49
1. First, we find the K-map as per the number of variables as 2, 3, 4, and 5 variables.
2. Find the maxterm and minterm in the given expression.
3. Fill cells of K-map for SOP with 1 respective to the minterms.
4. Fill cells of the block for POS with 0 respective to the maxterm.
5. Next, we create rectangular groups that contain total terms in the power of two like 2, 4, 8, ... and try to
cover as many elements as we can in one group.
6. With the help of these groups, we find the product terms and sum them up for the SOP form.
C*
(A) Y = ab + be + ca
(B ) Y = ab + be + ca
— s (C) Both (A) and (B)
(D) None of these
Ans. Option (A ) is correct.
(C) Y = (a + b)(b + c)(c + a) Q. 5.
(D) None of these. X
B
.
Ans Option (A) is correct
..
Q 9
A* X
The output Y is: Z
B
(A) A'B
(C) A
(B) AB
(D) B fez
.
Ans Option (A) is correct The output at Y in the above diagram is:
..
Q 7 (A) BC (B ) AC
A- (C) AB (D) None of these.
.
Ans Option (B) is correct
B . .
Q 10
A* X
The output Z in the given figure is: B Z
(A) A'B (B) AB
(C) AB' (D) A'B’
.
Ans Option (C) is correct The output at Z is:
(A) (A + B)(B + C)(C + A)
..
Q 8
(B) A'B' + B'C + CA'
(C) AB + BC + CA
(D) All of these.
.
Ans Option (C) is correct
Final expression = XZ(X + Y ') + Z ' of Boolean using the laws of Boolean algebra.
=> XZ + XYZ + Z ' (by distributive law) Draw the logic gate diagram for the simplified
=> XZ (1 Y
+ + ') Z (by distributive law) expression. [ISC 2008] 0
=> XZ + Z '
(by complement law) -
F = A (A + B ) C (A + C)
'
=> + X Z '
Q. 5. How is an XOR gate different from an OR gate?
It represents the OR gate, X + Z ' Draw a truth table representing a three input XOR
operation. Derive its SOP expression and draw
the logic gate diagram for the SOP expression.
[ISC 2008]
Ans. OR gate produces output 1 for any input
Q. 2. Simplify the following expression and also draw combination having one or more l's, but XOR
the circuit/gate for the reduced expression. [Show gate produces output 1 for only those input
the stepwise working along with laws] [ISC 2010] combinations that have odd number of l's. Symbol
© is used to denote XOR gate.
-
F = X- (Y + Z (X - Y + X -Z) ')
Ans. Given expression, x y z F ^ x ©,»«© Zj Minterms
- - -
F = X (Y + Z (X Y + X Z) ') - 0 0 0 0 x ' y 'z '
- -
F = X (Y + Z[(X Y) + (X Z)] ') - 0 0 1 1 x 'y 'z
-
F = X (Y + Z[(X ' + Y ') (X ' + Z')]') - 0 1 0 1 x 'yz '
[On applying Demorgan's theorem,
i.e., (XY) ' = X ' + Y '] 0 1 1 0 x 'yz
Next, F = XY + XZ[(X ' + Y ') (X ' + Z')]) - 1 0 0 1 xy 'z '
(by distributive law)
F = XY + XZ(X ' X ' + X 'Z ' + X 'Y '
1 0 1 0 xy 'z
+ Y 'Z ')) 1 1 0 0 xyz
(using distributive law) 1 1 1 1 xyz
= XY + XZ(X ' + X 'Z ' + X 'Y ' + Y 'Z ')) F = x y z + x 'yz ' + xy 'z ' + xyz
' '
(using idempotent law)
= XY + XZ(X ' + X 'Y ' + Y 'Z ')) Logic circuit diagram for given SOP expression (F)
( using absorption law) is shown below:
= XY + XZ(X ' + Y 'Z ')) x-
( using absorption law)
= XY + X 'XZ
+ XZY 'Z ' y-
(using distributive law) z-
= XY (using complement law)
Logic circuit for reduced expression is: x
y
x <
z
Y
- tx>y
*
Q. 3. From the logic circuit diagram given below, name
the parts (1), (2), ( 3) and finally derive the Boolean
expression and simplify it: [ISC 2009] z-
x
A- y
01 z
B
C-
Long Answer Type
F(A, B, C) Questions -I (5 marks each)
Q. 1. A school intends to select candidates for an Inter-
School Essay Competition as per the criteria given
Ans. (1) OR gate A + B below: [ISC 2017]
(2) AND gate C(A + B) The student has participated in an earlier
(3) NOT gate [C(A + B)]' competition and is very creative.
Simplify = A + B + [C(A + B)] ' OR
(DeMorgan’s law) The student is very creative and has excellent
= A + B + C ' + A 'B ' general awareness, but has not participated in any
= A + A 'B ' + B + C ' competition earlier.
These questions are for practice and their solutions are available at the end of the chapter
52 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
OR The passenger is a lady and is not accompanied
I
The student has excellent general awareness and by an adult
has won prize in an inter-house competition. OR
The inputs are: The passenger is not below 15 years, but is
travelling for the first time.
INPUTS The inputs are:
A participated in a competition earlier
INPUTS
B is very creative
A The passenger is below 15 years age.
C won prize in an inter house -
competition C The passenger is accompanied by an
D has excellent general awareness adult.
(In all the above cases 1 indicates yes and 0 L The passenger is a lady.
indicates no). F The passenger is travelling for the
Output: X [1 indicates yes, 0 indicates no for all first time.
cases]
(In all the above cases 1 indicates yes and 0
Draw the truth table for the inputs and outputs indicates no).
given above and write the POS expression for Output: W - Denotes the passenger is allotted a
X( A, B, C, D). window seat (1 indicates yes and 0 indicates no)
Ans.
Draw the truth table for the inputs and outputs
A B C D X given above and write the SOP expression for
0 0 0 0 0 W(A, C, L, F ). [ISC 2016]
0 0 0 1 0 Ans .
0 0 1 0 0 A C L F W
0 0 1 1 1 (OUTPUT)
0 1 0 0 0 0 0 0 0 0
0 1 0 1 0 0 0 0 1 1
0 1 1 0 1 0 0 1 0 1
0 1 1 1 1 0 0 1 1 1
1 0 0 0 0 0 1 0 0 0
1 0 0 1 0
0 1 0 1 1
1 0 1 0 0
0 1 1 0 0
1 0 1 1 1
0 1 1 1 1
1 1 0 0 1
1 0 0 0 0
1 1 0 1 1
1 0 0 1 0
1 1 1 0 1
1 1 1 1 1 1 0 1 0 1
1 0 1 1 1
X = (A + B + C + D) (A + B + C + D ') (A + B
+ C + D ) (A + B + C + D) (A + B + C 1 1 0 0 1
+ D ') (A ' + B + C + D) (A' + B + C + D ')
1 1 0 1 1
(A' + B + C ' + D)
X = (A + B + C + D ) (A + B + C + D') (A + B 1 1 1 0 1
+ C ' + D) (A + B ' + C + D) (A + B ' + C 1 1 1 1 1
+ D ') (A ' + B + C + D) (A' + B + C + D ')
(A' + B + C ' + D). SOP Expression:
Q. 2. A passenger is allotted a window seat in an W(A, C, L, F) = 2(1, 2, 3, 5, 7, 10, 11, 12, 13, 14, 15)
aircraft, if he/she satisfies the criteria given below: W = A 'C 'I/ F + A 'C 'LF ' + A 'CL 'F + A 'CLF
The passenger is below 15 years and is + AC 'LF ' + AC 'LF + ACL 'F ' + ACL 'F
accompanied by an adult. + ACLF ' + ACLF
OR [ISC Marking Scheme 2016]
COMPUTER HARDWARE 53
Ans. (i) For F(A, B, C, D) = 2(0,1, 2, 3, 5, 6, 7, 10, 13,14, 15) w More practice should be given in drawing logic
circuits using basic gates and also with universal
CD gates.
AB CD CD CD CD
AB :i X i X i;
0
' '
3 2 Q. 4. Given the Boolean function: P( A, B, C, D) = FI(0,
;1 1 1 1, 2, 3, 5, 6, 7, 10, 13, 14, 15 ) [ISC 2014]
AB
4 5 7 6 (i) Reduce the above expression by using
AB ;I I I 4-variable Karnaugh's map, showing the
12 13 15 14 various groups (i.e., octet, quads and pairs).
AB 1 (ii) Draw the logic gate diagram of the reduced
8 9 11 10 expression. Assume that the variables and
,
1st quad (mg + m + m 2 + m3) = AB their complements are available as inputs.
Ilnd quad (m2 + mg + m10 + m14) = CD Ans. (i) For P(A, B, C, D) = 11(0, 1, 2, 3, 5, 6, 7, 10, 13,
Illrd quad (m6 + m7 + m13 + m15) = BD 14, 15)
So, final expression is, CD
F(A, B, C, D) = AB + CD + BD AB C+D C+D C+D C+ D
(ii) Logic gate diagram for expression
A+B :.o. .0 .Q .: O '
=
F (A, B, C, D) = AB + CD + BD is 0 1 3 2
J Th A+ B
A+ B
4
0
0
5
0:
0:
‘
! 7
0
0
6
F=AB+ CD+ BD
12 - - -13 : 15 14
A+ B 1 0
8 9 11 10
B P+ Q : 0. '
6; o:
0 1 • 3 2
P+ Q 0 () •
A+ B 4 5 7 6
cjy C+D P = (A + B)(C + D) + (B + D)
P+ Q
12 13
0
15
0
14
B+D
P+ Q 0 0 0 0
B 8 9 11 10
D-
Ist Quad (M0 MJ M8 M9) = (Q + R)
[ISC Marking Scheme 2014]
Ilnd Quad = (P +S)
Illrd Quad (M15 M14 MnM10) = (P + R)
Examiner's Comments So, the reduced expression is,
F(P, Q, R, S) = (Q + R) (P + S) (P + R)
w A number of candidates were not able to draw
(ii) Logic circuit diagram for F(P Q, R, S) is shown
the K-Map for the POS expression correctly. For
below:
many candidates the "Map rolling" concept was
not very clear. Some converted the canonical form
Q - Q+R
to cardinal form and then reduced it. R-
J
^ ^ J
universal gates while some others drew vague p P +S = (Q + R)(P +S)(P + R)
)
diagrams.
These questions are for practice and their solutions are available at the end of the chapter
I(ii) The logic gate diagram is shown below:
COMPUTER HARDWARE
diagram of the reduced expression using NOR
55
P+ Q
B
Q. 8. Given the Boolean function F(P Q, R, S) = P( 0, 5, P+ Q
7, 8, 10, 12, 13, 14, 15 ) [ISC 2002]
(i) Reduce the above expression by using P+ Q
4-variable K-map, showing the various
groups (i.e., octet, quads and pairs ). - - -
1st Quad (M2 M3 M6 M7) = (R + P)
(ii) Draw the logic gate diagram of the reduced - - - „
End Quad (Ml3 Mls M9 M ) = (P +S)
expression. Assume that the variables and - - -
HIrd Quad (M12 M13 M15 M14) = (P + Q)
their complements are available as inputs. Reduced expression is,
Ans. (i) Given function is, -
F(P Q, R, S) = (P + R) (P + Q) (P + S) -
F(P Q, R, S) = P(0, 5, 7, 8, 10, 12, 13, 14, 15) The logic diagram for above expression is:
RS
PQ R +S , R +S R +S R +S P+R
P+ Q 0
0 1 3 2
F = (P + R).(P + Q).(P + S)
P+ Q 0 0
4 5 7 6
P+ Q 0 0 0 0
12 13 15 14
P+ Q JJ. 8
0
9 11
0
10
Q. 10. Given the functions:
-
1st Pair (M0 M8) = R + S + Q
- - -
1st Quad (M5 M7 M13 M15) = S + Q
F( A, B, C, D ) = ABCD + ABCD + ABCD _
+ ABCD + ABCD + ABCD
- - -
Ilnd Quad (M8 M10 M12 M14) = S + P
Reduce the above expression by using 4-variable
Reduced expression is,
Karnaugh's map. Draw the logic gate diagram of
- -
F(A, B, C, D) = (S + Q) (S + P) (R + S + Q) the reduced expression using NAND gate only.
(ii) Logic diagram of given expression is: [ISC 2011]
Ans. Given expression,
Q--
S-
^TNQ +I F(A, B, C, D) = ABCD + ABCD + ABCD _ _
+ ABCD + ABCD + ABCD
CD
F = (Q + S)(P +S)(Q + R +S) AB ; CD CD ; CD CD
AB 1 i;
0 1 3 2
AB li :1
4 5 7 6
AB
Q. 9. Given expression is F(R Q, R, S) = P(2, 3, 6, 7, 9, 12 13 15 14
11, 12, 13, 14, 15). AB 1 1 1 1
Reduce the above expression by using four 8 9 11 10
variable Karnaugh's map. Draw the logic gate
56 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE Class-XII
1st Pair (m4 + m6) = ABD Q. 12. Given:
. I
1st Quad (mo + irij + m8 + m9) = BC F( A, B, C, D) = ( A + B + C + D) (A + B + C + D )
Final reduced expression is, (A + B + C + D ') (A + B + C' + D)
F(A, B, C, D) = ABD + BC (A + B + C + D ' ) (A + B + C + D )
(A + B + C + D) ( A + B + C + D)
Logic gate diagram for the reduced expression
using NAND gate only is as follows: 0 [ISC 2010]
B B (i) Reduce the above expression by using
4-variable K-Map, showing the various
groups (i.e., octet, quads and pairs).
F = BC + ABD (ii) Draw the logic gate diagram of the reduced
expression using NOR gate only.
Q. 13. F(I» Q, R, S) = P'Q 'RS ' + PQRS ' + PQ 'R 'S
. .
B
°—o —
Q 11 Given F(P, Q, R, S) = 2(0, 2, 5, 7, 8, 10, 11, 13, 14,
+ PQ 'RS ' + PQ 'RS + PQR 'S
+ PQRS ' + PQRS
Use Karnaugh's map to reduce the given function
15) [ISC 2010] F using the SOP form. Draw a logic gate diagram
(i) Reduce the above expression by using 4 for the reduced SOP form. You may use gate with
..
-
variable K map, showing the various groups
.
more than two inputs. Assume that the variables
and their complements are available as inputs.
(i e , octet, quads and pairs)
[ISC 2009]
(ii) Draw the logic gate diagram of the reduced
expression using NAND gate only . Ans. Given expression,
.
Ans (i) Given expression is, F(P, Q, R, S) = P Q RS ' + P QRS ' + PQ 'R 'S
+ PQ 'RS + PQR 'S + PQRS'
F(P Q, R, S) = 2(0, 2, 5, 7, 8, 10, 11, 13, 14, 15)
+ PQRS + PQ 'RS '
sRS
R’S’ R'S RS RS' To draw the K-map we need four input variables,
PQ % as shown:
P'Q' 1 : 1 1.1
0 1 3
''
2 sRS R'S1 R'S RS RS'
PQ\
P'Q 1 1 1 P'Q' 1
4 5 7 6 0 1 3 2
PQ 1 1 1 1
P'Q
12 13 15 14 4 5 7 6
1
PQ' 1 :
8 9
1 . 11. To PQ
12 13
1
15
1
14
11
1 1
1st Quad (m5 + m7 + m13 + m15) = QS PQ’ .1.
8 9 11 10
Ilnd Quad (m15 + m14 + mn + m10) = PR
Illrd Quad (mg + m2 + m8 + m10) = Q 'S ' 1st Quad (m13 + m15 + m9 + mn ) = SP
Reduced expression, F = QS + PR + Q 'S ' Ilnd Quad (m2 + m6 + m14 + m10) = RS '
(ii) The logic gate diagram for the reduced The reduced SOP expression, F = SP + RS '
expression using NAND gate only is given From the given expression, the logic gate will be
below: formed as:
P P R SS’
F = PR + QS + QS
S- Q^-T
These questions are for practice and their solutions are available at the end of the chapter
I
Q. 14. F( A, B, C, D) = P(0, 1, 2, 3, 5, 7, 9, 13)
COMPUTER HARDWARE
Ans. Given, F(A, B, C, D) = 2(0, 2, 3, 4, 6, 7, 9, 13)
57
These questions are for practice and their solutions are available at the end of the chapter
58 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE Class-XII
Here, A, B, C, D are the input variables and X is the
.
Q. 20. Given the Boolean function F(A, B, C, D) = 2(0, 1,
I
-
output variable, m0 m15 represents the minterms of 2, 4, 5, 7, 11, 13, 15). [ISC 2006]
the K map. - Use Karnaugh's map to reduce this function
1st Quad (m7 + m6 + m15 + m14) = BC F, using the given SOP form. Draw logic gate
1st Pair (nij + m9) = BCD diagram for the reduced SOP form. You may use
gates with more than two inputs. Assume that
Ilnd Pair (m8 + m10) = ABD
variables and their complements are available as
So, the final expression will be inputs.
F(A, B, C, D) = BCD + ABD + BC Ans. The given expression is,
Logic diagram for final expression is: F(A, B, C, D) = 2(0, 1, 2, 4, 5, 7, 11, 13, 15)
B -
^
BC .CD C’D' C'D CD CD'
C AB
A:B: 1 1
~ 0 1 3 2
B
^
BCD
C ) X = BCD+ ABD+ BC A 'B 1 1 1
D- 4 5 7 6
AB 1 1
A 12 13 15 14
B 1
D ABD AB' 1
8 9 11 10
Q. 19. Given X( A, B, C, D) = P(0, 2, 3, 4, 5, 11, 12, 13) 1st Quad (mo + nij + m4 + m5) = A C ' "
Use Karnaugh's map to reduce this function X Ilnd Quad (m5 + m7 + m13 + m15) = BD
using the given POS form. Draw a logic gate 1st Pair (m0 + m2) = A 'B 'D '
diagram for the reduced POS form. You may use Ilnd Pair (mn + m15) = ACD
gates with more than two inputs. Assume that the So, the final SOP expression will be
variables and their complements are available as
F(A, B, C, D) = A 'C ' + BD + A 'B 'D ' + ACD
inputs. [ISC 2006]
.
Ans Given X(A B C D) = P(0 2 3 4 5 11 12, 13)
, , , , , , , , , , Logical diagram for expression:
^ CD
-
K map Representation
-
C+D
_
,
C+ D C +D C+D
_ . A1 -
AB
A+ B 0 0 :0 D , ,
F(A,B,C,D) = A C + A'B 'D'
0 1 3 2 +BD + ACD
B
A+B 0 0 D
4 5 7 6
A+B 0 0. c
12 13 15 14
' '
A+B 0
8 9 11 10 Very Long Answer Type
1st Quad (M4 M5 M12 M13) = (B + C)
Questions I -
(10 marks each)
1st Pair (MO-M2) = (A + B + D) Q.l. (a) Given the Boolean function F(A, B, C, D) =
Ilnd Pair (M3 Mn ) = (B + C + D) 2(2, 3, 4, 5, 6, 7, 8, 10, 11). [ISC 2017]
Final expression, (i) Reduce the above expression by using
X(A, B, C, D) = (B + C) (A + B + D)-(B + C + D) 4-variable Karnaugh map, showing the
various groups (i.e., octal, quads and pairs).
Logical diagram for expression is:
(ii) Draw the logic gate diagram for the
B
C t> B+C
X(A,B,C,D)
reduced expression. Assume that the
variables and their complements are
available as inputs.
D
+B+ D , = (B + C).(A + B + D).(B + C + D) (b) Given the Boolean function:
A '
F(P, Q, R, S) = 7i(0, 1, 2, 4, 5, 6, 8, 10)
(i) Reduce the above expression by using
B B + C+ D 4-variable Karnaugh map, showing the
C various groups (i.e., octal, quads and pairs).
D
I (ii) Draw the logic gate diagram for the
COMPUTER HARDWARE
Q. 2. (a) Given the Boolean function F(A, B, C, D)
59
=
reduced expression. Assume that the 2(1, 3, 5, 7, 8, 9, 10, 11, 14, 15).
variables and their complements are (i) Reduce the above expression by using
available as inputs. 4-variable Karnaugh map, showing the
Ans. various groups (i.e., octal, quads and
(a) (i ) pairs).
CD' CD CD CD'
(ii) Draw the logic gate diagram for the
A'B' 1 1
reduced expression. Assume that the
0 1 3 2
variables and their complements are
A'B [I
4
i
5
i
7
n6 available as inputs.
(b) Given the Boolean function:
AB
12 13 15 14 F( A, B, C, D ) = p(4, 6, 7, 10, 11, 12, 14, 15)
AB' 1 d (i ) Reduce the above expression by using
8 9 11 10 4-variable Karnaugh map, showing the
various groups (i .e., octal, quads and
2 quads — A B, B C
' '
pairs ) .
1 pair — AB ' D '
(ii ) Draw the logic gate diagram for the
F = A 'B + B 'C + AB 'D ' reduced expression. Assume that the
<fl> A' variables and their complements are
AND,
B available as inputs. [ISC 2016]
Ans .
B' F (a ) (i) F(A, B, C, D) = 2(1, 3, 5, 7, 8, 9, 10, 11, 14,15)
AND , OR
C
CD' CD CD CD'
A
AND, 0 1 3 2
D' A 'B' 0 1
(b) (i)
A'B 4 5 7
R +S R + S' R' + S' R' + S 0 1
0 (0 12 13 15
P+Q AB 0 0
0 1 3 2
0 0 0 8 9 11
P + Q’. AB' 1 1
4 5 7 6
P’ + Q 1
There are three quads:
12 13 15 14
Quad 1 (mj + m3 + m5 + m7) = A 'D
P' + Q/ rrx Quad 2 (m8 + m9 + m10 + mn ) = AB '
8 9 11
\ Quad 3 (m10 + mn + m14 + m15) = AC
3>
(ii) P
R
Q
s T3> B'
A -
C -
d3>
60 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE Class-XII
Quad 2 (M6M7M14M15) = B ' + C ' Q. 3. (a) Given F(A, B, C, D) = 2(0, 2, 3, 6, 8, 10, 11, 14, 15)
Quad 3 (M10MnM14M15) = A ' + C' (i) Reduce the above expression by using
Hence, F(A, B, C, D) = (B ' + D) (B ' + C ') - (A ' 4-variable Karnaugh map, showing the
various groups (i.e., octet, quads and
pairs).
(ii) Draw the logic gate diagram for the
reduced expression. Assume that the
variables and their complements are
available as inputs.
(b) Given F(P, Q, R, S) = TI(5, 7, 8, 10, 12, 14, 15)
(i) Reduce the above expression by using
4-variable Karnaugh map, showing the
various groups (i.e., octet, quads and
pairs).
[ISC Marking Scheme 2016] (ii) Draw the logic gate diagram for the
reduced expression. Assume that the
variables and their complements are
Examiner's Comments available as inputs.
Ans. (a) Given, F(A, B, C, D) = 2(0, 2, 3, 6, 8, 10, 11, 14,15)
w (i) Most candidates fared well in this part. Some
candidates were not able to draw the K Map - CD
AW
C'D' C'D : CD CD' j
for the SOP expression correctly. For a number
of candidates the "Map rolling" concept was 1:
not very clear. Some converted the canonical
A'B' L 1- '
0 1 3
form to cardinal form and then reduced it.
A 'B 1
(ii) Most of the candidates attempted this part 4 5 7 6
correctly. Some drew the logic circuit using
NOR gates while some others drew vague AB 1 1
12 13 15 14
diagrams.
w (i) Most candidates answered this question
correctly. Some candidates made errors in
AB' 1:
8 9
1
ii - - - Jio -
: :-1- - - -
INPUTS
A' R The person has a valid reservation
ticket .
B'
B Do P The person holds a valid pass issued
by the Railway department .
C* D The person has a valid ID proof .
D' H The person is a disabled person.
D* (In all the above cases 1 indicates yes and 0
indicates no)
Output: T - Denotes allowed to travel (1 indicates
(b) Given, F(P, Q, R, S) = n (5, 7, 8, 10, 12, 14, 15) yes and 0 indicates no in all the cases)
\RS R + S R + S' R ' + S' R' + S (a) Draw the truth table for the inputs and
PQ \
outputs given above and write the POS
P+Q expression for T( R, P, D, H ) .
0 1 3 2
(b) Reduce T( R, P, D, H) using Karnaugh map.
P + Q' i.o Draw the logic gate diagram for the reduced POS
4 5 7 6
expression for T ( R, P, D, H ) using only NOR
P' + Q’ 0 0 0 gates. You may use gates with two or more inputs.
12 13 15 14 Assume that the variable and their components
are available as inputs . || »
P' + Q 0 0
8 9 11 10 Q . 5 . (a ) Given the Boolean function F( A, B, C, D)
= n(0, 1, 2 , 3, 5, 7, 8, 9, 10 , 11).
(i) Quad P ' + S (i ) Reduce the above expression by using
Pair P + Q ' + S ' 4-variable Karnaugh map, showing the
Pair Q ' + R ' + S '
various groups ( i .e., octet, quads and
pairs ) .
So, F(P, Q, R, S) = ( P ' + S) - ( P + Q ' + S ') (ii ) Draw the logic gate diagram for the
• (Q ' + R ' + S ') reduced expression. Assume that the
( ii ) Logic gate diagram, variables and their complements are
available as inputs.
P - eoE—L >
P' + S
(b) Given the Boolean function:
P( A, B, C, D ) = ABC' D + ABC'D '
'
|
|g These questions are for practice and their solutions are available at the end of the chapter
62 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE Class-XII
There is one Octet and one Quad:
.
(a) Draw the truth table for the inputs and
I
Octet: (M0M1M2M3M8M9M10Mn ) = B outputs given above and write the SOP
Quad: (M]M3M5M7) = A + D ' expression for X(S, W, H, A).
(b) Reduce X(S, W, H, A) using Karnaugh's map.
Hence, F(A, B, C, D) = B-(A + D ') Draw the logic gate diagram for the reduced SOP
B F = B.(A + D') expression for X(S, W, H, A) using AND and OR
(A + D ) 1
gate. You may use gates with two or more inputs.
A Assume that the variable and their complements
D’ are available as inputs.
Ans. (a) The truth table for given input and output is:
(b) P(A, B, C, D) = ABC 'D ' + A 'BC 'D ' Inputs Output
+ A 'BC 'D + ABC 'D
+ A 'BCD + ABCD S W H A X
CD' CD CD CD'
0 0 0 0 0 mo
0 0 0 1 0 mi
0 1 3 2 0 0 1 0 0 m2
A’B 1
0 0 1 1 0 m3
A'B 4 5 7 6
1 1 1 0 1 0 0 0 m4
12 13 15 14 0 1 0 1 0 m5
AB
1 1 1 0 1 1 0 1 m6
8 9 11 10 0 1 1 1 1 m7
AB’
1 0 0 0 0 m8
P(A, B, C, D) = BC 'BD 1 0 0 1 1 m9
B*
G
—— i
1 0 1 0 1 mio
BC' + BD
1 0 1 1 1 mn
1 1 0 0 0 m12
1 1 0 1 1 m13
D*
1 1 1 0 0 m14
Q. 6. A school intends to select candidates for the Inter
1 1 1 1 1 m15
School Athletic Meet, as per the criteria given
below: Required SOP expression is
The candidate is from the Senior School and has X(S, W, H, A) = SWHA + SWHA + SWHA
participated in an Inter School Athletic Meet + SWHA + SWHA + SWHA
earlier.
or + SWHA
The candidate is not from the Senior School, but (b) The -
K map representation: Required
the height is between 5 ft. and 6 ft. and weight is expression is in a SOP form which is sum
between 50 kg and 60 kg. of product form. The inputs are taken in
or multiplication order. Here, 0 represents
The candidate is from the Senior School and has
complement of input.
height between 5 ft. and 6 ft. but the weight is not
NHA HA HA HA HA
between 50 kg and 60 kg. w\
The inputs are:
SW
Inputs 0 1 3 2
S Student is from the Senior School SW 0 i1 1:
W Weight is between 50 kg and 60 kg 4 5 7 6
and W changes in each line. Hence, output G are the input variables of table while X is
will be SA. output variable. The M0-M15 represents the
1st pair (m6 + m7) = SWH max terms of the K map. -
Ilnd pair (m10 + mn ) = SWH C D F G X
Final reduced expression is,
0 0 0 0 0 M0
X(S, W, H, A) = SA + SWH + SWH
The logic diagram for the reduced expression 0 0 0 1 0 Mi
0 0 1 0 0 M2
0 0 1 1 0 M3
0 1 0 0 0 M4
0 1 0 1 1 M5
0 1 1 0 0 M6
X(S,W,H,A) = SA + SWH + SWH 0 1 1 1 1 M7
1 0 0 0 0 M8
1 0 0 1 0 M9
1 0 1 0 1 Mio
..
Q 7 A Football Association coach analysis the criteria 1 0 1 1 1 M „
for a win/draw of his team depending on the 1 1 0 0 0 M12
following conditions:
1 1 0 1 0 M13
If the Centre and Forward players perform well
but Defenders do not perform well. 1 1 1 0 0 Mu
OR 1 1 1 1 1 Mis
If Goal keeper and Defenders perform well but The POS expression is,
the Centre players do not perform well. X(C, D, F, G) = n(0, 1, 2, 3, 4, 6, 8, 9, 12, 13, 14)
OR = (C + D + F + G)(C + D + F + G)
If all the players perform well. (C + D + F + G)(C + D + F + G)
(C + D + F + G)(C + D + F + G )
The inputs are: (C + D + F + G)(C + D + F + G)
Inputs (C + D + F + G)(C + D + F + G)
(C + D + F + G)
C Centre players perform well.
(ii) Using the expression,
D Defenders perform well. X(C, D, F, G) = n(0, 1, 2, 3, 4, 6, 8, 9, 12, 13, 14)
F Forward players perform well. FG
CD F+G F+G F+ G F+G
G Goalkeeper performs well.
(In all of the above case 1 indicates YES C+D : 0 0 0 0:
0 1 3 2
and 0 indicates NO)
Output: X-Denotes the win/draw criteria [1 C+D 0 0
indicates win/draw and 0 indicates defeat in all : 4 5 7 6
the cases]. C+D 0:
12
0
13 15
:p.. 14
(i) Draw the truth table for the inputs and
outputs given above and write the POS C+D 0 0
expression for X(C, D, F, G ). 8 9 11 10
(ii) Reduce X(C, D, F, G ), using Karnaugh's map.
- - -
1st Quad (M0 MJ M2 M3) = C + D
Draw the logic gate diagram for the reduced POS Ilnd Quad (M4 M6 M12 M14) = D + C
expression for X(C, D, F, G ) using AND and OR
Illrd Quad (M8-M9-M12-M13) = F + C
gate. You may use gates with two or more inputs.
Assume that the variable and their complements Reduced expression is,
are available as inputs. F = (C + D)(D + C)(C + F)
64 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE Class-XII
The logic circuit diagram for the reduced S P
.
C T X
I
expression is given below: 0 0 0 0 0 MSL
C+D 0 0 0 1 1 MI
0 0 1 0 0 M?
0 0 1 1 1 Mi.
0 1 0 0 1 Mt
X = (C + D)(D + G)(C + F) 0 1 0 1 1 Ms
0 1 1 0 1 Mg .
0 1 1 1 1 Mz
1 0 0 0 0 M&
c 1 0 0 1 0 M9
.
F
1 0 1 0 1 M10
Q. 8. The principal of a school intends to select students 1 0 1 1 1 Mu
for admission to class XI on the following criteria: 1 1 0 0 1 M „
Student is of the same school and has passed the 1 1 0 1 1 Mu
class X Board Examination with more than 60% 1 1 1 0 1 Mu
marks. 1 1 1 1 1 M15
OR The SOP expression is,
Student is of the same school, has passed the X(S, P, C, T) = 2(1, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14,
class X Board Examination with less than 60% 15)
marks but has taken active part in co-curricular = SPCT + SPCT + SPCT + SPCT
activities. + SPCT + SPCT + SPCT + SPCT
OR + SPCT + SPCT + SPCT + SPCT
(ii) Using the expression,
Student is not from the same school but has either
passed the class X Board Examination with more X(S, P, C, T) = 2(1, 3, 4, 5, 6, 7,10,11,12,13, 14,15)
than 60% marks or has participated in sports at CT
SP CT CT CT CT
the national level.
The inputs are: SP i 1
0 1 3 2
Inputs
SP 1 1 1 1
S Student of the same school.
4 5 7 6
P Has passed the class X Board
Examination with more than 60 % marks. SP 1. 1. 1 1
12 13 15 14
C Has taken active part in co-curricular
activities. SP 1 1
8 9 11 10
T Has participated in sports at the national
level. 1st Octet (M4 + M5 + M6 + M7 + M12 + M13
Output X: Denotes admission status [1 indicates + M14 + M15) = P
granted and 0 indicates refused in all the cases]. 1st Quad (Mj + M3 + M5 + M7) = ST
(i) Draw the truth table for the inputs and Ilnd Quad (M10 + Mu + M14 + M15) = SC
outputs given above and write the SOP Reduced expression is,
expression. X = P + SC + ST
(ii) Reduce X(S, P C, T) using Karnaugh's Map. The logic circuit diagram for the reduced
Draw the logic gate diagram for the reduced SOP expression is given below:
expression for X(S, I* C, T) using AND and OR
gate. You may use gates with two or more inputs.
Assume that the variable and their complements
are available as inputs.
Ans. (i) The truth table is shown below. Here, S, P,
C, T are the input variables of table while X
-
is output variable. The M0 M15 represents the
maximum of the K map. -
I
Q. 9. A government Institution intends to award a
COMPUTER HARDWARE
(ii) Reduce X(E, R, S, C) using Karnaugh's map.
65
medal to a person who qualifies any one of the Draw the logic gate diagram for the reduced SOP
following criteria: expression for X(E, R, S, C) using AND and OR
The person should have been an Indian citizen gates. You may use gates with two or more inputs.
and had lost his/her life in a war but had not Assume that the variable and their complements
completed 25 year of service. are available as inputs.
OR
Ans. (i) According to the question, we have four inputs
The person must be an Indian citizen and has
E, R, S, C and X represents output value. The
served the nation for a continuous period of 25
truth table for given expression X(E, R, S, C) as
year or more but has not lost his/her life in a war.
shown:
OR
The person is not an Indian citizen but has taken E R S X c
active part in activities for the upliftment of the 0 0 00 0
nation. 0 0 10 1
The inputs are: 0 0 01 0
Inputs 0 0 11 1
A The person is/was an Indian citizen. 0 1 00 1
B Has a continuous service of more than 0 1 10 0
25 year. 0 1 01 1
C Lost his/her life in a war. 0 1 11 0
D Taken part in activities for upliftment 1 0 00 0
of the nation. 1 0 10 1
Output: X denotes eligible for medal [1 indicates 1 0 01 1
YES and 0 indicates NO in all cases]. 1 0 1 1 1
(i) Draw the truth table for the inputs and 1 1 0 0 0
outputs given above and write the POS 1 1 0 1 0
expression for X(A, B, C, D ). 1 1 1 0 1
(ii) Reduce X(A, B, C, D) using Karnaugh's map. 1 1 1 1 1
Draw the logic gate diagram for the reduced ,
(ii) 1st Quad (m + m3 4- m9 + mrl ) = R 'C
POS expression for X(A, B, C, D). You may use Ilnd Quad (m10 + mn + m14 + m15) = ES
gates with two or more inputs. Assume that the
1st Pair (m4 + mg) = E 'RC '
variables and their complements are available as
inputs. Final SOI) F = R 'C + ES + E 'RC '
. .
Q 10 A provisional store announces a special discount
.
SC
S'C ; S'C SC SC’
ER"
on all its products as a festival offers only to those
who satisfy any one of the following conditions: E 'R1 : 1 1
0 1 3 2
If he/she is an employee of the store and has a
service of more than 10 year. E 'R 1: :1
'
OR 4 5 7 6
If he/she is a regular customer of the store whose ER :1 1
age is less than 65 year and is not a employee of 12 13 15 14
the store.
OR ER’ 1 1 : 1: 1
If he/she is a senior citizen but not a regular 8 9 ; ii 10
customer of the store. Logic gate diagram for expression
The inputs are:
F = R 'C + ES + E 'RC ' is,
Inputs
R- 1
R'C
E Employee of the store
Regular customer of the store
C
R
S Service of the employee is more than 10 yr
C Senior citizen of 65 yr or above E F = R'C+ ES + E’RC
S
Output X: Denotes eligible for discount
[1 indicates YES and 0 indicates NO in all cases],
(i) Draw the truth table for the inputs and E' - E’RC'
R
outputs given above and write the SOP
expression for X(E, R, S, C).
These questions are for practice and their solutions are available at the end of the chapter
66 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE Class-XII
Q. 11. Given the Boolean function F(A, B, C, D) = 2(5, 6,
. I
The applicant possesses certain special skills as
7, 8, 9, 10, 14) specified in the 'Skill Requirement List' of the
Use Karnaugh's map to reduce the function F, country and is sponsored by a permanent resident
using the SOP form. Draw a logic gate diagram of that country.
for the reduced SOP form. You may use gates with The inputs are:
more than two inputs. Assume that the variables
Inputs
and their complements are available as inputs.
A The spouse or sponsor has permanent
-
Ans. K map representation residence status.
.CD B The spouse has lived in the country for 4
CD1 CD CD CD’
AB or more years.
A’B1 1 C The applicant possesses the required
0 1 3 2
special skills.
A’B . 1.1; i; D Sponsorships by a permanent resident.
4 5 7 6
Output X: Denotes eligible for discount (1
AB 1 indicates YES and 0 indicates NO in all cases).
12 13 15 14
1: (i) Draw the truth table for the inputs and
AB’ i .J. 1
outputs given above and write the SOP
8 9 11 10
expression for X(A, B, C, D).
Here, A, B, C and D are four variables. So, we will (ii) Reduce X(A, B, C, D) using Karnaugh's map.
use 4-variable K-map.
Draw the logic gate diagram for the reduced SOP
1st Pair (m5 + m7) = ABD expression for X(A, B, C, D) using AND and OR
Ilnd Pair (m7 + m6) = A 'BC gates. You may use gates with two or more inputs.
Illrd Pair (m10 + m14) = ACD ' Assume that the variable and their complements
IVth Pair (m8 + m9) = AB 'C ' are available as inputs.
Here, expression Ans. (i) From the above, we have four inputs A, B, C
X (A, B, C, D) = A 'BD + A 'BC + ACD' + AB 'C ' and D and one output X. The truth table for
given variables is shown:
Logic gate diagram for the expression is:
A B C D X
A'BD 0 0 0 0 0
0 0 0 1 0
0 0 1 0 0
A'BC 0 0 1 1 1
X = A'BD + A'BC 0 1 0 0 0
+ ACD' + AB'C' 0 1 0 1 0
0 1 1 0 0
0 1 1 1 1
1 0 0 0 0
1 0 0 1 0
1 0 1 0 0
1 0 1 1 1
Q. 12. The immigration rules of a country allow the issue
1 1 0 0 1
of work-cum-stay permits to an applicant only if
the applicant satisfies any one of the following 1 1 0 1 1
conditions. [ISC 2008] 1 1 1 0 1
The spouse of the applicant is a permanent 1 1 1 1 1
resident of that country, having lived there for at So, the SOP expression is,
least 4 year. A B 'C D + A BCD + AB 'CD + ABC 'D '
OR + ABC 'D + ABCD ' + ABCD
I -
(ii) K map for above SOP expression is,
COMPUTER HARDWARE
(ii) Draw X(A, B, C, D) using Karnaugh's map.
67
.CD C'D' CD CD CD' Draw the logic gate diagram for the reduced SOP
AB expression for X(A, B, C, D) as AND and OR
A'B' 1 gates. You may use gates with two or more inputs.
0 1 3 2 Assume that variables and their complements are
A'B 1 available as inputs.
4 5 7 6 Ans. (i) Truth table for given inputs is given below:
AB [i 1 T: A B c D X
12 13 15 14
0 0 0 0 0
AB' 1
8 9 11 10 0 0 0 1 0
0 0 1 0 0
1st Quad (m12 + m13 + m14 + m15) = AB
0 0 1 1 0
Ilnd Quad (m3 + m7 + mn + m15) = CD
The SOP expression X(A, B, C, D) 0 1 0 0 0
= AB + CD
The logic diagram of expression is: 0 1 0 1 1
0 1 1 0 1
0 1 1 1 1
X = AB + CD
1 0 0 0 0
AB
1 0 0 1 0
1 0 1 0 1
Q. 13. The inaugural function of the newly constructed
1 0 1 1 1
flyover has been organised by the Public Works
Department. Apart from a few special invites, 1 1 0 0 0
entry is permitted only, if: [ISC 2007] 1 1 0 1 1
The person is an employee of the PWD of class 1 1 1 0 1
I category with more than 10 year of working 1 1 1 1 1
experience.
(ii) SOP for X(A, B, C, D)
OR
= A 'BC 'D + A 'BCD ' + A BCD
The person is an employee of any other + AB 'CD ' + AB 'CD + A B C D
government or authorised private organisation + ABCD ' + ABCD
either at the managerial level or with more than K-map representation
10 yr of working experience. NCD
The inputs are:
^
AB
C’D1 C’D CD CD’
Inputs A'B’
0 1 3 2
A The person is a class I employee of PWD.
B The person is an employee of any other A'B i l l!
4 5 7 ; 6
government or authorised private
organisation. AB 1 .0 .1:
12 13 15 14
C The person has more than 10 yr of
AB'
1 1 1
working experience.
8 9 11 10
D The person is holding a managerial post.
A, B, C, D are the input variables.
Output: 1st Quad (m5 + m7 + m13 + m15) = BD
X: Denotes eligible for entry [1 indicates YES and Ilnd Quad (m7 + m6 + m15 + m14) = BC
0 indicates NO in all cases]. Illrd Quad (m15 + m14 + mn + m10) = AC
(i) Draw the truth tables for the inputs and So, the final expression will be
outputs given above and write the S X(A, B, C, D) = BD + BC + AC
expression for X(A, B, C, D).
Logic diagram for X = BD + BC + AC is
68
B-
Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Assume that variables and their complements are
I
D- D BD available as inputs.
Ans. (i) The truth table is given below:
A B C D R Minterms
B 0 0 0 0 0
X = BD + BC + AC
C 0 0 0 1 0
0 0 1 0 0
A-
0 0 1 1 0
0 1 0 0 0
c-
0 1 0 1 0
Q. 14. A combinational circuit with 3 inputs A, B, C
detects an error during transmission of code and 0 1 1 0 1 —> ABCD
gives the output D as 1 if any two of the inputs
are low (0).
0 1 1 1 1 —> ABCD
1 0 0 0 0
(i) Write the truth table with inputs A, B, C and 1 0 0 1 0
output D.
1 0 1 0 0
(ii) Write the SOP expression for D(A, B, C) using
minterms. Implements D using NAND gates 1 0 1 1 1 —> ABCD
only. 1 1 0 0 0
(iii) Write the POS expression for D(A, B, C) 1 1 0 1 0
using maxterms. Implements D using NOR
1 1 1 0 1 ABCD
gates only. [ISC 2007] 0 1 1 1 1 1 -> ABCD
Q. 15. The National College of Journalism is offering
courses in three different categories of journalism, -
(ii) K map representation
which are the print the web and the broadcasting Required SOP expression
media. [ISC 2006] XID
C'D' CD CD CD1
A student is eligible to apply, if he/she satisfies AB
any one of the following conditions: A'B’
0 1 3 2
The student is a graduate in any discipline with
an aggregate percentage of 75 or above and with a A'B 1 1
record of literary skills. 4 5 7 6
OR AB 1 1
The student is a graduate in Mass Communication 12 13 15 14
with aggregate percentage of 75 or above. 1 1
AB' L .l
The inputs are: 8 9 11 10
AB CD CD CD CD
[ISC 2005]
•i
”
A’ + B :0 To ; o c
8 9 11 10
-
1st Quad (M2- M3 M10 - M11) = B + C ' B IBD F
£>
I = EP + UPS
1 0 1 0 1
1 0 1 1 1
1 1 0 0 0
1 1 0 1 0 s
1 1 1 0 1 u- UPS
1 1 1 1 1
Combinational Circuits
Topic- 3 Concepts covered: Combinational circuits: Adder (Half and Full);
Encoder and decoder; Multiplexer and Demultiplexer
Revision Notes
> Combinational logic circuit is a circuit in which we combine the different gates in the circuit. For Example, Half
Adder, Full Adder, Encoder, Decoder, Multiplexes and Demultiplexer.
Characteristics of combinational circuits:
• A combinational circuit can have an n number of inputs and m number of outputs.
A A'
B Combinationed B'
i Circuit i
i
i i
N M
Logic diagram
71
c
£>
Full Adder Performs the S= x©y©z x y z S y s
addition of C = xy + yz + 0 0 0 0 0 z
three bits. xz 0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
c
1 1 0 0 1
1 1 1 1 1
1T T
X y Do A D2 2B
information from m < 2n 0 o I 0 o 0
n input lines to a n=2 o I o l o 0 ?x' ? y' ?z: '
maximum of 2n
unique output
1 0 0
1 1 0
0
0
1
0
0
1 D D0
lines.
D A
D A
D A
D A
D A
D A
D D7
n =4 3 0 0 1 1
0/
4 ,
3A
*
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
v,
8 1 0 0 0
9 1 0 0 1
za
F0 = , 3, 5, 7, 9)
Fa = 2(2, 3, 6, 7) F3 F2 F3 F0
F2 = 2(4, 5, 6, 7)
F3 = 2(8, 9)
72 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Multiplexer S e l e c t s
I
b i n a r y
information
from one
of many
inputs lines
and directs
it to a single
output line.
4x1 4 input Y
MUX lines
Si So
2 selection 0 0
Y
lines 0 1 Ii
0
k
1 h
1 1 I3
8x1 8 input s2 s0 Y s2 st s0
MUX lines
Si
0 0 0 lo 1?
-
(23) 3 selec - lo ; =D
tion lines 0 0 1 II k
r
i0 = s'2s [ s'0 0 o l o h 4-
0 1 1 I3
1
1
0
0
0
1
I4
I5
4-
1> F
1 1 0
1 1 1 I7
|Key Terms
> Half Adder: It performs the addition of two bits. There are two inputs A and B and the two outputs are Sum (S)
and Carry (C).
> Full Adder: A combinational circuit that performs the addition of three bits as two significant bits and one
previous carry.
> Decoder: It is a combinational circuit that converts binary information from n input lines to a maximum of 2"
unique output lines.
> Encoder: It produces a reverse operation of decoder. Basically. It is a process of converting signals from one type
to another type.
> Multiplexer: It selects binary information from one of many input lines and directs it to a single output line.
Since, it selects the data, it is also termed as a data selects.
Q. 2. State the difference between multiplexer and e.£.,4-to-l line e.g., 3-to-8 decoder.
multiplexer
decoders. [ISC 2009]
( Any two)
I
Q. 3. State the difference between an encoder and a Circuit for carry:
COMPUTER HARDWARE 75
<©>
(ii) They are used in computer to convert the
various input forms to binary form.
IN2
4>
-t>
i>
D
0 0 1 1 0
0 1 0 1 0 IN3
0 1 1 0 1
IN4
->
1 0 0 1 0 x
1 0 1 0 1 IN5
H>
1 1 0 0 1 IN6
i
SOP Expression:
i i i i
IN7
D
Sum = A'B'C + A'BC' + AB'C' + ABC
2 (1,2,4,7)
S2 SI SO
D
Carry = A'BC + AB'C + ABC' + ABC
2(3,5,6,7)
76 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Q. 3. State the application of Half Adder. Draw the Ans. A 4: 1 multiplexer consists of four data input lines
I
truth table and circuit diagram for a Half Adder. as D0 to D3, two select lines. S0 and Sj and a single
output line Y.
0 [ISC 2017]
Q. 4. What is a decoder? Draw the logic diagram for a Si S0 Y
binary to octal (3 to 8) decoder ? [ISC 2016] 0 0 D0
Ans. Decoder: It is a combinational circuit inputs 'n' 0 1 Di
lines and outputs 2n or fewer lines. It converts 1 0 D2
LLL to HLL.
1 1 D3
Logic Diagram:
A
R BRCR 0
h
>
1
Y
2
>
3
I2
6 I3
Si
[ISC Marking Scheme 2016] SQ -t»
Q. 6. State how a half adder is different from a full
adder. Also give their respective uses.
Examiner's Comment [ISC 2012, 05]
Ans. Difference between half adder and full adder are
w The definition was written correctly by most of
as follows:
the candidates. Some candidates were confused
with the logic diagram of a decoder and made Half Adder Full Adder
the diagram of an encoder instead. A few used
A combinational circuit A combinational circuit
the OR gate instead of the AND gate in the logic
that performs the that performs the
diagram.
addition of two bits is addition of three bits
called a half adder. (two bits are significant
Answering Tip and a one is a previous
carry) is called a full
w Students should learn the concept of combinational adder.
circuits as encoders, decoders and multiplexer. The half adder circuit It consists of three
They should also practice on designing the logic needs two binary inputs binary inputs and two
circuits. and two binary outputs. binary outputs.
Half adder does not Full adder has carry in
Q. 5. Briefly explain the working of a 4: 1 multiplexer. has carry in input. input.
Also, draw the logic diagram of 4: 1 multiplexer.
Q. 7. Draw the circuit diagram for a 3 to 8 decoder.
[ISC Specimen Question Paper 2016] [ISC 2010]
These questions are for practice and their solutions are available at the end of the chapter
I
Ans. The logic diagram for 3 to 8 decoder is:
COMPUTER HARDWARE
Multiplexers are used for:
77
Finn
...
x' y' z.
D0
(i) Routing several words to same destination
such as bus.
(ii) Parallel to serial conversion
Q. 10. Using two halt adder and an OR gate, construct
full adder. [ISC 2007, 05]
D. Ans. As we know, the function expression of Sum and
Carry of full adder are:
Sum (S) = x © y © z
D2
Carry (C) = xy + yz + xz
To construct the full adder, using two half adder
D3
and an OR gate, we take three input variables, x, y
and z. As shown in truth table:
D4
x y z s c
0 0 0 0 0
D5
0 0 1 1 0
0 1 0 1 0
Do 0 1 1 0 1
1 0 0 1 0
D7 1 0 1 0 1
1 1 0 0 1
..
Q 8 Draw the truth table for half adder. Also derive 1 1 1 1 1
a POS expression for the half adder and draw its From the above truth table, logic diagram using
logic circuit. two half adder and OR gate.
Ans. Truth Table for Half Adder x< x ®y
P S = xeysz
x y s c
z»
o o 0 0
C = xy + z(x©y)
0 1 1 0 xy = xy + yz + zx
l o l o
l l o l
The algebraic expression of Sum and Carry are,
-
Sum (S) = (x + y) (x ' + y ') on applying XOR gate,
Long Answer Type
So, Sum (S) = x © y <©> Questions -I (4 marks each)
Carry (C) = xy
Its logic circuit diagram is: Q. 1. How is a half adder different from a full adder?
E>-
X* Draw the truth table and derive the SUM and
CARRY expression for a full adder. Also, draw the
logic diagram for a full adder. [ISC 2016]
Ans. Half adder adds only two binary bits where as a
D *c
Full adder adds three input binary bits. Half adder
performs partial addition whereas a Full adder
performs total addition.
Q. 9. What is the purpose of a multiplexer? Mention Truth table for a Full Adder:
any two application of a multiplexer. [ISC 2008]
A B C Sum (S) Carry Zero (Cn)
Ans. A digital multiplexer is a combinational circuit that
0 0 0 0 0
select binary information from one of many input
0 0 1 1 0
lines and directs it to a single output line.
0 1 0 1 0
The selection of a particular input line is controlled 0 1 1 0 1
by a set of selection lines. For n selection lines, 1 0 0 1 0
there are 2n input lines. A multiplexer is also called
1 0 1 0 1
a data selector, since it selects one of many inputs,
1 1 0 0 1
e.g., 4 to 1 line multiplexer, 8 to 1 line multiplexer,
1 1 1 1 1
etc.
78 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Expression for Ans. Truth table for Octal to Binary Encoder:
I
Sum =A©B©C
Input Output
and Carry = AB + AC + BC
ABC
Octal number B2 Br B0
SUM 0 0 0 0
1 0 0 1
2 0 1 0
D AB
3 0 1 1
4 1 0 0
D BC CARRY
5
6
1
1
0
1
1
0
D AC
Answering Tip
'B2 BI '
[ISC Marking Scheme
B 0
2015]
w Students should learn the concept of combinational
circuits as half adder and full adder. They should
also practice on designing the logic circuits with
the truth tables. Examiner's Comment
w Most of the candidates answered this part correctly,
Q. 2. Define Half Adders. Draw the circuit diagram a few candidates drew the decimal encoder while
and the truth table for a Half Adder. <fg)[ISC 2015] some others drew the gates wrong.
n
w
Examiner's Comment
Some candidates drew wrong circuit diagrams.
The circuits for partial sum and carry were done
separately and not as one circuit in some cases.
w
V' Answering Tip
More practice should be done in drawing encoder
and decoder and proper use of connectors and
gates must be there.
Jo- JoS'iS'o
w
—
LJK
4S'iS0
Y
w
Answering Tip
Application of logic gates should be learnt along
with definition, truth table, logic diagram and
k
De* J S'0
expressions.
F0 s2-
Q. 8. What is a full adder? Draw the truth table for a
•
Fi full adder. Also derive SOP expression for the full
adder and draw its logic circuit. [ISC 2011]
Ans. Full Adder: A combinational circuit that performs
F2 the additions of three bits (two significant bits and
one previous carry) is known as full adder.
F3 Truth Table for Full Adder
x y z Sum Carry
Here, A and B are two input variables and F0, Fj, F2 0 0 0 0 0
and F3 are outputs.
0 0 1 1 0
The truth table for 2 to 4 decoder is: 0 1 0 1 0
Truth Table of 2 x 4 Decoder 0 1 1 0 1
A B F0 Fi F2 F3 1 0 0 1 0
0 0 1 0 0 0 1 0 1 0 1
0 1 0 1 0 0 1 1 0 0 1
1 0 0 0 1 0 1 1 1 1 1
1 1 0 0 0 1 Sum = xyz + xyz + xyz + xyz = x © y © z
Carry = xyz + xyz + xyz + xyz = xy + yz + xz
I x —Njj ~~
oSum(S) = x®y®z
COMPUTER HARDWARE 81
y
^ xy
Long Answer Type
<& Questions-II (5 marks each)
Q. 1. Draw the logic circuit diagram for an octal to binary
encoder and explain its working when a particular
Carry (C) = xy + yz + zx digit is pressed. Also, state the difference between
encoders and decoders . [ISC, 2020]
z zx Ans. Circuit diagram of a octal to binary encoder:
x 0 1
Q. 9. What is a multiplexer? Draw the truth table and
logic diagram of a 8 X 1 multiplexer. [ISC 2010] 2 -
1"
3
Ans. A multiplexer is a combinational circuit that selects 4 --
1
h . So .
F Working: It converts High Level to Low Level.
0 0 0 o Example: If input is (5)8 the output will be (101)2,
i.e., binary value of 5 and so on. To convert the
0 0 1 1
output signal to 1, a trigger is applied to the
0 1 0 2 required gate otherwise it remains 0 as default.
0 1 1 3 An encoder is a combinational circuit which
1 0 0 4 inputs 2n or fewer lines and outputs 'n' lines.
1 0 1 5
It converts HLL to LLL e.g. octal, decimal and
1 1 0 hexadecimal to binary
6
A decoder is a combinational circuit which
1 1 1 7
inputs 'n' lines and outputs 2n or fewer lines. It
From the given truth table, we conclude some converts LLL to HLL e.g. binary to octal, decimal
expression as follows: and hexadecimal. [ISC Marking Scheme, 2020]
I0 = S2'S1'S0T0 Q. 2. Draw the logic diagram and truth table to encode
It = S2'S/S0'I , the decimal numbers (2, 3, 5, 7, 8) and briefly
12 = S2'S/S0'I2 explain its working.
13 = S2'S/S0'I3 [ISC, Specimen Question Paper 2016]
14 = S2'S/S0T4 Ans. Given F(A, B, C, D) = 2(2, 3, 5, 7, 8).
15 = S2'S/S0T5 Truth Table
16 = S2'S/S0T6 A B C D F
¥ = S2'S/S0'I7 0 0 0 0 0
From the expression, the logic diagram is formed 0 0 0 1 0
as follows: 0 0 1 0 1
S2 S, So 0 0 1 1 1
0 1 0 0 0
4-
k
MD 0
0
1
1
0
1
1
0
1
0
0 1 1 1 1
1 0 0 0 1
1 0 0 1 0
1A - :
-Mk > i> r
1
1
0
0
1
1
0
1
0
0
1 1 0 0 0
4- = =o 1
1
1
1
0
1
1
0
0
0
1 1 1 1 0
82 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
I
p(«rt«c-s
Sum of Product (SOP) expression, (x®y)
F(A, B, C, D) = A 'B'CD' + A 'B'CD
+ A 'BC 'D + A 'BCD
X
)E >
+ AB 'C 'D' (x0y).C
Logic gate diagram, c D (x®y)c + x.y = K
A . {>
A'
A'BC'D
A'B’CD'
D- xy
These questions are for practice and their solutions are available at the end of the chapter
I COMPUTER HARDWARE
F = X' Y' + X Y - _=
F (A'.B’)’ = A + B
F = X?Y
B'
The logic diagram is shown as: B"
\
F = (X'Y' + XY) TOPIC- 2
3 Marks Questions
/
4. Given expression is
10. P = AB + CD. -
F = A (A ' + B) C (A + C)- -
-
Dual of expression P is (A + B) (C + D) On applying distributive law,
The logic diagram for dual expression is: - - -
F = (A A ' + A B) (CA + CC)
A- (A + B)' So, - - -
F = (A B) (C A + C)
B (using complement law and idempotent law)
(A + B) . (C + D) F = A B(C) - (using absorption law)
F = ABC --
c The required logic gate diagram for the reduced
.
D- (C + Dl -
ls SOP expression of given truth table will be:
expression above is given below:
AB
3
ii 2
AB
7 6
AB
15 14
AB 1
ii 10
tF= (B+D).(C'+ D)
.
12 (i) Given expression r+p]
F(A, B, C, D) = (A + B + C + D) (A + B + C + D ')
(A + B + C ' + D') (A + B + C ' + D)
(A + B ' + C + D') (A + B ' + - . -
17 K map representation,
1st Pair (M2-M3) = A + B + C
C ' + D ')-(A ' + B + C + D)
(A ' + B + C ' + D) Ilnd Pair (M4 M5) = A + B + C
.^CD C+D C + D’ C + D' : C’+ D
Illrd Pair (M12 M14) = A + B + D
All So, the final expression will be
0
A+ B 0: 0 0 F(A, B, C, D) = (A + B + C)-(A + B + C) (A + B + D)
0 1 3 2
CD
A + B' 0. 0. AB C+ D C+D C+D C+D
4 5 7 6 :0 0;
A+ B
A' + B’ 0 1 3 2
12 13 15 14
A+ B : 0 0: 1
A' + B 0 0 4 5 7 6
8 9 11 10
A+ B 0! :0
12 13 15 14
We get 2 quads,
1st Quad (Mj Mj Mg M = A + D ' A+ B 1
Ilnd Quad (M10 M8 Mo M2) = B + D ^ Logic diagram for expression,
8 9 !
! 10
A-
A +B+ C
F = (A + D').(B + D) B F
C-
A-
+ B+ D
fi -
.
ls Here, given X(A, B, C, D) = P(0, 2, 6, 8, 10, 14) D-
«
A
C+ D C + D' C + D' :C' +D 10 Marks Questions
4.
A+B 0
0 1 3 °-i- 2 T
(a) R P D H
A + B' 0 (OUTPUT)
4 5 7 6 0 0 0 0 0
A' + B’ 0 0 0 0 1 0
12 13 15 14
0 0 1 0 0
A’+ B 0 0 0 0 1 1 0
8 9 11 10
0 1 0 0 0
0 1 0 1 0
I COMPUTER HARDWARE 85
0 1 1 0 1 •(A '
+ B ' + C ' + D) (A ' + B ' + C ' +
0 1 1 1 1 D ')
1 0 0 0 0 -
(ii) From K map, we get
1
1
0
0
0
1
1
0
0
1
- - -
1st Quad (M0 M2 M4 M6) = A + D
P
>
(R + P)'
[(R + P) ' + D' ]'
B-
c-
14. (i )
D A' + B + C
ei >
A B C D
.
9 (i) Given expression X (A, B, C, D) has four
inputs and X represents output values. The 0 0 0 0
truth table for given inputs is, 0 0 1 1
A B C D X 0 1 0 1
0 0 0 0 0
0 0 0 1 1 0 1 1 0
0 0 1 0 0 1 0 0 1
0 0 1 1 1
0 1 0 0 0 1 0 1 0
0 1 0 1 1 1 1 0 0
0 1 1 0 0
1 1 1 0
0 1 1 1 1
1 0 0 0 0 (ii) D(A, B, C) = ABC + ABC + ABC
1 0 0 1 0
1 0 1 0 1
1 0 1 1 1
1 1 0 0 1
1
1
1
1
0
1
1
0
1
0
A
B
— ABC
1 1 1 0
1
Using above truth table the following POS
C -=0
expression will be drawn: A
(A + B + C + D)-(A + B + C ' + D) B —=0
-
(A + B ' + C + D) (A + B ' + C ' + D)
(A ' + B + C + D)-(A ' + B + C + D')
c — =0=-
1
86 Oswaal ISC Question Bank Chapterwise & TopLcwLse, COMPUTER SCIENCE, Class-XII
_
I
(in) D(A, B, C) = (A + B + C) (A + B + C) (A + B + C) 5 Marks Questions
(A + B + C) - (A + B + C) .
3 The truth table for hexadecimal to binary encoder
A+ B +C will be as follows:
Hex No. Jk A A Jjo .
A +B+C 0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
A + B+ C 3 0 0 1 1
-D
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
A +B + C
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
A 1 0 1 0
B 1 0 1 1
C 1 1 0 0
TOPIC-3
3 Marks Questions D 1 1 0 1
.
3 Half adder is a combinational logic circuit with E 1 1 1 0
two inputs and two outputs. The half adder F 1 1 1 1
circuit is designed to add two single bit binary From the truth table it can be seen that to receive
number A and B. It is the basic building block for high (1) signal.
addition of two single bit numbers. This circuit B0 must be connected to switches for 1 , 3 , 5 , 7, 9,
has two outputs carry and sum. B, D and F.
Truth Table :
Bi 2, 3, 6, 7, A, B, E and F
Inputs Output Circuit Diagram : B2 4, 5 , 6, 7 , D, E and F
A B S C A- B3 8, 9, A, B, C, D, E and F.
B Therefore, using 16 input push button switches
0 0 0 0
for entries 0, 1, ..., 9, A, B, C, D, E, F and 4 OR -
0 1 1 0
c -
gates to generate a 4 bit word B2BjB0 for output,
a diagram for hexadecimal to binary encoder may
1 0 1 0
be drawn.
1 1 0 1
0 LU
4 Marks Questions 1
.
2 Half adders are combinational circuits which adds 2
two input binary bits and output two binary bits. 3
(Partial Sum and Carry). 4 LLI
Circuit Diagram: 5
A- itx> 6
B 7
Sum
8
9
LU
D Carry A
B
Truth Table of Half Adder C
A B Partial Sum Carry D LU
0 0 0 0 E
0 1 1 0
1 0 1 0
F
1 1 0 1
[ISC Marking Scheme 2015] f >3 B2 BI B0
I 87
.
4 Draw the logic diagram and truth table for a 2 input XNOR gate. [2]
5. Study the diagram given below and answer the question that follow:
10. F(A, B, C, D) = Jt(0, 1, 2, 3, 5, 7, 9, 13). Use K-map to reduce the given function fusing the given POS form. Draw
a logic gate diagram for the reduced POS form. You may use gate with more than two inputs. Assume that the
variables and their complements are equitable as inputs. [5]
CHAPTER
PROGRAMMING
IN JAVA
Programming in Java ( Review of Class XI Sections B and C ); Objects:
Objects as data ( attributes ) + behaviour ( methods or functions );
(a )
object as an instance of a class. Constructors, ( b ) Analysis of some real
*world programming examples in terms of objects and classes, (c ) Basic input/ output using Scanner and Printer
'classes from JDK; input/ output exceptions.Tokens in an input stream,concept of white space,extracting tokens
' from an input stream ( String Tokenizer Class ).; Primitive values,wrapper classes,types and casting: Primitive
Values and its types. Corresponding wrapper classes for each primitive type.; Class as type of the object, as
'mechanism for user defined types. Variables Expressions: Variables as names for values named constants
ffinal ); expressions (arithmetic and logical ) and their evaluation ( operators, associativity, precedence).
'/ Assignment operation; difference between left hand side and right hand side of assignment. Statements,
'scope: Statements: conditional ( if, if else, if switch, case ternary operators ), looping ( for, while, continue,
'break ); grouping statements in blocks, scope and visibility of variables. Methods: Methods (as abstractions
for complex user defined operations on objects). Formal arguments and actual arguments in methods; different
1behaviour of primitive and object arguments. Static method and variables. The this operator. Examples of
algorithmic problem solving using methods ( number problems, finding roots of algebraic equations etc.)
;Arrays, strings: Structured data types - arrays, strings, algorithms: missing searching, finding maximum/
\minimum,sorting techniques, solving systems of linear equations, substring,concatenation, length,access to
'char in string, etc.).; Recursion: Concept of recursion, simple recursive functions ( e.g. factorial, GCD, binary
search, conversion of representations of numbers between different bas!
1 Topic- 1
-will notConcepts
*Note These are only for your reference. Questions from these
be asked in the Final Examination. Fundamentals of Java
parts
Page No. 88
pndent ^
"Java Virtual Machine" converts
Objects
Byte code to Machine Language.
Features of Java (instance of a class )
Oriented
L
Pr° grammi
(blue print that describes the
behaviour or state of the object)
fPwoiffuunmmfy in Jana
(All related data and methods
( fundamentals ) ] enclosed within one boundary)
( reusability)
J
Variables Data Types Wrapper Classes
eg. al, $ price,
value, sum.
ett simple
“O
Scn
eg. class A
{ fun 0 2
{ int x; 1
} Java compiler automatically Z
} to change an entity of O
one datatype to another upgrades lower type to
class A
eg. arrays, eg. byte (1 byte)
by programmer.
higher type. z
classes,
{
static int X;
}
interfaces.
int (4 bytes)
eg - double d = 100.5;
long 1= (long)d;
Trace the Mind Map
1
First Level Second Level Third Level oo
vo
I
90 Oswaal ISC Question Bank Chapterwise & Topicwise, COMPUTER SCIENCE, Class- XII
I
e of the method f 3
"
S
' 3
g--
If
X -
£ S
I s 3
s iV
5- 1
I g (
I u <
IT
§
£
1/
( method body)
S II
S'
.s
(Type, order, and «
number of parameters) 1
T3
3
.s is
(statements of body)
I
c S11 S S
§
•
.5 5 -g - 3 ~
C
Sg
A
-aii a -
9
•
i§ -g
i *i
me U U
o*
'
-
5* '
-
jeUcol sizel; imel 1 = new
•0 1
v es-
6> (i) int A [ ] = new int [10];
(ii) double B [ ] = {1.2, 3.5, 6.2, 1.8};
*
Storage of elements
3 int A [ ] = {5,12,8,17,10};
One dimensional in an array
%
%
Two dimensional
Jwxytamminp in Jauu int B [ ] = new int [5];
(i) int A [ ] = new int [5];
( Avuup ) A [0] = 6; A [1] = 8; (ii) scanner sc = new scanner (System.in );
System.out . println ("Enter 5 numbers");
for (int i = 0; i < 5; i+ + )
( A [i] = sc.nextlnt ();}
B ©Base address
W®storage space in bytes
I
92 Oswaal ISC Question Bank Chapterwise & Topicwise, COMPUTER SCIENCE, Class-XII
inherit
Uctor f a Base class
°
Objects of subclass can use
Base - abstract methods
Enormous situation
in program
try
(block of code to
monitor for errors. )
Catch
(It allows to define a block
of code to be executed,
eg. Missing semicolon, when an error occur in
missing brackets ( ) etc try block.)
u
~
Finally
(block of code to be executed s
after try and catch block ends. )
>
2
eg. if any body uses % 1
Z
for multiplication C\
eg. IO Exception
( Input Output Exception ) m [j Z
First Level Second Level Third Level
I
VO
«
I
94
>
Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Object Oriented Programming (OOP) is a programming paradigm which deals with the concepts of object to
I
create programme and software applications. The features of OOP are closely linked with the features of real -
world.
• Objects Objects have characteristics and behaviours. For example a student has states or characteristics:
:
name, age, group as well as behaviour such as student studies, plays, acts, etc.
;
• ofClassits type
: A class can be defined as a template or blueprint that describes the behaviour or state that the object
supports. An object is an instance of a class. A class is a way to bind the data and its associated
functions together.
• are
Methods Method basically is behaviour. A class contains many behaviour. It is in methods where the logics
:
written, data is manipulated and all actions are executed.
• already
Inheritance In Java, classes can be derived from classes. If you require to create a new class and here is
:
a class that has some of the code you need, then it is possible to derive your new class from the
already existing code. The feature is termed as inheritance. The existing class is called super class and the
derived class is called the subclass.
• Data Abstraction An act of representing main features without having the background details or internal
:
details. It deals with the outside view of an object as interface. For example, We all are performing several
operations on ATM machine like withdrawals, depositing, mini-statement, etc. but we can't know internal
details of ATM.
• achieved
Data Encapsulation Process of wrapping of data and methods in a single unit is called encapsulation. It is
:
by using class concept in Java. The isolation of the data from direct access by the program is called
'data hiding'.
• aPolymorphism A process of representing one entity in various forms is called 'Polymorphism'. For example,
:
single person acts like customer in the shopping mall, student in a school, a son at home, a passenger in a
-
bus/train. It means that one person in different different behaviours.
> Java Identifiers:
All components of a Java program require names. Names used for classes, variables and methods are called
identifiers. There are following points to remember for identifiers:
• All identifier should begin with a letter (A to Z or a to z), $ (dollar sign), ( ) underscore).
> Constructors: A constructor is the member function of a class that is used to initialize the data members when an
object of that class is created. The java compiler builds a default constructor for each class. Each time a new object
is created, at least one constructor will be invoked. The main rule of constructors is that they have the same name
as the class. A class can have more than one constructor.
I Example:
PROGRAMMING IN JAVA 95
Public student ( )
}
Public student (string name)
case N:
action N statement;
break; default;
default statement;
}
Where expression: is variable containing the value to be
evaluated . It must be of type byte, short, int, char,
default: is an optional keyword used to specify the statements to
be executed only when all the case statements evaluate to false .
while loop executes till condition is Syntax of while loop:
specified . It executes the steps mentioned While (condition){
in the loop only if the condition is true. action statements:
This is useful where programmer doesn't
know in advance that how many times
the loop will be executed.
}
Where condition: is any Boolean expression that returns a true or
false value. The loop continues upto condition returns true value.
Do-while loop do
!
The do-while loops execute certain action statements;
statements till the specified condition }while(condition){
is true. This loop ensures that the loop action statements;
body is executed atleast once.
}
For loop for(initialization statements; condition; increment/decrement
All loops have some common feature; statement){
a counter variable that is initialized action statements;
before the loop begins. The for loop
provides the feature that, initialized the
variable before loop begins, a condition }
for counter variable and counter upto where initialization statements: sets or initialize the value for
which loop lasts. counter variable.
condition: A Boolean expression that returns true or false value.
The loop terminates if false value is returned.
98 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
|Key Terms
> Objects: Objects contains several states and behaviours.
> Class: A template or blueprint that describes the behaviour as state that the object of its types supports.
> Data Abstraction: It is the process that involves identifying the essential features without including the internal
details.
> Data Encapsulation: A mechanism to bind the code and data together for manipulation is called data manipulation.
> Inheritance: It is the process by which one object acquires the properties of another objects. It can provide the
idea of reusability, drive a new class from the existing code. It means that a process in which a class is derived
from the base class is called inheritance.
> Polymorphism: An ability to take one operation and acts with different behaviour according to situation, is
known as polymorphism.
• The scope of a variable is the part of the program over which the variable name can be referenced.
>
• Assigning a value of one type to a variable to another type is called type casting.
Default constructor: It is automatically created by complier in the absence of explicit constructor.
> Parameterized constructor: These constructors are needed to pass parameters on creation of objects.
> Constructors with default arguments: It is required to define constructors with default arguments.
> Autoboxing: It is the automatic conversion that the Java compiler makes between the primitive types and their
corresponding object wrapper class
> Unboxing: a reverse process of autoboxing is known as unboxing.
answer the question that follow: Explanation: In this code after case 1 there is break
void trick (int a , int b) statement, which occurs fall through in switch
{ int p=l; case. To avoid fall through we must add break
for (int j=l; j< =b;j++ , p*=a) ; statement at the end of every case statement.
(i) What will be the output of the method trick() void play (int n)
when the values of a = 3 and b = 4? { int s=0;
- -
[ISC Sem 1 Paper 2021 22]
while (n!=0)
(A) 12 (B) 127
(C) 81 (D) 64 { s=s*10+n- (n/10)*10;
.
Ans Option ( C) is correct. n/=10;
Explanation: Here loop will execute 4 times and 3 }
will be multiply with p which is initially 1, 4 times.
Output will b e 3 x 3 x 3 x 3 = 8 1 System.out. println(s) ;
(ii) What is the method trick() computing?
-
[ISC Sem 1 Paper 2021 22]- (i) What will be the output of the method play()
(A) Factorial of a number when the value of n = 6957?
(B ) Product of the number -
[ISC Sem 1 Paper 2021 22] -
(C) Power of a number raised to a number (A) 27 (B) 695
(D) HCF of the two numbers
(C) 5679 (D ) 7596
.
Ans Option (C) is correct.
Ans. Option (D ) is correct.
Explanation: It will produce 34, i.e. 81.
Explanation: Here while will execute and print the
..
Q 4 With reference to the following program code,
passed digit in reverse order.
answer the questions that follow:
.
void funny (int p int m , int n) (ii) What is the method play() performing?
-
[ISC Sem 1 Paper 2021 22] -
{ for(int i=p;i<=p;i++)
(A) Arranging the digits in ascending order
{ switch (i) (B) Reversing the number
{ case 1: m+=10; (C) Extracting the first 3 digits
case 2: n-=l; break; (D) Sum of the digits
case 3: m+=n;n+=3;break; Ans. Option (B) is correct.
default: m+=2; Explanation: It will produce the reversing the
number.
System ,out.println(m+ ” ; ”+n) ; Q. 6. What is the output of the code given below?
void main ()
} { int a , b, c ;
(i) What will be the output of the method funny()
for ( a =150 , b = 65 , c = 0 ; a % b ! = 0 ; c = a % b , a = b ,
when the values of p = l,m = 12 and n = 6?
[ISC Sem-1 Paper 2021-22] b=c) ;
(A) 20:4 (B ) 22:5 System.out.print(b+ ””) ;
(C) Error (D) 24:7 [ISC Sem-1 Paper 2021-22]
Ans. Option (B ) is correct. (A) 0 (B ) 65
Explanation: Case 1 will execute which increase (C) 5 (D) Error
the value of m by 10 after that control moves to
case 2 and reduce the value of n by 1. So output Ans. Option (C) is correct.
will be 22:5 Explanation: Loop will continue till a % b not equals
(ii) What is the keyword used in Java to avoid a fall to 0. In first iteration c = 20, a = 65, b = 20. In second
through condition? [ISC Sem-1 Paper 2021-22] iteration c = 5 a = 20 and b = 5. Here a is divisible by
(A) case (B ) continue b, so loop will stop and it will produce the output
(C) switch (D) break 5, as the value of b.
100 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Q. 7. Java complier makes automaticconversion between Q. 13. Consider the following lines of code and find the
I
the primitive type and their corresponding object error if any:
wrapper class. This is called: import java.util .*;
(A) Implicit type casting
class xyz
(B) Coercion
(C) Explicit type casting
(D) Autoboxing public static void main (Strings [] args)
Ans. Option (D) is correct
Q. 8. Data items that have fixed data values are: Scanner sc=new Scanner(System.in) ;
(A) Static (B) Literals int a , b, res=0 ;
C
( ) Identifiers (D) None of these char OP;
Ans. Option (B) is correct
System.out.println("Enter first
-
Q 9 ... complies the Java source code program number") ;
file(.java files) into byte code.
a=sc.nextlnt () ;
(A) JVM compiler
System.out.println("Enter second
(B) java interpreter program
number") ;
(C) Virtual machine
(D) None of these. b=sc.nextlnt () ;
Ans. Option (A ) is correct System.out.println("Enter an
operator") ;
Q. 10. is a machine instruction for a Java
processor chip called JVM. OP=sc.next ().charAt (0) ;
(A) Java source code (B) Java program switch (ch)
(C) Java Byte code (D) All of these
Ans. Option (C) is correct caseV :
Q. 11. A Java class that has the same name as that of the res =a +b;
Java program is called break;
(A) main class (B) first class
default:
(C) initial class (D) None of these
Ans. Option (C) is correct System.out.println("Invalid
operator") ;
Q. 12. Consider the following lines of code and select
the most appropriate output
case'-':
res =a-b;
class ABC
break;
{
public static void main (String [] args)
}
{
int x=5;
(A) case for ' / &'% ' operators are missing.
if (x== 5); ( B) Data types of a &b variables should be double.
System.out.println("Welcome'') ; (C) default is placed at wrong position.
else (D ) No error in this code.
Ans. Option (D) is correct
System.out.println("Oops! Sorry");
Q. 14. Which of the following constructs can not be
nested in Java?
(A) if (B) switch
(A) Welcome (C) do...while (D) All can be nested
(B) Oops! Sorry Ans. Option (D) is correct
(C) Welcome Q. 15. The two jump statements in Java are:
Oops! Sorry (A) switch & break (B) break & jump
(D) Nothing will be printed on screen. (C) break & continue (D) for & continue
Ans. Option (D) is correct Ans. Option (C) is correct
I
Q. 16. The of an identifier is the part of the
PROGRAMMING IN JAVA 101
Q. 20. The methods and variables defined within a class
program in which the identifier is accessible. are called
(A) level (B) class (A) objects of a class
(C) scope (D) method (B) statements of class
(C) operations of class
Ans. Option (C) is correct.
(D) members of class
Q. 17. Which of the following is a symbol that takes Ans. Option (D) is correct.
one or more arguments and operates on them to Explanation: Methods are declared inside the body
produce a result? of the class but immediately after the declaration
(A) Operator (B) Literal of instance variables. Collectively, the methods are
(C) Identifies (D) Comment variables defined within a class are called members
of a class.
Ans. Option (A ) is correct.
Explanation: An operator is a symbol that takes Q. 21. Which type of access specifier is not accessible
one ore more arguments and operates on them to within the subclass inside the same package ?
(A) Private (B) Protected
produce a result. It performs an action on one or
(C) Public (D) Default
more operands. Operator are following types as
Ans. Option (A) is correct.
• Unary operators
• Ternaryoperators
Binary Explanation: Private access specifier denotes a
variable or method as being private to the class
• operator
and may not be accessed outside the class. It is
Q. 18. Identify the correct syntax for instance variable not accessible within the subclass inside the same
from the following options. package.
(A) Variable Name Q. 22. Evaluate the following Java expression, if x = 2, y
(B ) Class Name. Variable Name = 6, and z = 18.
(C) Object Reference. Variable Name ++ z + y-y + z + x ++
(D) None of these Choose the correct answer from the following
Ans. Option (C) is correct. (A) 38 (B) 39
Explanation: Non-static variables are called (C) 35 (D ) 40
instance variables. Instance variables are used to Ans. Option (D ) is correct.
store the state of an object. Every object created Explanation: In the above expression, ++ z means
from a class definition would have its own copy that the value will first increment by 1, i.e., 19.
of variable. Now, evaluate the statement by putting the values
of x, y and z. On evaluating the expression, we get
Syntax Object Reference. Variable Name 40, as shown below.
Q. 19. Choose the correct output for the following code ++ z + y-y-z + x ++
int a = 7, b = 5: 19 + 6 - 6 + 19 + 2 = 40
if (a < b) Q. 23. What will be the output of the following program?
public class Test
System.out.print ("a is small") ;
public static void main (String [ ] args)
else
int count = 1;
while (count<=13)
System.out.print fb is small'') ; {
System.out.println (count % 2 == 1?
(A) a is small (B) b is small "$ $ $": "****") ;
(C) Either a or b (D) None of these ++count ;
Ans. Option (B) is correct. }
Explanation: The if-else statement can be used to }
route program execution through two different
paths. In above code, there is condition (a < b)
(A) 13 times $$$
which is false according the values given, so else
( B) 13 times ****
part will be executed. The output will come "b is (C) 7 times $$$ and 6 times ****
small". (D) Both will print only once
102 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Ans. Option (C) is correct Q. 27. What will be the output of the following
I
Java
Explanation: In the above code, we have declared program ?
count =1. The value of count will be increased till class Test
12, because of the while (count < =13) statement. If
the remainder is equal to 1 on dividing the count
by 2, it will print ($$$) else print (****). Therefore, public static void main (String args [ ])
for all odd number till 13 (1, 3, 5, 7, 9, 11, 13), it will
print ($$$) and for all even numbers till 12 (2, 4, 6,
8, 10, 12) it will print (****). int a = 2;
Hence, dollar ($$$) will be printed 7 times and int b = 3;
asterisk (****) will be printed 6 times. if ((b = 1) == a)
Q. 24. Which of the following is not a valid jump System.out.print (b) ;
statement?
(A) break (B ) goto else
(C) continue (D) return System.out.print (++b) ;
Ans. Option (B ) is correct
Explanation: Jump statements are used do
unconditionally transfer program control from
(A ) 1 (B ) 2
one point to else where in the program. Jump
statements are primarily used to interrupt loop (C) 3 (D) 4
or switch case instantly. Java supports three jump Ans. Option (B ) is correct
statements: break, continue and return. Explanation: b is initialised to 1. The conditional
Q. 25. What will be the output of the following Java statement returns false and the else part gets
program? executed.
class Test Q. 28. What will be the output of the following Java
{ program ?
public static void main (String args [ ]) class Test
{
int a =5; public static void main (String args [ ])
System.out.print (++a * 9) ; {
int total=0;
} for (int i=0, j=0; i < 6 & j < 6; ++ j, j=i+l)
(A) 54 (B ) 45
total + =i;
(C) 48 (D) 59
Ans. Option (A ) is correct
System.out.println (total) ;
Explanation: Operator + + has more preference }
than *. thus a becomes 6 and when multiplied by }
9 gives 54. (A ) 6 (B ) 10
Q. 26. With a = 1, which of the following are legal lines (C) 15 (D) Compilation error
of Java code for changing the value of a to 2? Ans. Option (C) is correct
a + +; Explanation: Using comma operator, we can include
a = a + 1; more than one statement in the initialization and
a + = 1; iteration portion of the for loop. Therefore both
a = + 1;
+ + i and j = i + l is executed (gets the value - 0, 1, 2,
3, 4, 5 & j gets the values - 0, 1, 2, 3, 4, 5, 6.
(A) 1, 2, 3 (B ) 1, 4
(C) 1, 2, 3, 4 (D) 2, 3, 4, 5 So, the output is 0 + l + 2 + 3 + 4 + 5 = 15
Ans. Option (A ) is correct Q. 29. What will be the output of the following Java
Explanation: Operator + + increases value of code?
variable by 1. class Test
a = a + 1 can also be written in shorthand form as
a + = 1. Also a = + 1 will set the value of a to 1.
public static void main (String args [ ])
I PROGRAMMING IN JAVA 103
Q. 31. Which of the following is/aretype(s) of constructor?
(A) Default constructor
int a =5;
(B ) Parameterized constructor
System.out.println (++a*2 +" " +a) ; (C) Constructor with default arguments
(D) All of these
Ans. Option (D) is correct.
}
Explanation: Constructor has the same name as the
(A) 10 5 (B ) 10 6
name of the class to which it belongs. Constructor's
(C) 12 5 (D) 12 6 syntax does not include a return type, since
.
Ans Option (D) is correct . constructors never return a value. If may include
Explanation: Operator + + has higher precedence parameters of various types constructors have
different types as
than multiplication operation, *, a is incremented
to 6 than multiplied with 2 giving 12. •Default constructor
. .
Q 30 Which of the following is a combination of
•Parameterized constructor
n w -
Examiner's Comment
This part was well answered by most of the
candidates. Some wrote vague definition of 'fall
through'. Others explained using examples.
int unknown (int n)
int i. k = 0
if (n % 2 ==0)
{
i = n/ 2 ;
Q. 2. The following is a function of some class. What k = 1;
will be the output of the function test ( ) When the
value of count is equal to 4? Show the dry run/ else
working.|| § [ISC Specimen Question Paper 2016]
void test (int count) k = n;
n- -;
if (count == 0)
i= n / 2 ;
System.out.printlnf ”) ;
}
|
|g These questions are for practice and their solutions are available at the end of the chapter
104 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
while (i > 0) Output
I
{
k = k * i * n;
Similarly, when n is odd
n- -; Output
return k; n( n - l )
}
(i) What will be returned by unknown (5) ? Q. 4. The following function is a part of some class
What will be returned by unknown (6) ? which computes and returns greatest common
(ii)
divisor of any two numbers. There are some place
(iii) What is being computed by unknown (int n)? in the co-marked ?l ?r 121, 131, ?4? and 151 which
Ans. (i) for n = 5 must be replaced by statement expression so that
if (5% 2 = = 0) (False) the function works correctly, [ISC 2011]
Then, int gcd (int a , int b)
k =5
int r;
n =4 while ( ?1?)
i = 4/2 = 2 {
Iteration 1. 2 > 0 (True) r = ? 2 ?;
k = 5 * 2 * 4 > 40 = b = ? 3? ;
So, i =1 a = ?4 P ;
n =3 if (a ==0)
Iteration 2.1 > 0 (True) return ? 5 ? ;
k = 40 x 1 x 3 else
= 120 return -1;
}
i =0 (i) What is the expression or statement at ?1?
n =2 (ii) What is the expression or statement at 121
Iteration 3. 0 > 0 (False)
(iii) What is the expression or statement at ?3?
Return k = 120 (iv) What is the expression or statement at ?4?
(ii) Similarly, as n is 6 which is even, so the (v ) What is the expression or statement at 151
condition under if will be executed, Ans. (i) a > 0
n = 6, i = 3, k = 1 (ii) b% a;
condition (i > 0) n i k (iii) a;
(iv) r;
True 5 2 18
(v ) b;
True 4 1 180
Q. 5. The following is a function of some class. It
True 3 0 720 returns 1 if the number is a perfect number
False otherwise it return 0. [ISC 2008]
720 will be returned /*A perfect number is a number which is
(iii ) When n is even equal to the sum of its factors other than the
number litself /
n i k int perfectNo (int n)
n n/2 1 {
int ?1? ;
” -l n2 for (int j = 1; ? 2 ? ; j++)
:—
(n - l ) !* *
: : {
if ( ? 3 ? )
(n - 2) —2 -2 sum ? 4 ? ;
if (?5?)
return 1;
(n - 3) else
-- 3 return 0;
:
tf j
- 2 * (» - 2) }
I (i) What is the expression/value of ?1?
PROGRAMMING IN JAVA
Q. 7. Give the output of the following program
105
Revision Notes
> A function or method in Java contains the executable code.
> Need for methods
• Complex problem can be broken into smaller and more easily understandable tasks.
• Low level details about as to how a method is accomplishing a task are hidden from the users.
• Reusability of the code increases.
A function must be defined before it is used anywhere in the program.
> Syntax of a method:
Public static int method name (int a , int b)
//body
}
public Static - > modifier
int - > return type
methodName - > name of the method
a, b - > formal parameters
int a , int b - > list of parameters
> A method in Java has to be inside a class.
> The first line of the function definition that tells the program about the type of the value returned by the function
and the number and type of arguments.
> A function is called by providing the function name followed by the parameters enclosed in parentheses.
> A function can be invoked in two ways:
• Call by value: value of actual parameters are copied into the formal parameters.
• Call by reference: A reference of the actual parameters are passed to the formal parameters.
> A function terminates either when a return statement is encountered or the last statement of the function is
executed.
> main() method is the logical entry point of the program.
> A static method of a class can't access a non-static method or variable of its own class.
> Recursive function: A function definition that calls itself.
> A recursive function must have two cases
I• The recursive case
PROGRAMMING IN JAVA 107
>
• The base case
When many methods have the same name with different functionality it is called overloading.
> Table: Function and their description
Function Description
sin (x) Returns the sine of the angle x in radians
cos (x) Returns the cosine of the angle x in radians
tan (x) Returns the tangent of the angle x in radians
asin (y) Returns the angle whose sine is y
acos (y) Returns the angle whose cosine is y
atan (y) Returns the angle whose tangent is y
atan 2 (x, y) Returns the angle whose tangent is x/y
pow (x, y) Returns x raised to y (xy)
exp (x) Returns e raised to x (ex)
log (*) Returns the natural logarithm of x
ceil (x) Returns the square root of x
sqrt (x) Returns the square root of x
ceil (x) Returns smallest whole number greater than or equal to x
floor (x) Returns the largest whole number less than or equal to x
rint (x) Returns the truncated value of x
round (x) Returns the integer closest to the argument
abs (a ) Returns the absolute value of a
max (a, b) Returns the maximum of a and b
min (a, b) Returns the minimum of a and b
HH
>
Key Terms
Recursion is when a function calls itself . That is, in the course of the function definition there is a call to that very
same function.
> Method Overloading: When a class has two or more methods by the same name but different parameters
I
} return (Magicfun (0)’10+ l)
return a ; I
return (0)
void displayO Output -+ 0 * 10 + 1 = 1
1 MO + 0 = 10
gcd = gcd (numl , num 2) ;
10 MO + 1 = 101
System.out.println(“ Gcd of “ + numl
101 * 10 + 0 = 1010
+ “ and “ + num 2 + “ = “ + gcd) ;
Q. 5. The following function Check( ) is a part of some
public static void main (String[] args) class. What will the function Check( ) return
when the values of both 'm' and 'n' are equal to
{
5 ? Show the dry run/working , [ISC 2016]
Gcd ob=new Gcd () ;
ob.accept() ; int Check ( int m, int n)
ob.displayQ ; {
if (n = = 1)
} return - m -
Q. 4. The following function magicfun( ) is a part of else
some class. What will the function magicfun( )
return + + m + Check (m, - -n);
return, when the value of n = 7 and n = 10,
respectively? Show the dry run/working: Ans . Output: Check (5, 5)
[ISC 2017] 6 + Check (6, 4)
int magicfun (int n) 7 + Check (7, 3)
{ if ( n==0) 8 + Check (8, 2)
return 0; 9 + Check (9, 1)
Hence the output = - 9 + 9 + 8 + 7 + 6 = 21
else
[ISC Marking Scheme, 2016]
return magicfun (n/2) , *10 + (n % 2);
} return “
Ans. mymethod (3)
}
print Hello 3
else
mymethod(3)
print(2)
return numbersl (n - 1) +n + “ ”;
}
mymethod (2)
print Hello 2 (i) What will be the output of the function
mymethod(2) numbers (int n) when n = 5?
print(l )
mymethod (3) (ii) What will be the function numberl (int n)
print(2) return when n = 6?
(iii) State in one line what is the function
mymethod(l)
print(O) numbersl (int) doing apart from recursion?
mymethod (1)
print Hello 1 mymethod(2) Q. 10. The following function trial( ) and perform( ) are
print(l ) a part of some class. Answer the following parts
mymethod (0) mymethod(3) given below. Show the dry run/ working.
if (count = = 0) true print(2)
[ISC 2009]
|
|g These questions are for practice and their solutions are available at the end of the chapter
114 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
int trial (int n) is greater than 1 when the function is invoked. It
I
returns the value 1 when true otherwise it return
0. Show the dry run/working. [ISC 2008]
if (n== l)
void calling (int j)
return 2 ;
else if (n == 2)
int f = 2;
return 3;
show (n , f ) ;
else
}
return trial (n - 2) + trial (n - 1) ;
int show (int n , int f )
obj.JoinNum( );
I
Member functions:
obj.show();
Merger ( ) : constructor to initialize }
the data members }
void readNum ( ) : to accept the values of [ISC Marking Scheme, 2015]
the data members nl and
n2
voidJoinNum ( ) : to concatenate the numbers Examiner's Comment
nl and n2 and store it in
mergNum A number of candidates were able to attempt
void show ( ) : to display the original this part well. The joinnum () function was not
numbers and the merged done properly by some candidates. Various
number with appropriate methods/techniques were used to concatenate the
messages numbers. Some did it directly without converting
it to String type. Several candidates reversed the
Specify the class Merger, giving the details of the
constructor, void readNum ( ), void JoinNum( )
number using while loop and then added it to
the other number. In some cases 'int' was used
and void show ( ). Define the main ( ) function
instead of 'long' data type. Object creation in the
to create an object and c all the functions
main () function was not properly defined in some
accordingly to enable the task ,
||
* These questions are for practice and their solutions are available at the end of the chapter
I Specify the class Emirp giving details of the
PROGRAMMING IN JAVA
Design a class Point with the following details:
119
*= * 2* ,y = ±
1+ 2
1 J/l J/2
2 System.out.println(x+ +y) ;
}
These questions are for practice and their solutions are available at the end of the chapter
120 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
public static void main (String args[ ]) Ans. Palindrome Number
I
throws IOException import java .io.*;
public class Palin {
Point PI = new Point 0 ; int num ;
Point P2 = new PointO ; int revnum ;
Point P3 = new Point 0 ; Palin ( ) {
PI. readpoint( ) ; num = 0;
P2. readpoint ( ) ; }
P3 = P3.midpoint (PI , P2) ; void accept ( ) throws IOException {
P3.displaypoint ( ) ; InputStreamReader x = new
} InputStreamReader (System.in) ;
BufferedReader y = new
Q. 7. A magic number is a number in which the BufferedReader (x) ;
eventual sum of digits of the number is equal to System.out.printlnf 'Enter a number") ;
1. [ISC 2009] # num = Integer. parseInt (y. readLine ( )) ;
e.g., 172 = 1 + 7 + 2 = 10
10 = 1 + 0 = 1 int reverse (int y) {
then 172 is a magic number. int len = (y+"") .length ( ) ;
Design a class Magic to check if a given number if (len == 1) {
is a magic number. Some of the members of the return y ;
class are given below: } else {
Class name Magic return (((y % 10) * (int) Math . pow(10,
len - 1)) + reverse (y/10)) ;
Data member/instance variable: }
n store the number
void check ( ) {
Member functions
revnum = reverse (num);
Magic () constructor to assign 0 to if (num == revnum) {
n System.out.println("Yes, it's a
void getnum (int tin ) to assign the parameter
palindrome");
value of the number, n = } else {
nn System.out.println(" No, it's not a
palindrome'') ;
int Sum of returns the sum of the
}
digits(int) digits of a number
void ismagic ( ) checks if the given public static void main (String [] args)
number is a magic number throws IOException {
by calling the function Palin myPal.inObj = new Palin () ;
Sumofdigits(int ) and myPalinObj.accept ( );
displays appropriate
myPalinObj.check ( ) ;
message
}
Specify the class Magic giving the details of
the constructor, void getnum(int), int Sum_of_
digits(int) and void ismagic(). You need not to Q. 9. A ticket at a ticket selling booth at a fair is priced
write the main function. at ?2.50/-. The booth keeps track of the total
number of people who have visited the booth, the
Q. 8. Specify the class Palin giving the details of the number of people who have actually purchased
constructor] ), void accept] ), int reverse(int) and
a ticket and the total amount of money collected.
void check] ). Define the main] ) function to
Design a class called Ticbooth, which includes
create an object and call the functions accordingly
the following Members: [ISC 2006]
to enable the task. [ISC 2017]
|
|g These questions are for practice and their solutions are available at the end of the chapter
I Class Name Ticbooth
PROGRAMMING IN JAVA
System .out.println (“no. of people
121
no_people = 0. -
201 300 ? 1.20/-per call
rental charge
amount = 0 ;
above 300 ? 1.50/-per call
rental charge.
void notsold ( ) // method notsold ( )
{ void dispdate to display the details in the
no_people++ ;
( ) specified format.
The calculations need to be done as per the slabs
void sold ( ) //method sold Specify the class Telcall, giving the details of the
{ constructor, void compute ) ) and void dispdata) ).
no_people++ ; In the main function, create an object of type
amount = (float)(amount + 2.50) ; Telcall and display the phone bill in the following
format:
void disp_totals ( ) //method disp_totalQ Phone Name Total Amount
{ Number Calls
XXXXXXX XXX xxxxx xxxx [ISC 2006]
122 Oswaal ISC Question Bank Chapterwise & TopLcwLse, COMPUTER SCIENCE, Class-XII
Ans. class Telcall Some members of the class are given below:
I
{ [ISC 2006] 0
String phno, name ; Class Name Hifact
int n ; Data member/instance variables
double amt;
a, b, hcf, 1cm integers
Telcall (String ph , String na , int nc)
Member functions/methods
{
phno = ph ; Hifact ( ) constructor to assign initial
values to the data members
name = na ;
n = nc; void getdata ( ) to input values of a and b
amt = 0.00; void change ( ) to swap a and b if a > b
} int rechcf (int, int ) to find hcf using the recursive
void compute ( ) technique
{ _
int fn lcm (int, to find 1cm using a , b and hcf
if (n < = 100) int, int )
{ void result ( ) to invoke and rechcf ( ) and
amt = 500.00 ; _
fn lcm ( ) and to print 1cm, hcf
of the two numbers a and b
if (n > 100 && n < = 200) Specify the class Hifact giving the details of
constructor, void getdata (). void change ( ). int
{ rechcf () and int fn_lcm (). Write the main function
amt = (n - 100)*1 + 500 ; and find the hcf and 1cm of any two integers, a
and b.
if (n > 200 && n < = 300) Q. 12. A class quad contains the following data
{ members and member functions to find the roots
amt = (500 + 100*1 + (n - 200)*1.2) ; of quadratic equation:
if (n > 300) Class Name Quad
{
amt = (500 + 100*1 + 100*1.2 + (n
Data members a, b, c (float ), xv x2 (float )
Member functions/methods
- 300)*1.5) ;
} quad (float, float, constructor to assign values
float ) to the data members
void dispdata( ) float discriminate to return the discriminant [ b 2
{ 0 - 4rtC]
System.out.println (“ Phone Number\
_
void root equal () to display the root if both
tName\t\tTotal calls\tAmount”) roots are equal
System.out.println(phno+ \t “ + name” void imag( ) to display the roots, if roots
\t “ +n +” \t\t “ +amt) ; are imaginary
_
void roots real () to display the two real,
public static void main (String args[ ]) unequal roots
{ void roots ( ) to call other appropriate
Telcall t = new Telcall (“ 9897205588” , functions to find the solution
“Amit Sharma ” , 250) ; of the problem.
t.compute ( ); If ax2 + bx + c = 0 is the quadratic equation, then
t.discpdata ( ) ; if b2 - 4ac > 0 roots are real, unequal
0 These questions are for practice and their solutions are available at the end of the chapter
)
I Specify the class quad giving the details of the
PROGRAMMING IN JAVA
Member functions/methods
123
functions.
sumseries ( ) constructor
quad (float , float , float)
int factorial (int calculates and return
float discriminate ( ) n) factorial of n (»!) where
_
void root equal 0 «! = 1 x 2 x 3 x ... x n
void root real 0 double term (int calculates and return the
p, int q) value of p/q\ by making use
void root ( ) of factorial (int)
You may assume that other functions are written void accept ( ) inputs the value of data
for you. You need not to write the main function. member x, n
Ans. class quad void displays the value of
{ displaysum ( ) member sum.
float a, b, c, xl, x2, d; double calsum calculate the sum of the given
quad (float x , float y, float z) 0 series using the appropriate
//constructor with argument data and other member
{ function.
a = x; b = y; c = z; (i ) Specify the class series giving details of
} constructor, int factorial (int), double term
float discriminate ( ) //method discriminant (int, int), void display sum ( );
{ You may assume other member functions are
return (b*b) - (4* a * c); written for you. You donot need to write the
} main function.
_
void root equal ( ) //method root equal _ (ii ) What care do you need to take while
{ designing double term (int, int)
xl = -b/(2* a); Ans. (i ) class sumeries
x2 = -b/(2*a);
System.out. println (xl + " " + x2); int x , n ;
} double sum ;
_
void root real () //method root real _ sumseries ( ) //constructor sumseries
{
x = 0;
xl = (float)((-b + Math.sqrt(d ))/2*a);
n = 0;
x2 = (float)((-b - Math.sqrt (d ))/2* a );
} sum = 0.0 ;
void root ( ) //method root
{ int factorial (int n )
d = discriminant(); {
if (d = = 0) if (n = = 1)
_
root equal (); return (n) ;
if (d > 0) else return (n * factorial (n - 1)) ;
_
root real ();
if (d < 0) double term (int p, int q)
System.out.println("Imaginary"); {
}
double d ;
}
double f ;
x2 -1
Q.13. Sum = 1 + 1— + — + — + ... + ” [ISC 2005] if (q = = 0)
!2 ! 3! n! {
A class sumseries has been defined to calculate system.out. println ("Division by
sum of the above series. Some of the members of zero");
the class are given below: return (0) ;
Class Name Sumseries }
Data members/instance variable else
{
variable x, n (integer), sum(double )
f = factorial (q);
124 Oswaal ISC Question Bank Chapterwise & Topicwise, COMPUTER SCIENCE, Class- XII
d = p/f ; int a = num;
I
while(a!=0)
return (d) ; { a = a/10;
size ++; }
void displaysum ( )
int sumofDigits (int n, int p)
System . out. println ("Sum is" + sum) ; { return (n==0)? 0:
sumofDigits(n/10,p - 1)
+ (int) Math.pow(n%10, p);
(ii ) When we design double term (int, int ), care }
should be taken that a division operation void check ()
should not be done by zero.
{ if (num==sumofDigits (num,
Q . 14. A disarium number is a number in which the size))
sum of the digits to the power of their repective System.out.print("\n Disarium
position is equal to the number itself . Number");
Example: 135 = 11 + 32 + 53 else
Hence, 135 is a disarium number. System.out.print( w \n Not a
Disarium Number t t );
Design a class Disarium to check if a given
}
number is a disarium number or not. Some of the
member of the class are given below: static void main( )
{ System.out.println("Input a
Class : Disarium Number");
Data members/instance variables: int m = sc.nextlnt ();
int num : stores the number Disarium x = new Disarium (m);
x.countDigits( );
int size : stories the size of the number
x.check( );
Method/Member functions:
Disarium (int : parameterized constructor to } [ISC Marking Scheme, 2016]
nn ) initialize the data member n =
nn and size = 0
void count : counts the total number of Examiner's Comments
Digit() digits and assigns it to size
i n t : returns the sum of the digits of Most candidates answered this question correctly.
s u m o f D i g i t s the number (n ) to the power of Common errors made by the candidates were:
(int n, int p) their respective positions ( p) The concept of recursion was not clear to some
using recursive technique. candidates.
void check ( ) : checks whether the number
Some did not use the parameters in the function.
is a disarium number and
displays the result with an A few candidates wrote the function sum of Digits
appropriate message () without using the recursive technique.
Specify the class Disarium giving the details of Several candidates had problem in decrementing
the constructor(), void count Digit (), int sum of the power parameter in the recursive function.
Digits(int, int) and void check() . Define the main () The other function including the constructor was
function to create an object and call the functions well answered. Some candidates did not write the
accordingly to enable the task. [ISC, 2016] main () function.
Ans. import java.util.Scanner;
public class Disarium
{ int num, size;
Answering Tips
static Scanner sc = new Scanner(System.
in); w Students must practice on solving programs using
recursive techniques. They must have sufficient
Disarium (int nn)
knowledge about base case and recursive case in
{ num = nn; recursive programs.
size = 0; }
w Students should learn how to create recursive
void countDigit ( )
code for most iteration cases.
I
Q . 15. A class SeriesSum is designed to calculate the
PROGRAMMING IN JAVA
These questions are for practice and their solutions are available at the end of the chapter
PROGRAMMING IN JAVA 127
I TopiC- 3
Revision Notes
Arrays
Concepts covered: Arrays; Array implementation; Single and multi
dimensional arrays; calculating size and address of arrays.
> Arrays are the type of data structure which store a fixed-size sequential collection of elements of the same type.
An array is used to store a collection of data and also a collection of variables of the same type.
> -
One Dimensional Arrays
-
A one-dimensional array is, essentially, a list of like typed variables. To create an array, you must first create an
array variable of the desired type.
The general form of a one-dimensional array declaration is:
_
type var name[ ] ;
Here, type declares the base type of the array. The base type determines the data type of each element that
comprises the array. Thus, the base type for the array determines what type of data the array will hold.
For example, the following declares an array named month days with the type "array of int":
_
int month days[ ] ;
> Multidimensional Arrays
In Java, multidimensional arrays are actually arrays of arrays. There are a couple of subtitle differences. To
declare a multidimensional array variable, specify each additional index using another set of square brackets. For
example, the following declares a two-dimensional array variable called twoD.
int twoD[][] = new int[4] [5] ;
This allocates a 4 x 5 array and assigns it to twoD. Internally this matrix is implemented as an array of arrays of
int. The following program numbers each element in the array from left to right, top to bottom, and then displays
these values:
// Demonstrate a two-dimensional array,
class TWoDArray {
public static void main (String args[]) {
int twoD[][] = new int [4][5] ;
int i, j, k = 0;
for (i=0; i<4; i++)
for ( j =0; j<5; j++) {
twoD[i][j] = k ;
k ++;
}
for (i=0; i<4; i++) {
for ( j =0; j<5; j++)
128 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
System.out.print(twoD[i] [j] + " ");
I
System.out.printlnO ;
|Key Terms
> An array is a group of like-typed variables that are referred to by a common name. Arrays of any type can be
created and may have one or more dimensions. A specific element in an array is accessed by its index. Arrays
offer a convenient means of grouping related information.
> An array of objects is created like an array of primitive type data items.
Examiner's Comment
Examiner's Comment
r
- Some candidates wrote the answer directly
without sharing the working. A few candidates
w A number of candidates were confused with the
made mistakes in Calculation while others wrongly
width of the cell and assumed different values.
determined Row Major instead of Column Major.
Some wrote the answer directly without sharing
the working or mentioning the formula.
-YiY- Answering Tip
Answering Tip
r
- More practice should be alone in calculating
addresses using both Row major and column
w Size of various data types must be explained as it
major wise. The different terms used in address is necessary in such types of questions. Formula
calculation must be learnt.
and working should also be shown.
These questions are for practice and their solutions are available at the end of the chapter
132 Oswaal ISC Question Bank Chapterwise & TopLcwLse, COMPUTER SCIENCE, Class-XII
Q. 6. An array AR[- 4...6, - 2...12] stores elements in
I
1144 = 1098 + 2[(m(5 - 1) + (4 - 1))]
row major wise, with the address AR[2][3] as
4142. If each elements requires 2 bytes of storage,
=> 1144 - 1098 = 2[(m(4) + (3))]
46
find the base address. [ISC 2014] => 2
= 4m + 3
Ans . Given array, AR ]- .. .6, -2 . ... 12]
Row wise order,
^ => 23 - 3 = 4m
20
Add[2][3] = B + W[n(I - Lr) + ( j - Lc)] => 4
=m
B=? => m=5
Given 1 = 2, J = 3, W = 2 bytes Q. 10. A character array B[7][6] has a address 1046 at 0,
Add [i][ j ] = 4142 0. Calculate the address at B[2][3] if the array is
To find n, stored column major wise. Each character requires
n = Uc - Lc + 1 = (12 - (-2) + 1 two bytes of storage. [ISC 2010]
= 12 + 2 + 1 = 15 Ans. Given, Add [2][3]
n = 15 i = 2, j = 3, Lr = 0, B = 1046, Lc = 0, W = 2, n = 7
Now, Column Wise,
4142 = B + 2[15(2 - (- 4)) + (3 - (-2)) ] B[2][3] = B + W[(i - Lc) + n(j - Lr)]
4142 = B + 2[15(2 + 4) + 3(3 + 2) ] = 1046 + 2[(2 - 0) + 7(3 - 0)]
4142 = B + 2[90 + 15] = 1046 + 2 (2 + 21) = 1046 + 46
4142 = B + 190 B[2][3] = 1092
B = 4142 - 190 = 3952
Q. 11. Each element of an array A[20][10] requires two
[ISC Marking Scheme 2014] bytes of storage. If the address of A[6][8] is 4000,
Q. 7. A square matrix M[ ][ ] of size 10 is stored in the find the base address at A[0][0] when the array is
memory with each element requiring 4 bytes of stored as row major wise. [ISC 2009]
storage. If the base address at M[0][0] is 1840, Ans. Given, Address of A[6][8] = 4000
determine the address at M[4][8] when the matrix
n = Uc - Lc + 1 = 1 0 - 0 + 1 = 11
is stored in row major wise. | <f [ISC 2013] W = 2, i = 6, j = 8, Lr = Lc = 0
Q. 8. A matrix B[10][7] is stored in the memory with The base address of A[0][0] row major wise is
each element requiring 2 bytes of storage. If the calculated as follows:
base address at B[x][l] is 1012 and the address at
A[6, 8] = B + W[n(i - Lr) + (j - Lc)]
B[7][3] is 1060, determine the value 'x' where the
matrix is stored in column major wise. [ISC 2012] => 4000 = B + 2[11(6 - 0) + (8 - 0)]
Ans. i = 7, j = 3, W = 2, B = 1012, m = 10 = > 4000 = B + 2[11 x 6 + 8]
Add[i][j] = 1060 => 4000 = B + 148
Column wise, => B = 4000 - 148 = 3852
Add[i][j] = B + W[m(J - Lc) + (I - Lr)] Q. 12. A two dimensional array defined as X[3 ... 6, -2
>= 1060 = 1012 + [(3 - 1)*10 + (7 - x)] x 2 ... 2] requires 2 bytes of storage space for each
element If the array is stored in row-major order,
>= 1060 = 1012 + [20 + (7 - x)] x 2
determine the address of X[5, 1] given the base
1060-1012 = 40 + 14 - 2x
addresses as 1200. [ISC 2008]
48 - 40-14 = - 2x
Ans. According to row-major,
8 - 14 = - 2x
2x = 6
B + W[n(p - Lr) + (i - Lc)]
x =3 Given, B = 1200, W = 2 byte, i = 5, j = 1, Ur = 6,
Q. 9. A square matrix A[m x m] is stored in the
Uc = 2, Lr = 3, Lc = -2
n(number of columns)
memory with each element requiring 2 bytes of
storage. If the base address A[l][l] is 1098 and the = Uc - Lc + 1
address at A[4][5] is 1144, determine the order of n = 2 - (-2) + 1 = 5
the matrix A[m x m] when the matrix is stored Address of X[5][l]
column major wise. [ISC 2011] = 1200 + 2[5(5 - 3) + (1 - (-2))]
Ans. Given, i = 4, j = 5, B = 1098, Lr = 1, Lc = 1, W = = 1200 + 2[5(2) + 3]
2, m = ? = 1200 + 2 x (10 + 3)
Add[4][5] = 1144 = 1200 + 2 x 13
Column wise, = 1200 + 26
Add[4][5] = BA + [m(j - Lc) + (i - Lr)] Add[5][l] = 1226
||
* These questions are for practice and their solutions are available at the end of the chapter
I
Q. 13. Each element of an array X[-15 ... 10, 15 ... 40]
PROGRAMMING IN JAVA
may be replaced by a statement/ expression so
133
requires one bytes of storage. If the array is that the function works properly.
stored in column major order with the beginning void select sort (int [ ] a)
location 1500, determine the location of [5, 20].
[ISC 2007]
int i, j, t , min , minpos ;
Ans. Given, Base Address (B) = 1500
for (i = 0; i < ?1? ; i ++)
Element Size (W) = 1, Lr = - 15, Lc = 15, Ur = 10
Number of Rows (m)
min = a [i];
= Ur - Lr + l minpos = i;
= 10 - (-15) + 1 = 26 for ( j = ? 2 ? \ j < a .length ; j++)
Therefore, the address of X[15, 20] in column major
order {
if (min > a [ j])
= B + W[m(j - Lc) + (i - Lr)]
{
= 1500 + 1[26 (20 - 15) + (5 - (-15))]
? 3 ? = j;
= 1500 + 1(130 + 20)
min = ? 4 ? ;
= 1500 + 130 + 20
X[5][20] = 1650
Q. 14. In an array of real numbers ARR[25][25], ARR[1]
[1] is stored is location 1000. Find the address of t = a [minpos];
ARR[12][12] when the array is stored row major a [minpos] = a [i] ;
wise. Assume each real number requires 4 bytes. a [i] = ? 5 ?
[ISC 2006] }
Ans. Given, Arr[25][25] for (int k = 0 ; k > a.length ; k ++)
i = 12, j = 12, W = 4, B = 1000 System.out.println(a [k]) ;
Row wise,
Arr[12][12] = B + W[n(I - Lr) + (j - Lc)] (i) What is the expression or statement at ?1?
= 1000 + 4[25(12-1) + (12-1)] (ii) What is the expression or statement at ?2?
= 1000 + 4 [25 x 11 + 11] (iii) What is the expression or statement at ?3?
= 1000 + 4 [275 + 11] (iv) What is the expression or statement at ?4?
= 1000 + 1144 (v) What is the expression or statement at ?5?
Arr[12][12] = 2144 Ans. (i) ?1? = a.length - 1
Q. 15. An Array ARR[10][15] is stored in memory with (ii) ?2? = i + 1
each element requiring 2 bytes of storage. If the (iii) ?3? = minpos
first element ARR[0][0] is stored at the location
(iv) ?4? = a[j]
1250, calculate the location of ARR[5][3] when the
array is stored row major wise. [ISC 2005] (v) ?5? = t
Ans. Row major wise Q. 2. The following function is a part of some class.
ARR[i][j] = B + [n(i - Lr) + (j - Lc)] It sorts the array a[ ] in ascending order using
insertion sort technique. There are some places in
Given, B = 1250, W = 2 bytes, i = 5, j = 3, Lr = 0, the code marked by ?1?, 72?, 737, 747, 75? which
Lc = 0, Ur = 9, Uc = 4, must be replaced by expression/statement so that
n = Uc - Lc + 1 the function works correctly, [ISC 2010]
= 15 - 0 + 1 = 16 void insertosort (int a [ ])
ARR[5][3] = 1250 + 2[16(5 - 0) + (3 - 0)]
= 1250 + 2 (80 + 3) int m = ?1? ;
= 1250 + 2 x 83 int b, i , t;
= 1250 + 166 = 1416 for (i = ? 2 ? ; i < m ; i++)
Long Answer Type {
<©> Questions (5 marks) t = a [i] ;
b = i - 1;
Q. 1. The following is a function of some class which while ( ? 3? > = 0 && t < a [b])
sorts an integer array a[ ] in ascending order using
selection sort technique. There are some places in
the code marked by 717, 727, 737, 747, 75? which a [b + 1] = a [b]
134 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
?4? {
I
n = nn;
? 5 ? = t; }
void fillarrayO
{ arr = new int[n];
}
System.out.println("Enter " + n +
(i) What is the expression or statement at ?1? "elements");
(ii) What is the expression or statement at ?2? for(inti = 0;i < n;i + + )
(iii) What is the expression or statement at ?3? arr[i] = x.nextlnt();
(iv) What is the expression or statement at ?4? }
(v) What is the expression or statement at ?5? void sort()
Ans. (i) int m = a.length; {
int t;
(ii) i=1
for(int i = 0;i < n-l;i + + )
(iii) b> = 0
for(int j = 0;j < n-l-i;j + + )
(iv) b ;— { if (arr[ j] > arr[ j + l ])
(v) a[b] { t = arr[ j];
arr[j] = arr[ j + l];
Very Long Answer Type
arr[j + l ] = t;
Questions (10 marks) }
Q. 1. Design a class BinSearch to search for a particular }
value in an array. }
Some of the members of the class are given below: _
int bin search(int l,int u, int v )
{
Classname : BinSearch
int m = (l + u)/2;
Data members/instance variables:
if (arr[m] = = v)
arr[ ] : to store integer elements
return m;
n : integer to store the size of the else if (l > u)
array return -1;
Member functions/methods: else if (arr[m] > v)
BinSearch ( int nn) : parameterized constructor to _
return bin search(l,m-l,v);
initialize n = nn else
void fillarray( ) : to enter elements in the array _
return bin search(m + l,u,v);
void sort( ) : sorts the array elements in }
ascending order using any static void main()
standard sorting technique {
_
int bin search(int l,int u,int v) BinSearch obj = new BinSearch(5);
: searches for the value V obj.fillarrayO;
using binary search and obj.sort();
recursive technique and System.out.printlnf location: " +
returns its location if found _
obj.bin search(0,4,20) );
otherwise returns -1 }
Define the class BinSearch giving details of the }
constructor ), void fillarray( ), void sort( ) and Q. 2. A class Admission contains the admission numbers
int bin_search(int,int,int). Define the main( ) of 100 students. Some of the data members/member
function to create an object and call the functions functions are given below: @1 [ISC 2015]
accordingly to enable the task.
Ans. import java.util.*; Class : Admission
class BinSearch Data member/instance variable:
{ Adno[] : integar array to store
int arr[]; admission numbers
int n; Member functions/methods:
static Scanner x = new Scanner(System.in); Admission ( ) constructor to initialize the
BinSearch(int nn) array elements
These questions are for practice and their solutions are available at the end of the chapter
I void fill Array : to accept the elements of the { m = mm;
PROGRAMMING IN JAVA 135
These questions are for practice and their solutions are available at the end of the chapter
I PROGRAMMING IN JAVA
The details of the members of the class are given
137
} num [i] = 0;
} freq [i] = 0 ;
void disparray ( ) }
142 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Q. 11. A class Collection contains as array of 100
I
void enter Q throws IOException integers. Using the following class description
create an array with common elements from two
integer arrays. Some of the members of the class
BufferedReader br = new BufferedReader
(new InputStreamReader(System .in)) ;
are given below: $
[ISC 2008]
int i; Class Name Collection
for (i = 0; i < 50; i++) Data members/instance variables
arr[ ] integer array
System.out.prin tin len length of the array
(“Enter the number ”) ;
Member functions
num [i] = Integer.parselnt
(br. readLine ( )) ; Collection ( ) default constructor
} Collection parameterized constructor to
} (int) assign the length of the array
void frefac( ) void inparr ( ) to accept the array elements
Collection returns a Collection
int i; common containing the common
for (i = 0; i < 50; i++) ( Collection ) elements of current Collection
object and the Collection
object passed as a parameter
freq [i] = 0;
void arrange () sort the array elements of the
for (int j = 2; j < num [i] ; j++)
object containing common
elements in ascending order
if (num [i] % j==0 && isprime( j) ==l) using sorting technique.
void display () displays the array elements
freq [i] += 1;
Specify the class Collection giving the details of
the constructors, void inparr() and void arrange (),
Collection common (Collection). You need not to
} write the main function.
} Q. 12. Design a class change to convert a decimal
int isprime (int n) //method number to its equivalent in base 16 and to convert
it back to its decimal form, e.g., [ISC 2007]
for (int i = 2; i < n ; i++) (i) The decimal number 35 is 23 in base 16.
(ii) The decimal number 107 is 6B in base 16.
if (n %i==0) Some of the members of the class are given below:
return 0 ;
Class Name Change
}
Data members/instance variables
return 1;
} a[ ] integer type array
void disp( ) //method n integer to be converted to base 16
Member functions
System.out.prin tin change ( ) constructor to assign 0 to
(“ Number\t frequency”) instance variables
for (int i = 0; i < 50 ; i++) void input accept integer to be converted to
0 base 16
System.out.prin tin void to convert decimal integer to
(num [i] + “\t” + frq[i]) ; hexadeci hexadecimal form
} (int )
void to convert hexadecimal number
decihexa () back to decimal form
These questions are for practice and their solutions are available at the end of the chapter
I Specify the class change giving the details of
PROGRAMMING IN JAVA
if (a [i] > 0)
143
break;
Data members/instance variables
arr [ ] integers
}
item numbers to be searched in the
if (k ==0)
array
{
Member functions/methods
arr [i] = x ;
void indata ( ) input 50 integers (no
to
duplicate numbers are to be
entered)
void to sort the array in ascending
void bubsort ( ) // method
bubsort( ) order using the bubble sort
technique and to display the
sorted list int t , i;
void to input item and search for for (i = 0; i < 49; i++)
binsearch ( ) it using the binary search
technique, if found to print the for (int j = 0; j < 49 - i; j++)
item searched and its position
in the sorted list, otherwise to if (arr [ j] > arr [ j + 1])
print an appropriate message. { t = arr[ j] ;
Specify the class Sort giving the details of the arr [ j] = arr[j + l] ;
functions void inpdata(). boid bubsort() and void arr[j + 1] = t;
binsearch(). The main function need not to be
}
written.
}
Ans. import java .io.*;
class Sort //class name sort
System.out.println (“Sorted Array”)
for (i = 0; i < = 49; i++)
int item ;
int arr[ ] ;
System.out.pritln(arr [i]) ;
Sort ( ) //constructor
//printing the array
}
arr = new int [50]
}
//declare array size dynamically
void binsearch ( ) throw IOException
void inpdata ( ) throw IOException
InputStreamReader inp = new
InputstreamReader (System.in) ;
InputStreamReader inp = new Input
BufferedReader br = new BufferedRader
StreamReader (System.in) ;
(inp) ;
BufferedReader br = new BufferedReader
int b, e, m , pos = - 1;
(inp) ;
b = 0;
int x , k ;
e = arr.length - 1;
for (int i = 0; i < = 49 ; i++)
System.out.println(“ Enter Item to be
{
search ”) ;
k = 0;
item = Integer. parseInt (br. readLine ());
x = Integer. parseInt (br. readLine ()) ;
while (b <= e)
for (int m = 0; m < = i; m ++)
m = ( b + e) / 2 ;
if (arr[m] ==x)
if (arr[m] ==item)
System.out.println
pos = m + 1;
( “ Duplicate Item ’’) ;
break;
k = 1;
146 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
else Class Name IndexArray
I
Data members/instance variables
if (arr[m ] < item)
b = m + 1; ar [ ] integer
else Member functions/method
e = m - 1; indexarray ( ) to assign the code to 0
}
void sortarr ( ) to sort the array variable
using selection sort
if (pos== 1) — technique
System.out.println (“ Item Not Found”) ;
else int to search and return 1 if an
System.out.println(“ Item found at” binarysearch employee code is found in
+pos) ; (int[ ]. int) the array object otherwise
return 0
Specify the class indexed array giving details of
Q. 15. Class indexed array contains the employee code the constructor, void sortarr (), int binarysearch ().
of 100 employees. Some of the member function/ You may assume, other assumes, other functions
are written for you and you do not need to write
data members are given below: |§|[ISC 2005]
the main function.
Strings
Topic -4 Concepts covered: Strings (declaration and initialization; String class
methods and functions; String buffer
>
m Revision Notes
In java, string is basically an object that represents sequence of char values. An array of characters works same as
java string. For example:
char[] ch ={' j' , 'a ' , V / a ' / t' / p' / o' / i' / n' / t'};
String s=new String(ch);
is same as:
String s="javatpoint” ;
> Java String class provides a lot of methods to perform operations on string such as compare(), concat(), equals(),
split(), length(), replace(), compareTo(), intern(), substring() etc.
> The java.lang.String class implements Serializable, Comparable and CharSequence interfaces.
Serializable Comparable Charsequence
*
implements
String
> How to create String object?
There are two ways to create String object:
By string literal
By new keyword
(1) String Literal
Java String literal is created by using double quotes. For Example:
String s = "welcome";
Each time you create a string literal, the JVM checks the string constant pool first. If the string already exists
in the pool, a reference to the pooled instance is returned. If string doesn't exist in the pool, a new string
instance is created and placed in the pool. For example:
These questions are for practice and their solutions are available at the end of the chapter
I String sl ="Welcome";
PROGRAMMING IN JAVA 147
These questions are for practice and their solutions are available at the end of the chapter
152 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Specify the class Mystring giving the details of else
I
the constructor and void readString(). int code(int s = s + c;
index), void word ( ) only. The main function
need not to be written.
System.out.println(“longest word is ” +s) ;
Ans. import java .io.*;
}
class Mystring //class name
}
Q. 6. Design a class Stringfun to perform various
String str;
operations on strings without using built in
int len ; functions for finding the length of the string.
Mystring ( ) Some of the member functions/data members are
given below:
str = Class Name Stringfun
len = 0;
Data members/instance variable
str to store the sting
void readString() throws IOException
Member functions/ methods
InputSreamRader in = new InputStream void input( ) to accept the string
Reader (System.in) ; void words( ) to find and display the
BufferedREader br = new Buffered number of words, number
of vowels and number of
Reader (in) :
uppercase characters in
System.out.println(“ Enter string”) ;
the string
str = br.readline ( );
void frequency! ) to display frequency of
len = str.length ( ); each character within the
string .
int code (int index)
Specify the class Stringfun giving the details of
the functions void input (). void words and void
if (index >= len) frequency! )• You do not need to write the main
{ function.
System.out.println(“ Invalid Index ”) ; Ans. import java , io.*;
return - 1; class Stringfun //class name
c = word.charAt(i);
155
c!=='o' || c=='u ’)
Class Name : ConsChange s += c;
Data members/instance variables: System.out.print("\n shifted Word
word : stores the word =" +s);
word = s;
len : stores the length of the }
word void changeword( )
Member functions/methods:
{ char c; String s = "
for (int i = 0; i < len; i++)
ConsChange () : default constructor c = word.chartAt(i);
void readwordQ accept the word in
: if(c!= 'a * && c! = 'i * && c! = 'o'
lowercase && c!= ’ u'&& c! = 'e ’ )
s += (char)(c - 32);
void shifticonsQ : shifts all the consonants
else
of the word at the
s += c;
beginning followed by
}
the vowels (e.g. spoon
becomes spnoo ) System.out.printIn("\n Changed
word ="+s);
void changeword ( ) : changes the case of all }
occurring consonants
void show ( )
of the shifted word
to uppercase, for System.out.print("\n Original ="
e.g., ( spnoo becomes +word);
SPNoo ) shiftcons( );
changeword ( );
void show ( ) : displays the original
}
word, shifted word and
the changed word static void main( )
Cons Change X = new ConsChange ( );
Specify the class ConsChange giving the details X.readword ( );
of the constructor (), void readword( ), void X.show ();
shifticons (), void changewordQ and show () . }
Define the main( ) function to create an object and
call the functions accordingly to enable the task. } [ISC Marking Scheme 2016]
These questions are for practice and their solutions are available at the end of the chapter
PROGRAMMING IN JAVA 157
File Handling
Concepts covered: Types of files; Opening and reading and writing files;
File handling methods
Revision Notes
> File handling is an essential part of any programming language. Using files, a program can store data on a storage
device.
> To perform various actions on a file, such as read, write, and so on.
Why File Handling is Required?
> File Handling is an integral part of any programming language as file handling enables us to store the output of
any particular program in a file and allows us to perform certain operations on it.
> In simple words, file handling means reading and writing data to a file.
Streams in Java
> In Java, a sequence of data is known as a stream.
> This concept is used to perform I/O operations on a file.
> There are two types of streams :
1. Input Stream:
2. Output Stream:
• The input stream is used to read data from numerous input devices like the keyboard, network, etc.
InputStream is an abstract class, and because of this, it is not useful by itself. However, its subclasses are used
to read data.
Creating an InputStream
// Creating an InputStream
InputStream obj = new FileInputStream() ;
Here, an input stream is created using FilelnputStream.
• The output stream is used to write data to numerous output devices like the monitor, file, etc. OutputStream
is an abstract superclass that represents an output stream. OutputStream is an abstract class and because of
this, it is not useful by itself. However, its subclasses are used to write data.
Creating an OutputStream
// Creating an OutputStream
OutputStream obj = new FileOutputStream() ;
Here, an output stream is created using FileOutputStream.
> Methods for file handling:
S.No. Method Description
1. public void close() throws IO Exceptions{} This method closes the file output stream. Releases
any system resources associated with the file. Throws
an IO Exception.
2. public void finalizeQ throws IO Exception!} This method cleans up the connection to the file.
Ensures that the close method of this file output
stream is called when there are no more references to
this stream. Throws an IO Exception.
3. public void write(int w) throws IO Exception!} This method writes the specified byte to the output
stream.
4. public void write(byte[] w) Writes w.length bytes from the mentioned byte array
to the OutputStream
158 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
I
|Key Terms
> File handling in Java means to read from and write to file in Java. It provides the basic I/O package for reading
and writing streams.java.io package allows to do all input and output tasks in Java.
> Java.io package contains the inbuilt Java classes and predefined methods using which you can read from and
write data to file.
> Byte stream classes are as follows: InputStream, OutputStream, FilelnputStream, FileOutputStream,
ByteArraylnputStream, ByteArrayOutputStream, PrintStream, RandomAccessFile etc.
> Methods defined by InputStream: read /), read (byte[] r), available(), close/), etc.
> Methods defined by OutputStream: write(int w), write(byte[] w), finalize /), close/), etc.
..
Q 1 What are Java stream classes? ..
Q 3 What do you mean by String Tokenizer? Also
.
Ans In java, I/O facility is based on stream. Stream is a
write the syntax .
continuous flow of data. The InputStream is used .
Ans The java.util.StringTokenizer class allows an
to read data from a source and the OutputStream application to break a string into tokens. The
is used for writing data to a destination. processing of text often consists of parsing a
formatted input string. Parsing is the division of
The java.io package contains a large number
text into a set of discrete parts or token.
of stream classes that provide capabilities for
processing all types of data. Java stream classes Syntax
may be categorized into two groups based on the StringTokenizer (String str) ;
data type on which they operate: or
(i) Byte Stream Classes that provide support for StringTokenizer (String str, String delim);
handling I/O operations on bytes. Q. 4. Write a Java program using nextToken( ) method.
(ii) Character Stream Classes that provide support
for managing I/O operations on characters. ..
Q 5 Name the interfaces used inside the package of
..
Q 2 Define appending to text file with example . awt print.
.
Ans Appending to text file means, retaining the old Ans. The java.awt.print consists of the following
contents and append the new contents. interface:
Syntax (i) Pageable represent a set of pages to be printed.
FileWrite cObject name> = new FileWrite (ii) Printable implement a page painter.
(<filename> , true) ; (iii) Printer Graphics provides the getPrinterJob( )
method to obtain the printer job.
I Topic- 6
Exception Handling S JVM
Concepts covered: Exceptions and their types, functions for exception
handling, JVM . JDK
m
>
Revision Notes
An exception is an abnormal condition that arises in a code sequence at run time. In other words, an exception
is a run-time error. In computer languages that do not support exception handling, errors must be checked and
—
handled manually typically through the use of error codes, and so on. This approach is as cumbersome as
it is troublesome. Java's exception handling avoids these problems and, in the process, brings run-time error
management into the object oriented world.
> Exception Handling: A Java exception is an object that describes an exceptional (that is, error) condition that
has occurred in a piece of code. When an exceptional condition arises, an object representing that exception is
created and thrown in the method that caused the error. That method may choose to handle the exception itself,
or pass it on. Either way, at some point, the exception is caught and processed. Exceptions can be generated
by the Java run-time system, or they can be manually generated by your code. Exceptions thrown by Java
relate to fundamental errors that violate the rules of the Java language or the constraints of the Java execution
environment. Manually generated exceptions are typically used to report some error condition to the caller of a
method.
> Java exception handling is managed via five keywords: try, catch, throw, throws, and finally.
Program statements that you want to monitor for exceptions are contained within a try block.
If an exception occurs within the try block, it is thrown. Your code can catch this exception (using catch) and
handle it in some rational manner.
System-generated exceptions are automatically thrown by the Java run-time system. To manually throw an
exception, use the keyword throw. A throw is followed by an instance variable.
These questions are for practice and their solutions are available at the end of the chapter
160 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
I
Any exception that is thrown out of a method must be specified as such by a throws clause, throws is followed
by exception class names
Any code that absolutely must be executed after a try block completes is put in a finally block.
> Two types of exceptions are:
(i) Checked exception
(ii) Unchecked exception
> General form of an exception-handling block:
try {
// block of code to monitor for errors
}
catch (Exceptioniypel exOb) {
// exception handler for Exceptioniypel
|Key Terms
> Way of handling anomalies situations in a program-run is known as exception-handling
> Exception handling has three keywords: try, throw and catch
> Program statements that you want to monitor for exceptions are contained within a try block.
> If an exception occurs within the try block, it is thrown. Your code can catch this exception ( using catch) and
handle it in some rational manner.
> System-generated exceptions are automatically thrown by the Java run-time system. To manually throw an
exception, use the keyword throw. A throw is followed by an instance variable.
> A JVM is an abstract computation machine that enables a computer to run a Java program. There are three
notions of the JVM as specification, implementation and instance.
These questions are for practice and their solutions are available at the end of the chapter
162
(ii)
Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
I—: 11
numberl (O) Output-^
int n , rev, f ;
Emirp(int nn) //constructor Emirp .
5 Import java .io.*;
class Happy
n = nn ;
rev = 0; int n ;
f = 2; Happy ( ) //constructor
}
int isprime(int x) n = 0;
{
if (f = = X) void getnum (int nn) //method
return 1; n = nn ;
}
}
else if (x % f = = 0) _ _
int sum sq digits (int x) //method
{
return 0 ;
if (x > = 0 && x <= 9)
return x*x;
else
else
_ _
return (sum sq digits (x%10) + sum _
f ++; _
sq digits(x/10) ;
return (is prime(x)) ;
void ishappy ( ) // method
}
void isEmirp Q // method
int a = 0, num = 0;
{
int C = n ; rev = 0; int R;
_ _
a = sum sq digits (n) ;
while (a > 9)
while (C! = 0)
{
R = C %10; num = sum_sq_digits (a) ;
rev = rev * 10 + R; a = num ;
C = C/10;
if (num== l)
int a = insprime(n); System.out.println (“ Happy no.”) ;
int b = isprime(rev) ; else
if (a == l && b== l) System.out.printlnfnot Happy no.”) ;
System .out.println(n + “number is
Emirp”) ; public static void main (String args []) throws
else IOException
System .out.println(n + “ number is
not Emirp”) ; System.out.printlnfEnter a number”) ;
} BufferedReaderbr = new BufferedReader
public static void main (String args []) (new InputStreamReader(System .in) :
throws IOException int n = Integer.parselnt (br. readLine ()) ;
Happy ob = new Happy () ;
System .out.printlnfEnter value of n ”) ; //object creation
BufferedReaderbr = new BufferedReader ob.getnum (n) ;
(new InputStreamReader(System.in)) ; ob.ishappy ( ) ;
I b = 0;
PROGRAMMING IN JAVA 165
hcf = 0;
.
7 class Magic lcm = 0;
System.out.print!n ("Enter
value to be searched"); void display ( )
int v = x.nextlr.t ( );
int p = obj.binSearch (C, int i, j;
obj . Adno.length 1, v ); - for (i=0 ; i<m ; i++)
if (p==-l )
System.out .println
("No. not found"); for ( j =0; j<n ; j++)
else {
System.out.println System.out. print (arr [i] [j ] +" ") ;
("No. is present");
}
System.out. println( ) ;
} [ISC Marking Scheme, 2015]
4. import java.io.*;
class Composite
} }
I
} void sortarr ( )
void inparr ( ) throws IOException
int N = ar.length
InputstreamReader ip = int i, j, pos.temp;
new Inputstream Reader (System.in) ; for (i = 0; i < N - 1; i++)
//convert byte to char
BufferedReader br = new Buffered pos = i;
Reader(ip) ; for ( j = i + 1; j < N ; j++)
//create default input size {
System.out.println (“ Enter the ” + len + if (ar[j] < ar[pos])
“elements ”) ;
for (int i = 0; i < len ; i++)
Pos = j;
arr [i] = Integer. parselnt (br.
readLineQ) ;
temp = ar[i] ;
ar [i] = ar[pos] ;
ar [pos] = temp;
Collection common (Collection a)
}
// method
CHAPTER INHERITANCE,
INTERFACES,
4 POLYMORPHISM,
DATA
STRUCTURES
(a ) Inheritance; super and derived classes; member access in derived classes;
redefinition of variables and methods in subclasses, abstract classes, class
object, protected visibility. Subclass polymorphism and dynamic binding.
| (b ) Interfaces in Java, Implementing interfaces through a class; interfaces for user defined implementation
j of behaviour.
*Note- These Concepts are only for your reference. Questions from these parts will not be asked in the Final Examination.
I Tonic -1
^
Inheritance
Concepts covered: Inheritance: Super
class: Sub class; Visibility Mode: Method
overriding: Super keyword
Topic- 1
Inheritance
Topic-2
Interfaces
.
Page No 172
.
Page No 190
Revision Notes
> Inheritance is a mechanism in which one object acquires all the properties and behaviours of a parent object.
> Derivation: It is the relationship between a base class and derived class. It is also known as inheritance hierarchy.
> Inheritance graph: A derivation from multiple base classes is known as inheritance graph.
> Subclass: It is the derived class and its declaration must include name of its base class.
> Base class: It is the base class or the class from which the sub class is derived.
> Class object: It is a class defined in java.lang package and every class that we define is a subclass of this class.
> Only single inheritance, hierarchial and multi level inheritance can be implemented in Java.
> Every class in Java has only one immediate or direct superclass.
> Inheritance relation is transitive, i.e., every class inherits states and behaviour from all superclasses which are
higher in class hierarchy.
I INHERITANCE, INTERFACES, POLYMORPHISM, DATA STRUCTURES 173
>
ts
x
2 -3 ^>
N
i 14 1
I III
J J J
EHEHZI
ctotSupel class
Sub- class-
Constructors
asscann°t inherit
c
°nstruCtor
°f a Base class
Objects of subclass can Use
Base - abstract methods
Over loading I
s1
NJ
(
^ tetirne )
/pe<
V «A0 $ > >
3g
up
174
>
Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE Class-XII
Forms o£ inheritance
. I
Single inheritance: When a subclass inherits from only one base class, and there are only 2 classes in this
relationship, then it is known as single inheritance.
Base class
Multilevel inheritance: When a subclass inherits from a class that itself inherits from another class, it is known
as multilevel inheritance.
Base class of Y
Sub class of X
Base class of Z
Sub class of Y
Multilevel inheritance
Multiple inheritance: When a subclass inherits from multiple base classes it is known as multiple inheritance.
Java does not support multiple inheritance.
Sub class
Multiple inheritance
Hierarchical inheritance: When many subclasses inherit from a single base class it is known as hierarchical
inheritance.
Hierarchical inheritance
> Hybrid Inheritance: When a subclass inherits from multiple base classes and all of its base classes inherit from a
single base class it is hybrid inheritance.
> -
Variables in superclass having the same names as variables of sub class are hidden.
> Methods in superclass with same name as that of member methods of subclass are overridden.
> To refer to hidden data members and overridden methods of superclass 'super' keyword is used.
> Overriding the inherited method: If two method of the base and the derived class have the same signature then
the subclass method hides or overshadows the base class method. This is called overriding the inherited member.
I> INHERITANCE, INTERFACES, POLYMORPHISM, DATA STRUCTURES
Constructor of super class are not inherited by sub classes.
175
> Default constructor of the super class is automatically invoked before any statements within the constructors are
executed.
> Polymorphism is Java is a concept by which we can perform a single action in different way.
> Polymorphism means many forms.
> There are two types of polymorphism in Java:
Compile Time polymorphism
RunTime Polymorphism
> Two ways to implement polymorphism in Java are:
(a) Method Overloading
(b) Method Overriding
> Method overloading is one of the ways through which java supports polymorphism. Method overloading can be
done by changing number of arguments or by changing the data type of arguments. If two or more method have
same name and parameter list but differs in return type they are not overloaded method
> Method Overriding: If subclass (child class) has the same method as declared in the parent class, it is known as
method overriding in Java.
> It is used to provide the specific implementation of a method which is already provided by its superclass, and it
is used for runtime polymorphism.
|Key Terms
> Inheritance: One object acquires the properties of another object
> Polymorphism: Ability to take more than one form
Constructor chaining - phenomena of calling one constructor from another constructor of same class.
> Inline functions: The compiler replaces the function statement with the function code itself (expansion) and then
compiles the entire code.
> Concrete superclass: It is the class whose objects can be declared and created.
> Abstract class: It is the one that represents a concept only. It's objects can't be created.
> Keyword abstract is used to create an abstract class.
> Abstract methods: The methods have no method statements and are declared using abstract keyword.
> Extends is the keyword used to inherit the properties of a class
> The implements keyword is used with classes to inherit the properties of an interface.
> This keyword is used to refer to current object.
> Super keyword is used to refer to immediate parent class of a class.
> Overriding: To override the functionality of an existing method.
Examiner's Comment
Examiner's Comment
w A number of candidates were not aware of the
w Examples were used for a number of candidates advantages of inheritance. Some used examples
to show the difference. In some cases, only 'super' while others explained in their own words. A few
keyword was explained. candidates wrote the definition instead of the
advantages.
INHERITANCE, INTERFACES, POLYMORPHISM, DATA STRUCTURES 177
In Java programming, inheritance used as:
Answering Tip (i) Similarities: Whenever there are similarities
between two more classes, apply inheritance.
w Advantages and need for inheritance should be ii
( ) Extraction: If a new class to be defined has
learned properly. certain features in addition to the features of
an existing class, use inheritance and code
only the additional features of this new class.
Detailed Answer: (iii) Combination: If a class is inherited from
Following are the advantages of inheritance: more than one class, it results in multiple
(i) Reuse the existing code and extend the inheritances. Multiple inheritance combine
functionally. features from more than one existing class.
(ii) Add new members to the derived class to Q. 6. What is meant by visibility mode in the definition
specialize the class. of derived classes in Inheritance? Explain any two
(iii) Replace the implementation of existing visibility modes available. [ISC 2007]
methods by overriding a method that already Ans. Visibility mode in case of derived classes modifies
exists in the base class. the accessibility of the superclass member in the
Q. 3. Define encapsulation and polymorphism. derived class. Two visibility modes available are
[ISC 2006] explained below:
Ans. Encapsulation: It is the mechanism that binds Protected Members are accessible inside their
own class as well as in all subclasses of their class,
together code and the data it manipulates.
Encapsulation is the wrapping up of data and regardless of whether subclasses exist in the same
methods into a single unit (called class). package or any other package.
Private Members are accessible only to the class in
which it is defined.
Class
Liquid
I Long Answer Type
Method Data Coffee Milk
Questions -I (5 marks)
Q. 1. A super class Product has been defined to store
Polymorphism
Encapsulation the details of a product sold by a wholesaler to a
retailer. Define a sub class Sales to compute the
Polymorphism: It means the ability to take more total amount paid by the retailer with or without
than one from, i.e., the same operation may behave fine along with service tax. [ISC 2017]
differently in different situations.
Class name : Product
Q. 4. How can we override a method in inheritance? Data member/instance variable:
[ISC 2011] name stores the name of the
Ans. Overriding: Overriding is the ability to define a product
behaviour specific to the subclass type which means code integer to store the
a subclass can implement a parent class method product code
based on its requirement. Overriding means to amount stores the total sale
override the functionality of an existing method .
amount of the product (in
Rules for Method Overriding decimals)
(i) The argument list should be exactly the same Member functions/methods:
as that of the overridden method. Product(String parameterized constructor
(ii) Instance method can be overridden only if n, to assign data member
they are inherited by the subclass. int c, double p ) name = n, code = c and
(iii) A method declared as final cannot be amount = p
overridden. void showQ displays the details of the
(iv) A method declared as static cannot be data members
overridden but can redeclared.
Class name : Sales
Q. 5. Define inheritance. How is it useful in Data member/instance variable:
programming? [ISC 2009]
day stores number of days taken
Ans. Inheritance: It is the ability to derive something
to pay the sale amount
from something generic. Inheritance aids in the
reuse of code, i.e., a class can inherit the features tax to store the service tax (in
of another class and add its own modification. The decimals)
parent class is known as the superclass or base totamt to store the total amount (in
class and the newly created child class is known as decimals)
the subclass or derived class.
178 Oswaal ISC Question Bank Chapterwise & TopLcwLse, COMPUTER SCIENCE, Class-XII
I
Q. 2. A super class Bank has been defined to store the
Member functions/methods:
details of a customer. Define a sub-class Account
Sales ( ... ) : parameterized constructor that enables transactions for the customer with
to assign values to data the bank. The details of both the classes are given
members of both the below:
classes. Class Name : Bank
void : calculates the service tax Data member/instance variable:
compute( ) @ 12.4% of the actual sale name stores the name of the
amount customer
Calculates the fine @ 2.5% accno stores the account number
of the actual sale amount P : stores the principal
only if the amount paid amount in decimals
by the retailer to the Member functions/methods:
wholesaler exceeds 30 days Bank ( ... ) parameterized constructor
calculates the total amount to assign values to the
paid by the retailer as instance variables
(actual sale amount + void display () displays the details of the
service tax + fine ) customer
Q. 3. A superclass Perimeter has been defined to 101-200 60 paisa per call + rental
calculate the perimeter of a parallelogram. charge
Define a subclass Area to compute the area of the 201-300 80 paisa per call + rental
parallelogram by using the required data members charge
of the superclass. The details are given below:
| above 300 1 rupee per call + rental
| [ISC 2013]
charge
These questions are for practice and their solutions are available at the end of the chapter
I Details of both the classes are given below:
INHERITANCE, INTERFACES, POLYMORPHISM, DATA STRUCTURES
address = ad ;
183
telno = t;
Class Name Detail
rent = r ;
Data member/instance variable:
}
name to store the name of the void show()
customer
address to store the address of the System.out.println(“ Name of customer ”
customer + name) ;
telno to store the phone number of System.out.println(“Addres of customer”
the customer +addresses) ;
rent to store the monthly rental Systm.out. println(“Telephone no.”
charge +telno) ;
Member functions:
System.out.println(“ Rent” + rent) ;
below: | §) [ISC 2010] to perform the task. The details of the two classes
are given below:
Class Name Worker
Class Name Library
Data member/instance variable:
Data member/instance variable:
Name to store the name of the worker
name to store name of the book
Basic to store the basic pay in
author to store author of the book
decimals
P to store price of the book in
Member functions:
decimals
worker ( ...) parameterized constructor to Member functions:
assign values to the instance
Library ( ...) parameterized constructor to
variables assign values to data members
void display () display the workers details of both the classes
void show ( ) displays the book details
Class Name Wages
Data member/instance variable: Class Name Compute
hrs store the hours worked Data member/instance variable:
rate stores rate per hour d number of days taken in
store the overall wage of the returning the book to store the
wage
fine
worker
Member functions:
Member functions:
Compute ( ...) parametrized constructor to
Wages ( ...) Parameterized constructor to
assign values to data members
assign values to the instance
of both the classes
variables of both the classes
void fine ( ) calculates the fine for the
double Calculate and returns
excess days
overtime ( ) the overtime amount a
( hours’’ rate )
' void display display the book details
void display Calculate the wage using the
0 alongwith the number of
days, fine and the total (0.2%
0 formula wage = overtime of price of book*total no. of
amount + Basic pay and days) + fine
display it along with the other
details Specify the class Library giving the details of the
constructor and void show( ). Using the concept
Specify the class Worker giving details of the of Inheritance, specify the class Compute giving
constructor and void display( ). Using the concept the details of constructor, void fine( ) and the
of inheritance, specify the class Wages giving void display( ) function. You need not to write the
details of constructor, double overtime( ) and void main( ) function.
display( ). The main( ) function need not to be .
Ans class Library
written.
{
..
Q 7 A library issues books on rental basis at a 2%
String name;
charge on the cost price of the book per day As . String author ;
per the rules of the library, a book can be retained
.
for 7 days without any fine If the book is returned float p;
after 7 days, a fine will also be charged for the Library (String n , String a , float amt)
excess days as per the chart given below: {
[ISC 2009]
name = n ;
author = a ;
Number of Excess Days
1 to 5
Fine per Day ( )
2.00
^ p = amt;
6 to 10 3.00 }
Above 10 days 5.00 void show ( )
{
||
* These questions are for practice and their solutions are available at the end of the chapter
186 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
System.out.println(“ Book Name = ” Q. 8. A class Employee contains employee details and
I
+ name) ; another class Salary calculate the employee's net
Sytem.out.Println ( Author Name = ”
“ salary. The details of the two classes are given
+author) ; below: [ISC 2008]
System.out.println(“ Print = ” + p) ; Class Name Employee
}
Data member/instance variable:
}
class Compute extends Library empNo to store the employee number
empName to store the employee name
int d ;
float f , total; empDesig to store the employee's
Compute (String n , String a , flaot amt, int designation
days) Member functions:
Employee ( ) default constructor
super (n , a , amt) ;
d = days; Employee ( ...) Parameterized constructor to
assign values to employee
f = 0;
number, name and designation
total = (float)((0.2*p)*d) ;
} void display display the employee details
void fine ( ) 0
Class Name Salary
if (d > 7)
Data member/instance variable:
d = d - 7; basic float variable to store the basic
if (d < = 5) pay
Member functions:
f = 2*d ;
Salary (...) parameterized constructor to
assign values to data members
else if (d <= 10)
void calculate () calculate the employee's net
salary according to following
f = 1 0 + ((d - 5)*3);
rules:
} DA = 10 % of basic
else HRA = 15% of basic
Salary = basic + DA + HRA
f = 10 + 15 + ((d - 10)*5); PF = 8% of Salary
Net salary = Salary - PF
Display the employee details
d = d + 7; and the Net salary.
total = total + f ; Specify the class Employee giving details of
} the constructors and member function void
display ( ). Using the concept of inheritance,
void display ( )
specify the class Salary giving details of
{ constructor and the member function void
show ( ) ; calculate( ). The main( ) function needs to be
System.out.println(“ Book taken for = ”+d written.
“ days ”) ; Ans. class Employee
System.out.println( Total fine = Rs. ” +f ) ;
“
System.out.println(“Total amount to be int empNo;
paid = Rs. ” +total) ; String empName ;
String empDesig;
Employee ( )
I INHERITANCE, INTERFACES, POLYMORPHISM, DATA STRUCTURES
register number, name of subject and marks
187
void calculate ( ) The details of both the classes are given below:
Class Name Iscscores
DA = (float)(basic*(0.1)) ; Data member/instance variable:
HRA = (float)(basic*(0.15) ;
int number[6][2] to contain marks for six
float s = basic + DA + HRA; subjects and subject code
PF = (float)(s*(0.08)) ; [numeric]
NS = s - PF;
Member functions:
display ( ) ;
System.out.println(“ Net salary: ” + NS) ; Iscscores( ) Default constructor to accept
the marks
public static void main (String args [ ]) int point ( ) to return the point in each
{ subject according to the
Salary si = new Salary (5000, 101, following:
“Akash ” , “ Manager ”) ; -
Marks > = 90 1 point
sl.calculate ( ) ; -
80-89 2 point
-
70-79 3 point
} -
60-69 4 point
These questions are for practice and their solutions are available at the end of the chapter
188 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
m = 2; return (p);
p=p+m }
}
if ((number[i] [0] > = 70) & & (number[i] Class Bestfour extends Isccores
[0] < = 79))
I INHERITANCE, INTERFACES, POLYMORPHISM, DATA STRUCTURES
Member functions/methods:
189
I Interfaces
Topic - 2 Concepts
Revision Notes
covered: Interface; Implementing Interface; Abstract class
> Interface: An interface in java is a blueprint of a class. It has static constants and abstract methods.
> Extending Interface: An interface can extend another interface in the same way that a class can extend another
class. The extends keyword is used to extend an interface.
> Marker Interface: An empty interface is known as tag or marker interface.
> Nested Interface: An interface which is declared inside another interface or class is called nested interface.
> Use of Java Interface: There are mainly three reasons to use interface:
• It is used to achieve abstraction.
• By interface, we can support the functionality of multiple inheritance.
• It can be used to achieve loose coupling.
|Key Terms
> Interface fields are public, static and final by default, and the methods are public and abstract.
• A class implements an interface, but one interface extends another interface.
}
• Since a java class can implements multiple
interfaces at a time so it's better to use interfaces
Q. 4. WAP to demonstrate the use of multiple interface? as super class in most of the cases.
• The benefit of interface is it allows multiple
Q. 5. How an interface "extends" other interface? inheritance that thing is not possible with
Ans. interface Infl{ concrete classes and abstract classes.
public void method1() ; • With interfaces, implements keyword is to be
} used for implementing. Implements tells the
interface Inf 2 extends Infl { compiler that whatever classes are there after
public void method 2 () ; implementation, they are interfaces.
• An interface gives template structure of methods
public class Demo implements Inf 2{ from which new classes can be developed easily.
/‘Even though this class is only Very Long Answer Type
implementing the ®> Questions
<
(10 marks)
‘interface Inf 2, it has to implement all the
methods Q. 1 An interface Vehicle is defined with the methods
‘ Infl as well because the interface Inf 2
of changeGear(), speedup() and applyBrakes().
extends Infl Create the classes Bicycle and Bike which
7 implements the interface Vehicle.
public void method1(){
The details of the members of interface and both
System.out.println(“ methodl ”) ; the classes are given below:
public void method 2 (){ Interface Name Vehicle
System.out.println(“ method 2 ”) ; Member functions
}
public static void main (String args[]){ changeGear(int a)
Inf 2 obj = new Demo() ; speedupjint a)
obj. method 2 () ; applyBrakes(int a)
}
Class name Bicycle
Q. 6. What is the difference between a class and an Data members
interface in Java? Speed
Ans. Gear
Class Interface Member function
In class you can In an interface, you
, changeGear(int a) to change the gear of
instantiate variable and can't instantiate bicycle
create an object. variable and create an
object. speedup(int a) to increase the speed
of bicycle
Class can contain The interface cannot
concrete (with contain concrete(with applyBrakes(int a) to decrease the speed
implementation) implementation) of bicycle
methods methods Class name Bike
The access specifiers In Interface only one
used with classes are specifier is used- Public. Data members
private, protected and Speed
public. Gear
These questions are for practice and their solutions are available at the end of the chapter
I Member function
INHERITANCE, INTERFACES, POLYMORPHISM, DATA STRUCTURES
// doing some operations
195
Name = n ;
10 Marks Questions Basic = b;
.
3 Class Perimeter
void display ( )
protected double a , b;
System.out.printlnfName is ”+ Name) ;
Perimeter (int aa , int bb)
System.out.printlnfBasic Salary is ”
+Basic) ;
a = aa ;
b = bb;
} class Wages extends Worker
double calculate ( )
int hrs, rate ;
double P; double wages;
P = 2*(a + b) ; Wages (int h , int r, String n , float b)
return P;
} super (n , b) ;
void show ( ) //using the constructor of base class
{ hrs = h ;
double P = calculate () ; rate = r;
System .out.printlnfperimeter of }
parallelogram with Length ” + a + “ and double overtime Q
Breadth ” + b + “is:” + P) ;
return hrs*rate;
}
I void display ( )
INHERITANCE, INTERFACES, POLYMORPHISM, DATA STRUCTURES
{ readLine ( )) ;
wage = overtime ( ) + Basic ; System.out.printlnfEnter subject”) ;
super.display( ); subject = br.readLine ( );
System .out.printlnfHours Worked = System.out.printlnfEnter marks ”);
” +hrs) marks = Integer.parselnt
System .out.printlnfRate per hour (br.readLine ( )) ;
=” + rate) }
System .out.printlnfTotal Wages= ” void show2 ( )
+wages)
} System.out.printlnfReg no. ” +
} regnum + “\nSubject” + subject
9. (i) import java.io.*; + “\nMarks ” + marks) ;
class Student
}
String name, sex; TOPIC-2
int age; 5 Marks Questions
void inpdetailsl( ) throws IOException 4. interface Firstlnterface {
{ public void myMethod () ;
InputSreamReader in = new Input // interface method
StreamReader (System .in) ;
interface Secondlnterface {
BufferedReader br= new Buffered
public void myOtherMethodQ ;
Reader(in) ;
// interface method
System out.printlnfEnter student
.
} // DemoClass “implements”
name ”) ;
Firstlnterface and Secondlnterface class
name = br.readLineO ; DemoClass implements Firstlnterface,
System .out.println (“ Enter sex”) ; Secondlnterface {
sex = br. readLine ( ) ; public void myMethod () {
System .out.printlnfEnter age ”) ; System.out.println(“ Some text..”) ;
age =Integer. parseInt (br.readLine ( )) ; }
public void myOtherMethod () {
void showl ( ) System.out.printlnfSome other
text...”) ;
System .out.printlnfName ” +name) ; }
System .out.printlnfSex” + sex +
“\nAge ” +age) ; class MyMainClass {
} public static void main (String[] args) {
} DemoClass myObj = new DemoClass() ;
(ii) class Marks extends Student myObj.myMethod ();
myObj.myOtherMethod () ;
int regnum ; }
int marks; }
String subject; 10 Marks Questions
void inpedetails2 ( ) throws IOException 2. interface Fly
{
InputStreamReader in = new void goForwardO ;
InputStream Reader (System .in) ; void goDownQ ;
BufferedReader br = new Buffered }
Reader (in) ; class Duck implements Fly
System .out.printlnfEnter reg. no”) ;
198 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
length = 1;
width = w;
}
public void area (double 1, double w)
double vol = 1 * b * h ;
}
}
5 DATA
STRUCTURES
(a ) Basic data structures (stack, queue, dequeue ); implementation
directly through classes ; definition through an interface and multiple
implementations by implementing the interface. Conversion of Infix
to prefix and postfix rotations, ( b ) Single linked list ( Algorithm and programming), binary trees, tree
traversals (conceptual ).
I
Queues and Stacks Topic- 1
Conceptscovered: Queue; implementing
Queues using arrays; Insertion and
Queues and Stacks
.
Page No 201
Tonic -1 deletion in a queue; deque; Stacks;
^ Implementing Stacks as arrays; Push
and Pop in a stack; Conversion of an
Topic-2
Trees and Link list
algebraic expression from infix to prefix .
Page No 216
and postfix notation
m Revision Notes
QUEUE & DEQUEUE
> A Queue is a linear structure which follows a particular order in which the operations are performed.
> Queue obeys the FIFO (First In, First Out) manner. It indicates that elements are entered in the queue at the end
and eliminated from the front.
Queue
Insertion and Deletion
happen on different ends
Enqueue Dequeue
Enqueue Enqueue
> There are two different classes which are used to implement the Queue interface. These classes are:
• LinkedList
• PriorityQueue
> -
The Deque or (double ended queue) is also a type of queue that carries the inclusion and deletion of elements
from both ends.
> -
The deque is also considered thread safe.
> Enqueue: When an element is inserted in the queue, it is called enqueue.
> Dequeue: When an element is removed from the queue, this process is called dequeue.
202 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
I
b(
.I
CD
—3
CD
Sit:
S «2 a
9.I
c
S
•
S
I
STACK
DATA STRUCTURES 203
> The stack is a linear data structure that is used to store the collection of objects.
-
> It is based on Last-In First-Out (LIFO).
> The stack data structure has the two most important operations that are push and pop.
> push(): When we insert an element in a stack then the operation is known as a push.
> If the stack is full then the overflow condition occurs.
> pop(): When we delete an element from the stack, the operation is known as a pop.
> If the stack is empty means that no element exists in the stack, this state is known as an underflow state.
Push
|Key Terms
> Enqueue (qstore): adding an element to the queue at its rear
> Dequeue (qstore): deleting an element at the front of a queue.
> Empty: status of queue being Empty.
> Full: status of a queue being full.
> Front: Refers to the first element of the queue.
> Rear: Refers to the last element of the queue.
These questions are for practice and their solutions are available at the end of the chapter
206 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Q. 8. Convert the following infix expression into = A + (BC + ) + ((DE + ) * F)/G
I
postfix form. [ISC 2014] = A + (BC + ) + (DE + F*)/G
( A/B + C)*(D/E - F))
= ABC + + + (DE + F*)/G
Ans. In the above expression, = ABC + + DE + F* /G/+
= (A/B + C)(D/(E - F))* Q. 12. Convert the following infix expression to its
= (AB/ + C)(D/(EF-))* postix form. [ISC 2011]
= (AB/C + )(DEF -/)* a + b * c - d/e
After eliminating brackets, we get postfix form Ans. From above expression brackets will be eliminate
as per the operator precedence.
= AB/C + DEF-/* = a + b * c - (de/)
[ISC Marking Scheme 2014]
= a + (be*) - (de/)
Here + and - both have same precedence, so we
,
evaluate from left to right
Examiner's Comment
= (abc* + ) - (de/)
w Most candidates were able to solve this problem = (abc* + )(de/) -
correctly. Some candidates wrote the correct The postfix form is,
answer without sharing the working. Some = abc* + de/ -
applied the postfix correctly, but could not derive Q. 13. Convert the following infix notation to postfix
the final answer.
notation. 0
[ISC 2010]
(A + B)/C * (D + E)
Answering Tip Q. 14. Convert the following infix expression to its
postix form. [ISC 2009]
w The order of precedence was not clear and ((P * Q) / (R/S + T) + U)
placement of ' +' sign was improper in several Ans. From the above expression, eliminate the brackets
cases. as per operator precedence from left to right
associativity,
Q. 9. Convert the following infix notation to its postfix = ((PQ *) /(RS/ + T) ) + U
form. [ISC 2013] = (( PQ*) /( RS/T + )) + U
E*(F/(G-H)* I) + J = (PQ * RS/T +/) + U
Ans. First, we eliminate bracket content and them
convert it into postfix expression
= PQ * RS/T +/ U +
Q. 15. What do LIFO and FIFO stand for? Name a data
= E*( (FGH-/) *1) + J structure that follows LIFO principle and one that
= E* (FGH-/I*) + J follows FIFO principle. [ISC 2008]
= EFGH -/I** + J Ans. LIFO: Last In First Out
The postfix expression is FIFO: First In First Out
= EFGH -/I**J + The data structure that follows LIFO principle
Q. 10. Write the algorithm for push operation (to add is stack and the data structure that follow FIFO
elements) in an array based stack. [ISC 2013] principle is queue.
Ans. The algorithm for push operation to add elements Q. 16. Convert the following infix expression to its
in stack based on array, postfix form.
Step 1 if (t op = size - 1)
a/(b + c) + (d * (e - f )) [ISC 2008]
Step 2 return false //overflow error Ans. From the above expression eliminate the brackets
Step 3 else as per operator precedences from left to right
Step 4 top = top + 1 associativity,
Step 5 data [top] ((a/(b + c)) + (d * (e - f )))
Step 6 return true
= (a/(bc + )) + d * (ef -)
Q. 11. Convert the following infix notation to its postfix = (abc + /) + d* (ef - *)
form. [ISC 2012]
(A + (B + C) + (D + E) *F)/G = (abc +/) + (def - *)
Ans. First, we eliminate the inner brackets of the = (abc + /)(def -*) +
expression as per the operator precedence, The postfix expression is,
= A + (B+ C) + (D + E) * F/G = abc + / def - * +
These questions are for practice and their solutions are available at the end of the chapter
I
Q. 17. Convert the following infix expression to its
DATA STRUCTURES 207
postfix form.
Long Answer Type
(A + B*C)/(C - D*B )
[ISC 2007]
Questions -I (5 marks)
Ans. From the above expression eliminate the brackets Q. 1. A Queue is a linear data structure in which the
as per the operator precedence from left to right operations are performed based on FIFO (First In
associativity, First Out).
= (A + BC * ) / (C - DB * ) Define a class Queue with the following details:
= (ABC* + ) / (CDB*-) Class name : Queue
= ABC* + CDB*-/ Data member/instance variable:
The postfix expression is,
dat[ ] : array to hold the integer
= ABC* + CDB*-/ elements
Q. 18. Convert the following infix expression to its
cap : stores the maximum
postfix form. [ISC 2006]
capacity of the queue
A + [(B + C) + (D + E) * F] / G
Ans. In above expression eliminate brackets as per front : to point the index of the
operator precedence from left to right associativity, front
= A + [(B + C) + (D + E + )* F]/ G rear : to point the index of the
rear.
= A + [(BC + ) + (DE + ) * F] / G
= A + [(BC + ) + (DE + F*]/G Member functions/methods:
= A + [(BC + DE + F* + )/G Queue(int max) : constructor to initialize
the data member cap =
= A + [BC + DE + F* + G/]
max, front = rear = 0
= ABC + DE + F* + G/ + and create the integer
Q. 19. Define a queue. How is a dequeue different from array
a queue? [ISC 2006]
void add_dat(int v) : to add integers from the
Ans. Queue The queue can be formally defined as rear index if possible
ordered collection of elements that has two ends else display the
named as front and rear, from the front end one message("Queue full")
can delete the elements and from the rear one can
insert the elements. int pop_dat( ) : to remove and return
elements from front, if
A queue is a non-primitive linear data structure any, else returns -999
in which elements are inserted from one end and
deleted from another end and in dequeue both void display() : to display elements of
insertion and deletion operations can be performed the queue
at either end of the queue. Specify the class Queue giving the details of void
Q. 20. State the different applications of stack. add dat(int) and int pop_dat( ). Assume that the
[ISC 2005] other functions have been defined.
Ans. The different applications of stracks are: The main( ) function and algorithm need NOT be
(i) Parsing written.
(ii) Recursive function Ans. public class Queue
(iii) Nested function call
(iv) Expression conversion (infix to prefix, prefix _
void add dat (int v)
to infix, etc.)
(v ) Tower of Hanoi.
if (rear< cap)
Q. 21. Convert the following expression into postfix.
[ISC 2005]
(A + B/C) + B - C * D + C dat[rear] =v;
Ans. In above expression, eliminate the brackets as per rear=rear+l ;
operator precedence from left to right associativity. }
= (A + BC/) + B - CD* + C else
= (ABC/+ ) - (CD*) + C
= (ABC / + B + CD* - C + ) System.out.println(“ Queue full”) ;
The postfix expression is,
= ABC/ + B + CD *- C + }
208 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
_
int pop dat () Class Name : Book
I
Data member/instance variables:
if (front==rear) name [ ] : stores the names of the
{ books
System.out.println (“ UnderFlow”) ; point : stores the index of the
return -9999 ; topmost book
max : stores the maximum capacity
else of the bookshelf
Method/Member functions:
return dat [front++] ; Book (int : constructor to initialise the
cap) data members max = cap
} and point = -1
} void tell ( ) : displays the name of the
} book which we last entered
in the shelf. If there is
Q. 2. Queue is an entity which can hold a maximum of no book left in the shelf,
100 integers. The queue enables the user to add displays the message
integers from the rear and remove integers from "SHELF EMPTY"
the front. <§> [ISC 2017] void add : adds the name of the book
Define a class Queue with the following details: (String v) to the shelf if possible,
otherwise displays the
Class Name : Queue message "SHELF FULL"
Data member/instance variables: void display : display all the names of the
Que[ ] : array to hold the integer 0 books available in the shelf
elements Specify the class Book giving the details of Only
size : stores the size of the array the functions void tell ( ) and void add (String).
Assume that the other functions have been
rear : to point the index of the rear defined.
front : to point the index of the The main function need not be written.
front
Member functions: Ans. public class Book
{ String name [ ];
Queue (int : constructor to initialize the
mm) data size = mm, front = 0, int point, max;
rear = 0 Book (int cap)
max = cap;
void addele : to add integer from the rear
(int v ) if possible else display the point = -1;
massage "Overflow" name = new String [max] ;
int delele( ) : returns elements from
front if present, otherwise void tell ( )
displays the message { if (point < 0)
"Underflow" and return System out .print
,
else
public intm[ ] ;
public int st[ ], top;
System.out. println
public static int cap ;
(“not possible”) ;
pubic ArrayJoJStack (int n)
cap = n;
int popmarks ( )
top = - 1;
m = newinfc [n] ;
st - new int[n]; if (top >= 0)
BufferedReader br
top |—
return x;
212 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Class Name Dequeue
I
else Data members/Instance variables:
arr [ ] array to hold upto 100 integer
return - 999 ; elements
lim stores the limit of the dequeue
front to point the index of the front
public void display ( )
end
rear to point the index of the rear
if (top > = 0) end.
Member Functions
System.outprintln
Dequeue (int constructor to initialise the
(“Elements in stack:”) ;
1) data members lim = 1; front =
for (int i = 0; i <= top; i++) rear = 0
{ void addfront to add integer from the front
System.out.println(st[i]); (int val ) if possible else display the
message ("Overflow from
1 front")
void addrear to add integer from the rear
(int val ) if possible else display the
[ISC Marking Scheme 2014] message ("Overflow from
rear")
int popfront return element from front,
Examiner's Comments 0 if possible otherwise return
-9999
w The concept of stack was not clear to most of the
candidates. Common errors made by candidates intpoprear () return elements from rear, if
were: possible otherwise returns -9999
w Incorrect declaration of array; (ii) the condition/ Specify the class Dequeue giving details of the
logic for underflow and overflow was not constructor (int). void addfront (int). void addrear
answered correctly. (int). int popfront ( ) and int poprear ( ). The main
function and algorithm need not to be written.
w Increment/decrement of top index was not done
Ans. Class Dequeue
properly; Top was initialized to 0 instead of - 1 in
some cases; The pushing of marks from array to
stack was confusing to many candidates; Some int arr [ ] ; //array to hold values
sorted the array and then pushed the values into int front , rear ;
the stack whereas in other cases it was directly
int lim ;
done; The methods pushmarks () and popmarks
() were found to be difficult by some candidates. public Dequeue (int 1)
The class declaration and construction were well
answered. lim = 1;
front = -1;
rear= - 1;
Answering Tip arr = new int [lim] ;
w More practice should be done in data programs
with the stacks, queues, de queues. Boolean isEmpty 0
if (front == rear)
Q. 3. A doubly queue is a linear data structure which
enables the user to add and remove integers return (true);
from either ends, i.e., from front or rear. Define a }
class Dequeue with the following details: public void addfront (int val)
[ISC 2013]
if (front == -1)
I front = 0; rear = 0 ; if (front == rear)
DATA STRUCTURES 213
||
* These questions are for practice and their solutions are available at the end of the chapter
214 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
The details of the class Stack is given below: ctr++ ;
I
Class Name Stack
}
Data members/instance variables:
String popname ( )
st [] the array to hold the names
size the maximum capacity of the
String S = “ » .
string array
if (top < 0)
top the index of the topmost
element of the stack
System.out.println (“ Underflow”) ;
ctr to count the number of
else
elements of the stack {
Member Functions S = st [top] ;
Stack () default constructor top - - ;
Stack (int parameterized constructor to ctr -
cap) initialise size = cap and top return S ;
=-l }
void to push a name into the stack }
pushname if the stack is full, display the void display ( )
(string n) message "OVERFLOW".
String removes a name from the top for (int i = 0; i <= top; i++)
popname () of the stack is empty, display System.out.println(st [i]) ;
the message "UNDERFLOW" }
void display display the elements of the
stack (ii) Stack works on LIFO ( Last In First Out)
(i) Specify class Stack giving details of the principle.
constructor, void pushname (String n), String Q. 6. Define a class Repeat which allows the user to
popname ( ) and void display ( ). add elements from one end (rear) and remove
The main ( ) function and algorithm need not elements from the other end (front) only.
to be written. [ISC 2010]
(ii) Under what principle does the above entity The following details of the class Repeat are
work? given below:
Ans. (i) class Stack
Class Name Repeat
Revision Notes
Trees and Link list
Concepts covered: Trees; Terminology related to a tree; Binary tree;
Linked list and implementing various data structures using linked list.
> A binary tree is made of nodes, where each node contains a "left" pointer, a "right" pointer, and a data element.
> The "root" pointer points to the topmost node in the tree.
> The left and right pointers recursively point to smaller "subtrees" on either side.
> A null pointer represents a binary tree with no elements -- the empty tree.
> A Binary tree is either empty or it consists of a node called the root, pointing to two nodes, left and right, each
being a binary tree in itself.
> A "binary search tree" (BST) or "ordered binary tree" is a type of binary tree where the nodes are arranged in
order: for each node, all elements in its left subtree are less-or-equal to the node ( < = ), and all the elements in its
right subtree are greater than the node ( > ).
> A linked-list is a linear collection of data elements called nodes, pointing to the next following nodes by means of
pointers.
> In linked lists number of elements need not be predetermined.
> Linked lists are of two types:
Single linked list.
doubly linked list.
> Single linked list contain nodes with single pointer pointing to the next node.
> START if a single linked list is a special reference which stores the address of the first mode.
> Next or link reference of the last node of the list is always NULL.
|Key Terms
> Parent and Child: Every node (except the root) has a unique predecessor called its parent successor of a node is
known as its child.
> Siblings: Two nodes of some parent.
> The line drawn from a node to its successor is called an edge.
> Path: Sequence of consecutive edges is called a path.
> leaf: Terminal node
> branch: A path ending in a leaf.
> level number: Root has level number 0 and each child has level number one more than us parent.
> Weight/depth: It is the largest level number of a tree.
Answering Tip
w More practice should be done in Binary Tree, its
parts and characteristics.
Write the pre order and post order traversal of the Q. 5. State the sequence of traversing a binary tree in
above tree structure. [ISC Sem-2 Paper 2021-22] [ISC 2014]
—
Ans. Preorder ABDCEFG (i) Preorder
—
Postorder DBEGFCA (ii) Postorder
These questions are for practice and their solutions are available at the end of the chapter
218 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class- XII
Ans. (i) root-left-right ( + LR) (i) Preorder Traversing: Preorder traversal prints
I
the contents of a binary in preorder. In other
- -
(ii) Left right root (LR + )
words, the contents of the roots node are
[ISC Marking Scheme 2014]
printed first, followed by left subtree and
finally the right subtree, as shown
Examiner's Comment Root -» Left subtree Right subtree
(ii) Inorder Traversing: Inorder traversal prints
w In parts (i) and (ii), some candidates explained
with the help of a diagram. A few used the term the contents of a sorted tree are in inorder. In
vertex or an operator to represent root. other words, the contents of the left subtree
are printed first, followed by root and finally
the right subtree, as shown
Answering Tip — —
Left subtree > Root > Right subtree
10 25 41 50 75 85
Ans. (i) Preoder: (i) Name the Root and the leaves of the tree.
= 60, 40, 70 (ii) Write the post order traversal of the tree.
= 60, 40, 20, 45, 70, 80
(iii) Separate the Internal nodes and the External
= 60, 40, 20, 10, 25, 45, 41, 50, 70, 80, 75, 85 nodes of the tree.
(ii) Postorder:
Ans. (i) Root of the tree = A
= 40, 70, 60
Leaves of the tree = D, E, G
= 20, 45, 40, 80, 70, 60
= 10, 25, 20, 41, 50, 45, 40, 75, 85, 80, 70, 60 (ii) Post order traversal
Q. 8. Explain any two standard ways of traversing a DBEGFCA
binary tree. [ISC 2007] (iii) Internal nodes of the tree = B, A, C, F
Ans. IWo standard ways of traversing a binary tree are: External nodes of the tree = D, E, G
I DATA STRUCTURES 219
Answering Tip
w Students should have knowledge to explain
binary tree with the various parts as root, nodes,
height, depth, level, size, tree traversal ( preorder,
(i) Write the inorder traversal of the above tree inorder and postorder), etc.
structure. w Students should do regular practice on algorithms
(ii) Name the parent of the nodes B and G. or programs of link list and binary tree data
structure with the help of appropriate illustrations
(iii) Name the leaves of the right sub-tree. and diagrams.
Ans. (a ) Algorithm
Step 1. Start Q. 2. Answer the following questions from the diagram
Step 2. Set temporary pointer to the first node of a Binary Tree given below: [ISC 2015]
Step 3. Repeat steps 4 and 5 until the pointer
reaches null
Step 4. Search for the node. If found display
details, exit
Step 5. Move pointer to the next node
Step 6. End
Method:
Boolean searchName (Node start, String v)
(i) -
Name the leaf nodes of the right sub tree.
Level 2
Answering Tip
Level 3
w Understand binary tree with different parts like
root, nodes (internal and external), height, depth, Level 4
level, size tree traversal (preorder, inorder and The height of tree = 4
postorder), etc. Q.5. Answer the following questions from the diagram
of a binary tree given below: [ISC 2012]
Q. 3. Answer the following questions from the diagram
of a binary tree given below:
These questions are for practice and their solutions are available at the end of the chapter
I (i ) Write the Postorder tree traversal (i )
DATA STRUCTURES
(ii) Name the leaves of tree. (ii) Write the Postorder tree traversal.
(iii) Height of the tree (iii) Write the internal node of the tree.
(iv) Root of the tree (iv) State the level of the root of the tree.
Ans. (i ) Postorder traversal of tree is Ans. (i ) Parent node of E = C
= BCA (ii) Postorder tree traversal is as
= B DE CA = BCA
= BDFECA = DBECA
= BDGHFECA = FGDBHECA
(ii) Leaves of the tree are those nodes that do not (iii) Internal nodes of the tree are as
have any child and also known as external = A, B, C, D, E
nodes. iv
( ) The level of the root of the tree is 0.
Hence, leaves of tree = B, D, G, H
Q. 8. Answer the following diagram of a binary tree
(iii) Height of tree = 4
A Level 0
given below t
< |[ISC 2009]
Bj [C Level 1
EH \E Level 2
F Level 3
These questions are for practice and their solutions are available at the end of the chapter
222 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
= CDBGFAKLJ
}
= CDEBGHFAKLJ
} (iv) Size of tree = n, where n = number of
} total nodes
(ii) In above algorithm, we used queue as a data = 11
structure . [ISC Marking Scheme, 2020]
TOPIC-2 8. (i) Root of the tree =A
2 Marks Questions (ii) External nodes of the tree are as
3. Binary Tree: A data structure in which each node
has at most two sub nodes/children (left & right)
= D, H, I, F, G
(iii) In order traversal of the tree
Linked list: A linear collection of data elements
whose order is not given by their physical = B AC
placement in memory. Instead, each element = DBEAFACG
points to the next. It is a data structure consisting = DBHEIAFCG
of a collection of nodes which together represent (iv ) Left subtree is
a sequence .
5 Marks Questions
3. ( i ) Root of the tree = A
( ii ) Left subtree is,
Highest
(v ) Height of the tree = Level of the tree = 3
AJ Level 0
H cl Level 1
20 [JL FJ [y Level 2
( iii ) In order traversal of tree is followed as,
Left subtree —> Root —> Right subtree H] [I Level 3
= B AJ
= CBFAKJ
224 Oswaal ISC Question Bank Chapterwise & Topicwise, COMPUTER SCIENCE, Class-XII
Token (int s) : Constructor to initialize the data members size = s Front = rear = 0 and
create the integer array.
void addele (int n) : to add a token at front, if possible.
int removals (g) : to remove and return token number if possible else return -1.
Specify the class Token giving the details of the functions void addele (int num) and int removable ( ).
Name the data structure mentioned here. [4 + 1]
PRACTICE PAPER - 1
COMPUTER SCIENCE
PAPER-1 (Theory)
( Maximum Marks: 70 )
( Time allowed : Three hours )
Answer to this Paper must be written on the paper provided separately.
You will not be allowed to write during the first 15 minutes .
This time is to be spent in reading the question paper.
The time given at the head of this Paper is the time allowed for writing the answers .
-
PART I (20 Marks)
(Attempt all questions)
Question 1 .
(a) What is MINTERM? [1]
(b) When does a bi-conditional results into false. [1]
(c) Find the dual of :
A + AB = A + B
(d) Name the two forms of a canonical expression. [1]
(e) Draw logic circuit diagrams for the following:
xy + xy + xz [1]
Question 2 .
(a) What is a linked list? What is the role of next reference in a linked list? [2]
(b) A 2-D array defined as B[4...7, -1...3] requires 3 words of storage space for each element. If the array is stored
in column-major form, calculate the address of A[6, 2] given the base address as 100. [2]
(c) What are function signature and function prototype? [2]
(d) Consider the following stack:
STACK:AJNTS<-Top
Describe the stack when the following operations take place. Consider every time the new stack for next
operation.
(i) Push (STACK, K)
(ii) Pop (STACK) [2]
(e) What is a fll through? How can it be avoided? [2]
Question 3 .
Consider the following code in Java and predict the output. Also show the working. What does the method
func() do?
class Hello
int x ;
if (n== l)
return a [0] ;
else
x=func(a , n-1) ;
if (x >a [n-l])
return a ;
else
return a [n-1] ;
}
Public static void main (string[] args)
} [5]
-
PART II (50 Marks)
Answer six questions in this part , choosing two questions from
Section A, two from Section B and two from Section C .
SECTION-A
(Attempt any 2 questions from the given Section)
Question 4 .
(a) Given the boolean function: F(A, B, C) = 1(1, 3, 6, 7).
(i) Reduce the function by using 3 variable Karnaugh map, showing the various groups (i.e., octet, quads
and pairs).
(ii) Draw the logic gate diagram for the above function. Assume that the various variables and their
complements are available as inputs. [4 + 1]
(b) Given the boolean function: F(A, B, C, D) = n( 3, 5, 7, 8, 10, 11, 12, 13)
(i) Reduce the function by using 4-variable Karnaugh map, showing the various groups (i.e., octet, quads
and pairs).
(ii) Draw the logic gate diagram for the above function. Assume that the various variables and their
complements are available as inputs? [4 + 1]
Question 5 .
(a) What do you understand by a multiplexer? State any one application of a multiplexer circuit. Draw the logic
diagram and function table for 4 x1 multiplexer. [5]
(b) Draw the logic gate diagram for the Boolean function
F(A, B, C) = (A' + B) (B' + C)
making use of NOR gates only. [3]
(c) Convert the following expressions to canonical POS form
(A + C) (C + D) [2]
Question 6 .
(a) A combinational circuit has 4-inputs and one output. Output is 1 if :
(i) All the inputs are equal to 1.
(ii) None of the inputs are equal to 1.
(iii) An odd number of inputs are equal to 1.
(I) Obtain the truth table.
(II) Find the simplified output function in SOP form.
(III) Draw the logic diagram. [5]
228 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
(b) What is a decoder? Draw the truth table and a logic circuit diagram for a 2 by 4 decoder.
I[3]
, ,
(c) F(A, B, C, D) = (A' + C)(A' + C')(A + B + C D)
Reduce the above expression using boolean laws. [2]
SECTION-B
(Attempt any 2 questions from the given Section)
Question 7 .
Design a class SumDigits to find the sum and product of digits of a given number. Class specifications are given
below:
Class name : SumDigits
Data members/instance variables:
n : integer to store the number.
sum : integer to store the sum.
product : integer to store the product.
Methods/members functions:
SumDigits : default constructor
void accept() : to accept the number
void sum() : to calculate and display the sum of digits without using( % ) modulus
operator.
void product() : to calculate and display the product of digits without using ( % ) modulus
operator.
Specify the class SumDigits giving details of the constructor, void accept(), void sum (), void product(). Define a
main() function to create an object and call the functions accordingly. [10]
Question 8 .
Given a 2-D array write a program to print it in spiral order. Implement class display with the following
specifications:
Class Name : Display
Data members
Arr 2D : an NxN array
size : integer to hold the value of N.
Member methods:
Display (int) : receives the value of size and creates an array with values 1 to size.
Print() : prints the array elements as a matrix.
PrintSpiral() : prints the array in spiral order
void accept() : to accept the array elements.
Also create main() method that should obtain the value of size and calls the other functions. [10]
Question 9 .
Write the Java program to implement a class swap used to swap adjacent letters of a string. The class contains a
—
datamember str that holds the string and two functions accept() (to accept string from the user) and swapPairs()
(to swap adjacent letters).
Design the class giving details of the constructor and both the function. Also write main method to create object
of the class and call the functions. [10]
SECTION-C
(Attempt any 2 questions from the given Section)
Question 10 .
A data structure line reads the input from the terminal as a string. Write a code to output the string in the reverse
order, with each character appearing twice, for e.g., input string TISHYA is displayed as AAYYHHSSIITT.
Which type of data structure is line? [4 +1]
I
Question 11 .
PRACTICE PAPER 229
A class one with data members int a and char b inherits from another class. Two with data members float F and
int x. Write definitions for one and two for the following situation:
(i) Objects of both the classes are able to access all the data members of both the classes.
(ii) Only the members of class one can access all the data members of both the classes. [5]
Question 12 .
(a) A linked list is formed from the objects of the class node. The class structure of the node is given below:
Class Node
int num ;
Node next;
}
Write an algorithm or a method to print all the prime numbers from the list. The method of declaration is as
follows:
void primeNum(Node start) [2]
(b) Consider the tree structure given below and answer the questions that follow:
PRACTICE PAPER 2 -
COMPUTER SCIENCE
PAPER-1 (Theory)
( Maximum Marks: 70 )
( Time allowed : Three hours )
Answer to this Paper must be written on the paper provided separately.
You will not be allowed to write during the first 15 minutes .
This time is to be spent in reading the question paper.
The time given at the head of this Paper is the time allowed for writing the answers .
-
PART I (20 Marks)
(Attempt all questions)
Question 1.
(a) What is a truth value? [1]
(b) What is a Binary Decision? [1]
(c) Find minterm is maxterm designation of UVW [1]
(d) Draw Karnaugh map for [1]
F(W, X, Y) = 1(0, 2, 3)
e
( ) Define a logic circuit. [1]
Question 2.
(a) State the purpose of finally block in a try catch statement. What is exception? [2]
(b) What is Autoboxing? Give one reason why primitive types should be preferred over wrappers. [2]
(c) How is a 2D-Array stored in memory? How is this storage achieved ? [2]
(d) List any two applications of queues. [2]
(e) Define the following with respect to a binary tree.
(i) leaf
(ii) degree [2]
Question 3.
Following function is part of some class. Predict the output when x = 57 giving the working. What is the given
function doing, [5]
int funcl (int x)
int d ;
if (x ==0)
return 0 ;
else
d = 2%10;
I return (d*d + funcl (x/10)) ;
PRACTICE PAPER 231
Question 4.
(a) Given the Boolean function:
F(W, X; X Z) = 1(0, 4, 8, 12)
-
(i) Reduce the above expression by using 4 variable Karnaugh map, showing the various groups (i.e.,
octals, quads and pairs). [4]
(ii) Draw the logic gate diagram for the reduced expression. Assume that the variables and their
complements are available as inputs. [1]
(b) Given the Boolean function:
F(A, B, C, D) = n( 0,1, 3, 5, 6, 7, 10, 14, 15)
-
(i) Reduce the above expression by using 4 variable Karnaugh map, showing the various groups. [4]
(ii) Draw the logic gate diagram for the reduced expression. Assume that the variables and their
complements are available as inputs. [1]
Question 5.
(a) Draw the truth table and logic circuit diagram for a Hexadecimal to Binary encoder. [5]
b
( ) What is a Half Adder? Draw the truth table, derive its Boolean expression and draw a logic diagram for Half
Adder. [3]
(c) Convert A B + B C to its canonical SOP for using Boolean Algebra. [2]
Question 6.
(a) A person is allowed to travel in a reserved coach of the train, if he/she satisfies the criteria given below: [5]
The person has a valid reservation ticket and a valid ID proof.
OR
The person does not have a valid reservation ticket, but holds a valid pass issued by the Railway
department with a valid ID proof.
OR
The person is a disabled person and holds a valid pass issued by the Railway department along with a
valid ID proof.
The inputs are:
Inputs
R The person has a valid reservation ticket.
P The person holds a valid pass issued by the railway department.
D The person has a valid ID proof .
H The person is a disabled person.
Output: T-Denotes allowed to travel (1 indicates yes and 0 indicates no in all cases.)
(i) Draw the truth table for the inputs and outputs given above and write the POS expression for T(R, R D, H).
(ii) Reduce T(R, R D, H) using Karnaugh's Map.
-
( ) Implement the following Boolean functions in minimized 2 level NOR NOR form.
b - [3]
F(a, b, c, d) = Im (l, 3, 4, 6, 9, 12)
Assume complements of the input Boolean variables are available.
(c) Reduce the following expression using Boolean laws: [2]
- -
A (A' + B) CC (A + B)
232 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
SECTION-B
I
(Attempt any 2 questions from the given Section)
Question 7.
A magic number is a number in which the eventual sum of digits of the number is equal to 1.
eg --
'
721 = 7 + 2 + 1 = 10
10 = 1 + 0 = 1
Thus, 721 is a magic number.
Design a Class Magic to check if a given number is a magic number. Some of the members of the class are given
below:
Class name : Magic
Data members/instance variables
n : stores the number
Member functions:
Magic() constructor to assign 0 to n.
void inputnum(int no) to assign the parameter value to the number, n.
int digitsSum returns the sum of the digits of a number.
void is magic)) checks if the given number is a magic number by calling the function
digitsum(int) and display appropriate message.
Specify the class magic giving details of the constructor, void inputnum(int no), int digitsum (int) and void
ismagic(). You do not need to write the main function. [10]
Question 8.
Design a class word which enables a word to be arranged in ascending order according to its letters. The details
of the members of the class are given below.
Class name : Alpha
Data members/instance variables:
str : to store a word
Member functions:
word () default constructor
void readword() : to accept a word
void arrange)) : to arrange the word in alphabetical order using any standard sorting
technique.
void disp() : displays the word.
Specify the class word giving details of the constructor and the member functions void readword(), void arrange)),
void disp() and defining the main)) function to create an object and call the function in order to execute the class
by displaying the original word and the changed word with proper message. [10]
Question 9.
A class shuffle contains a two dimensional integer array of order (m&n) where the maximum value of both m and
n is 6. Design the class shuffle to shuffle the matrix (i.e., the first row becomes the last, the second row becomes
the first and so on). The details of the members of the class are given below:
Class name : Shuffle
Data members:
matrix[] : stores the array element
m : integer to store the member of rows
n : integer to store the numbers of columns
Member functions/methods:
Shuffle (int row, int col) : Parameterized constructor to initialize the data members m = row, n = col
void input() : accepts elements of the array
void shift (shuffle S) : enables the matrix of the object(s) to shift each row upwards m a cyclic
manner and store the resultant matrix in the current object.
void display : display the matrix elements.
Specify the class shuffle giving details of the construct(), void inputs)), void cyclic (shuffle) and void display)).
[10]
I SECTION-C
PRACTICE PAPER 233
Question 10.
Chain is an entity which can hold at the most 50 integers. The chain enables the user to add and remove integers
from hot the ends i.e., front and rear. Define a class chain with the following details:
Class name Chain
ele[] the array to hold the integer elements
cap stores the maximum capacity of the array,
front to point the index of the front
rear to point the index of the rear
Member functions:
chain (int max) : constructor to initialize the data cap = max, front = rear = 0 and to create
the integer array.
void pushfront(int v) : to add integers from the front index if possible else display the message-
"Front is Full".
int popfront : to remove and return elements from front. If array is empty then
return-999.
void pushrear(int v) : to add integers from the front index if possible else display the message
"Rear is full".
int poprearQ : to remove and return elements from rear. If the array is empty then
return-999.
(a) Specify the class chain giving details of the constructor and all the member functions. No need to write the
main function.
(b) Name the data structure implemented above. [4 + 1]
Question 11.
A super class worker has been defined to store the details of a worker. Define a subclass wages to compute the
monthly wages for the worker. Both the classes are defined as follows: [5]
Class name : Worker
Data members/instance variables:
name : to store the name of the worker
basic : to store the basic pay in decimals
Member functions:
Worker (...) Parameterized constructor to assign values to the instance variables.
void display() displays the workers details
class name wages
Data members:
hrs : to store the hours worked
rate : stores rate per hour
wage : stores the overall wage of the worker
Member functions:
wagesQ : parameterized constructor to assign values to the instance variables of
both the classes.
double overtime() : Calculates and return the overtime amount as (hours“ rate)
void display() : Calculates the wage using the formula wage = overtime amount +
Basic pay and displays it along with the other details.
Question 12.
(a) A linked list is formed from the objects of the class node. The class structure of the node is given below:
class node
{
int num ;
234 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Node next;
I
Write an algorithm or a method to delete 'nlh' node from the list. The method of declaration is as follows:
void del (Node start, int n) [2]
(b) Consider the tree structure given below and answer the questions that follow:
COMPUTER SCIENCE
PAPER-1 (Theory)
( Maximum Marks: 70 )
( Time allowed: Three hours )
Answer to this Paper must be written on the paper provided separately.
You will not be allowed to write during the first 15 minutes.
This time is to be spent in reading the question paper.
The time given at the head of this Paper is the time allowed for writing the answers.
Question 10.
(a) Draw the equivalent logic circuit for the following Boolean expression:
(AB) + C [1]
(b) Correct the following boolean, statements [1]
(i) X + 1 = X
(ii) (A + B)' = A.B
(c) State DeMorgan's laws of Boolean Algebra. [1]
(d ) Derive a canonical SOP expression for the Boolean function F, represented by the following truth table: [1]
P Q R F(P, Q, R )
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
(e ) When does a XNOR gate produce high output? [1]
Question 2.
(a) Convert the following to a postfix expression [2]
(a + b)*(c + d)
(b) State difference in implementing stacks using array and implementing them using linked list. [2]
c
( ) X is a 2- array
D [10 x 5]. Each element of the array is stored in 2 memory locations. If X[l, 1] begins at address
100, find the location of X[3, 4] if the arrangement is row-major wise. [2]
236 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
(d ) (i) What should be the data type of the variable C, for Java to generate no error? Why?
I[2]
C = 5.7F +8.9/2 + 6*3.75;
(ii) What is coercion? Give one example.
(e) What is polymorphism? How is it implemented in Java? [2]
Question 3.
Read the following code carefully and predict the output of the function count A if the value passed to the
function count A is "Mississipi". [5]
What is the function count A() doing. Show the working also,
public int count A (string str)
int count = 0 ;
if (str.length ==0)
return 0
if (str.substring(0, l) .equals("i"))
count = 1;
return count + count A (str.substring(l)) ;
}
-
PART II (50 Marks)
SECTION-A
(Attempt any 2 questions from the given Section)
Question 4.
(a ) Given the Boolean function
F(A, B, C, D) = 1(1, 2, 3, 4, 5, 6, 7, 12, 13)
(i) Reduce the above expression by using 4-variable Karnaugh map, showing the various groups. [4]
(ii) Draw logic gate diagram for the reduced expression. Assume that the variables and their complements
are available as inputs. [1]
(b) Given the Boolean function
F(W, X, Y, Z) = n( 0, 2, 4, 6)
(i) Reduce the above expression by using 4-variable Karnaugh map, showing the various groups. [4]
(ii) Draw logic gate diagram for the reduced expression. Assume that the variables and their complements
are available as inputs. [1]
Question 5.
(a ) What is an encoder? Draw the logic circuit diagram for decimal to binary encoder, and its truth table. [5]
(b) Why is NOR gate regarded as a universal gate? Draw its symbol and truth table for two input NOR gate.
[3]
(c) Express P + Q • R in canonical SOP form. [2]
Question 6.
(a ) A provisional store announces a special discount on all its products as a festival offer only to those who
satisfy any one of the following conditions:
• If he/she is an employee of the store and has a service of more than 10 years.
OR
• If he/she is a senior citizen but not a regular customer of the store.
The inputs are:
E : Employee of the store
R : Regular customer of the store
S : Service of the employee is more than 10 years.
C : Senior citizen of 65 years or above.
I Output:
PRACTICE PAPER 237
X : Denotes eligible for discount [1 indicates YES and 0 indicates NO in all cases]
Draw the truth tables for the inputs and outputs given above and write the SOP expression for X[E, R, S, C],
[5]
(b) Represent F(a, b) = a.b using only NOT and OR gates. [3]
(c) Verify the following using boolean laws [2]
XY + XY = (X + Y) (x + y)
SECTION-B
(Attempt any 2 questions from the given Section)
Question 7.
Write a program to declare a single dimensional arrayX[] and a square matrix Y[][] of size N where 2 < N <10.
Allow the user to input positive integers into single dimensional array. Now
(a) Sort the elements of the single dimensional array in ascending order using and standard sorting technique.
(b) Fill the square matrix in the following format.
If array X[] = {6, 7, 2, 9} then after
sorting X[] = 12, 6, 7, 9}
Now matrix Y[] is filled as follow:
2 6 7 9
2 6 7 2
2 6 2 6
2 2 6 7 [10]
Question 8.
Write a program in Java to enter a number. Check and display whether it is prime perfect or not.
A number is said to be prime perfect, if all the factors are prime including 1 and excluding the number itself and
also the sum of all factors including 1 and excluding the number is equal to the number,
e.g. 6 is a prime perfect because factors of 6 i.e., 3 & 2 are prime and 1 + 2 + 3 = 6. [10]
Question 9.
You can encode or decode a string in many ways. One of them is to replace each vowel by two characters ahead
in ASCII table and each consonant by the next character. The replacement of characters may wrap around (i.e., A
follows Z). Write a program in Java to accept a word and encrypt it as follows: [10]
Word Encrypted form
SIDDHANT TKEEICOU
SECTION-C
(Attempt any 2 questions from the given Section)
Question 10.
Queue is an entity which can hold a maximum of 100 integers. The queue enables the user to add integers from
the rear and remove integers from the front.
Define a class Queue with the following details:
Class Name : Queue
Data members
Que [] array to hold the integer elements,
Size stores the size of the array,
Front to point the index of the front,
rear to point the index of the rear.
238 Oswaal ISC Question Bank Chapterwise & Toplcwlse, COMPUTER SCIENCE, Class-XII
Member functions:
I
Queue (int mm) : constructor to initialize the data size = mm, front = -1, rear = -1.
void addele (int V) : to add integer from the rear if possible else display the message
"overFlow"
it delete() : returns elements from front if present, otherwise displays the message
"Underflow" and return -9999.
void displaysQ : displays the array elements.
(a ) Specify the class Queue giving details of only the function void addele(int) and int delele(). Assume that the
other functions have been defined. The main function and algorithm need not be written. [4]
(b) What is the name of the data structure that allows addition and deletion of data from one end only? On
which principle it is based? [1]
Question 11.
A class personal contains employee details and another class retire calculates the employee's provident fund and
gratuity. [5]
The details of the two classes are given below:
Class Name : Personal
Data Members:
Name : stores the employee name
Pan : stores the employee PAN numbers
basic-pay : stores the employee basic salary
acc-no : stores the employee bank account number.
Member functions:
Personal (...) parameterized constructor to assign value to data members
void display() to display the employee details.
class name Retire
Data members:
Yrs : stores the employee years of service
PF : stores the employee's provident fund amount
Grat : stores the employee's gratuity amount
Member functions:
Retire(...) : parameterized constructor to assign value to data members of both the
classes.
void provident() : calculates the PF as (2% of the basic pay)*years of service.
void gratuity() : calculates the gratuity as 12 months salary, if the years of service is more
than or equal to 10 years else the gratuity amount is nil.
void display1() : Displays the employee details along with the PF and gratuity amount.
Specify the class personal giving details of the constructor and member functions void display(). Using the
concept of inheritance, specify the class retire giving details of constructor and function void provident(), void
gratuity() and void displayl (). The main function need not be written.
Question 12.
(a ) A linked list is formed from the objects of the class Node as given below:
class Node {
string name ;
node next;
Write an algorithm or a method to count and return number of nodes in the list; The method is defined as
int count(Node n); [2]
I (b) Answer the following questions based on the structure of the tree given below:
PRACTICE PAPER 239
(i) Write the post order traversal of the above tree. [1]
(ii) Name the siblings of nodes E&K. [1]
(iii) What is the order and degree of the above tree if root is at level 0. [1]
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
Highly recommended titles from
m OSWAAL BOOKS ®
ISC
« OSWAAL
_
BOOKS
tBMstantMB mm etraan
®
<
QUESTION BANK
FOR CLASS XII 0
^P
4
ISC
QUESTION
BANK
Chapterwise & Topicwise
SOLVED
PAPERS
IL t i
BENEFITS
• Latest Board Examination Paper
• Latest Solved Board Specimen Paper
2010- 2021
CLASS 12
BIOLOGY Bfi
k331
.fy 1
.
• Strictly as per the Latest Syllabus
‘On Tips Notes' & Mind Map
x
laid!Board
—
I ISC
fm « rut
OSWAAL BOOKS
rrmrrt EIMBHU
®
SAMPLE QUESTION PAPER
i: FOR CLASS XII
ISC 1A
m W SAMPLE
' i -
*«
Si
iii
MI \\
?///
QUESTION
PAPERS
CLASS 12
SEMESTER 2
CHEMISTRY
r • Strictly
BENEFITS
• Updated Typologies of Questions as per Latest ISC
Specimen Paper
as per the latest syllabus
• On Tips Notes’ & Mind Map
W :SS 2£ -3B=
‘
• Topics found difficult & suggestions for students
• Answer key with Explanations for every question
M Academically Important Questions (Al)
M
WK«G ALL SUBJECTS ARE AVAILABLE IN THIS SERIES
HftjE
Scan this QR code on your mobile for instant
access to all these books and more.
m
Get future ready
with comprehensive titles from
« OSWAAL BOOKS
LE OTraG mnm SIMPLE
[ &
®
® OSWAAL BOOKS
ns&BiEnaoi ; srTsrrr
TOPPER’S HANDBOOK
BENEFITS
• Definitions and Revision Notes
• Mind Maps
• 500+ Concept Videos
• Hybrid Edition with Print & Online Support,
• Useful for Class 12 Board Examination
and medical and other competitive examinations
SUBJECTS AVAILABLE IN THIS SERIES
• Physics • Chemistry
• Mathematics • Biology
« OSWAAL BOOKS
JEE (MAIN) MOCK TEST
r Rfvinrrcft CSICJR srrcrrn
- 15 SAMPLE QUESTION PAPERS &
JEE (MAIN) SOLVED PAPERS
• Latest Solved Papers ( all 4
Shifts) of 2021 Exam
• Concept based Revision Notes
• Valuable Exam insights, Tips,
Tricks & Shortcuts
• Two Sample Practice Papers
• ‘Strictly as per the scheme of
examination for JEE (MAIN) 2022
issued by NTA
• Fully solved 15 Mock Papers with
90 Question each
• Get concpet clarity - Mind Maps
NEET (UG) coH&o]
[«
« OSWAAL
16 YEARS’ SOLVED PAPERS BOOKS
(.nfiirtrnre rs/, flR crrcrrr