189Oswaal ISC Class_12, Computer Science_Revision Notes
189Oswaal ISC Class_12, Computer Science_Revision Notes
REVISION NOTES
Propositional Logic
A proposition is a declarative sentence that is either true or false but not both. Statements are also called statements.
For example,
1. The Sun sets in the East direction.
(It is a proposition with false value)
Logical Connective (Operators) : For combining two or more statements we use special symbols, called logical
connectives. There are several logical connective as follows :
Negation (NOT) : If S is a statement or proposition, then NOT (S) or (∼S) is negation of proposition S.
For example, S : Ram eats the mango.
Not (S) : Ram doesn’t eat the mango.
Conjunction (AND) : If R and S are two propositions, then R and S are connected by ‘AND’ or ‘.’ symbol.
For Example,
R : He is a player.
S : He plays football very well.
R ∧ S : He is a player and he plays football very well.
Disjunction (OR) : It is represented by ‘OR’ or ‘∨’ symbol. Let R and S two proposition. Then R V S is read as
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’. A ⇒B means A’+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 ↔ B is known as biconditional statement or proposition. ‘ ↔ ‘ or ‘⇔’ shows equivalence
velation between two propositions A ↔ B represents AB+A’B’.
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 O) are called ‘truth values’.
We can determine the truth values of the various connections as follows :
Maxterm () Minterm
x y z
Term Symbol Term Symbol
0 0 0 x+y+z m0 x’y’z’ M0
0 0 1 x+y+z’ m1 x’y’z M1
0 1 1 x+y’+z m2 x’yz’ M2
0 1 1 x+y’+z’ m3 x’yz M3
1 0 0 x’+y+z m4 xy’z’ M4
1 0 1 x’+y+z’ m5 xy’z M5
1 1 0 x’+y’+z m6 xyz’ M6
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’s 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. X + X ) terms, which have missing variables.
3. Expand all terms and remove the duplicate terms such that X + X = X or X + X + X = X.
4. The produced SOP expression is the canonical SOP expression.
Conversion from POS Expression to Canonical POS Expression:
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. X ⋅ X ) 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:
(A) Change every OR sign (+) to AND sign (·).
(B) Change every AND sign (·) to OR sign (+).
(C) Change normal variable (A) into complement variable ( A ) and vice versa.
4 ] Oswaal ISC Chapterwise & Topicwise Revision Notes, For Semester-1, COMPUTER SCIENCE, Class –XII
4-Variables K-map
Possible combinations 2n cells for n-variables :
–– – –
2-variables K-map (4 cells) : A B , A B, A B , AB.
––– –– – – – –– – –
3-variables K-map (8 cells) : A B C , A B C, A B C , A B C, A B C , B C, A B C , 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 by together in the form of Octal, Quad and pair form.
Some rules are as follows :
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 0 1 A 1
A 1 A 1 1
1 1 1 1 1 1 1 1
1 1 1 1
Incorrect Pattern Correct Pattern
Groups may be overlap as shown above in the correct pattern.
In a K-map, first find out all possible octet group, then Qued-group and at the end make pairs. Then you will
found the optimal solution or simplest form of given expression.
Karnaugh map or K-map 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 maxterms or minterms.
Rules of Simplification : The Karnuagh map uses the following rules for the simplification of expressions by
grouping together adjacent cells containing ones.
Groups may not include any cell containing a zero.
Groups may be vertical or horizontal, but not diagonal.
A
B 0
0 1
1 0
0 1 1 Group of 2
1 0 0
0 1 1 1 1
1 0 0 1 1
l AND (∧), OR (∨), Not (—), conditional (→) and biconditional (↔) are logical connectives. With the help of these
connective, compound statements are created.
l If there are n-variables in the expressions, then it contains 2n possible combination of their values.
l Tautology : A compound statement having all its possible values become true.
l Contradiction : A compound statement that is always false.
l Contingency : A compound statement that is neither true nor false.
l Argument : An argument is valid iff it is a tautology.
l Syllogism : Logical process of drawing conclusion from given propositions.
l Basic Postulates :
A+0=0+A=A 0+1=1;a+0=0
A.1 = 1 . A = A 0.1=0;1+1=1
A + A = A; A.A = A
A + A = 1; A. A = 0
(A) = A
l De Morgan’s Theorem : The complement of the sum of variables is equal to the product of their complement of
their variables.
( A+B) = A . B or : (A . B) = A + B
l Sum-of Products (SOP) : Sum of minterms is known as sum of products (SOP) form. Example, xy’ + x’y is a SOP
form.
l Product-of-Sum (POS) : Product of maxterms is known as product of sums (POS) from. Example, (x + y)·(x’ + y)
is a POS form.
l Mini term is a product of all literals and maxterm is a sum of literals.
l Canonical from : If an expression is represented in its maxterms or minterms.
l Cardinal form : If an expression is represented in its decimal equivalent of its terms.
REVISION NOTES
Logic Gates
A logical gate a small circuit which is used to implement boolean function. It is also used to design logic circuits in
computer hardware.
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 does not produced.
Types of Logic Gates :
As we know that the logic gates represents electronic circuits in boolean algebra. There are two types of logic gates
mainly :
(i) Fundamental or Elementary Logic Gates
(ii) Universal Gates
1. Fundamental Logic Gates : AND, Or and NOT gates are called fundamental logic gates.
(i) AND gate : This logic gates 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
A
AND X = A . B 0 1 0
B
1 0 0
1 1 1
Oswaal ISC Chapterwise & Topicwise Revision Notes, For Semester-1, COMPUTER SCIENCE, Class –XII [ 7
(ii) OR gate : This logic gate contain at least two inputs and single output. It enables or gives output iff any of
one of the inputs in enabled.
A B X=A+B
0 0 0
A
OR X=A+B 0 1 1
B
1 0 1
1 1 1
(iii) NOT Gate : It has only single input and single output. It acts as inverter.
–
A A
A or A'
A NOT 0 1
1 0
2. Universal Gates : NAND and NOR gates are known as universal gates. With the help of these gates, 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 X = (A . B)'
NAND 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)'
NOR 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
or 0 1 1
B
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.
The algebraic notation used to represent the XNOR operation is S = A B
A B X
0 0 1
A X=A . B
X NOR
or 0 1 0
B
X = A'B' + AB 1 0 0
1 1 1
8 ] Oswaal ISC Chapterwise & Topicwise Revision Notes, For Semester-1, COMPUTER SCIENCE, Class –XII
(A . B)'
X = A' A X=A.B
A
B
A'
A
X=A+B
B
B'
OR Gate
Realisation of Logic Gates using NOR Gate :
A'
A
X = A'
A
X=A.B
NOT GATE
B
B'
AND Gate
(A + B)'
A X = (A + B)
B
OR Gate
Combination Circuits
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'
Circuit
N M
Fig
Fig.: Block
Block Diagram
Diagram
The output of combinational circuit at any instant of time depends only on the levels present at input points.
They do not use any memory. The previous state of input doesn't have any effect on the present sate of the circuit.
A combinational circuit consists of related logic gates whose output at any time can be determined directly from
the present combination of inputs irrespective of previous inputs.
(eg.) half adder, full adder, decoder, encoder, multiplexer, etc.
Oswaal ISC Chapterwise & Topicwise Revision Notes, For Semester-1, COMPUTER SCIENCE, Class –XII [ 9
Circuit Description Expression Truth Table Logic diagram
Half Performs the S = x´y + xy´ x y S C
Adder addition of two =x/y
0 0 0 0
bits C = xy
0 1 1 0
1 0 1 1
1 1 0 1
D2
D3
D4
D5
D6
D7
4
3 0 0 1 1 5
4 0 1 0 0 6
5 0 1 0 1 7
6 0 1 1 0 8
9
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
F0 = S (1, 3, 5, 7, 9)
F3 F2 F1 F0
F1 = S (2, 3, 6, 7)
F2 = S (4, 5, 6, 7)
F3 = S (8, 9)
10 ] Oswaal ISC Chapterwise & Topicwise Revision Notes, For Semester-1, COMPUTER SCIENCE, Class –XII
Multiplexer Selects
binary
information
from one
of many
inputs lines
and directs
it to a single
output line.
4×1 4 input S1 S0 Y
MUX lines
0 0 I0
2 selection
lines 0 1 I1
1 0 I2
1 1 I3
REVISION NOTES
Fundamentals of Java
QQ Java is a high programming language originally developed by Sun Micro systems and released in 1995. Java
runs on several platforms as windows, Unix and Mac OS.
When we consider a Java program, it can be defined as a collection of objects that communicate via invoking
each others method.
Object Oriented Programming (OOP) is a programming paradigm which deals with the concepts of object to
create programme and software applications. The features of OOP are closely with the features of real-world
like object, class, inheritance, abstraction, encapsulation and polymorphism.
Objects : Objects have states and behaviours. For example; a student has states or characteristics : name,
age, group as well as behaviour such as student studies, playing, acting, etc.
Class : A class can be defined as a template or blueprint that describes the behaviour or state that the
object of its type supports. An object is an instance of a class. A class is a way to bind the data and its
associated functions together.
Methods : Method basically is behaviour. A class contains many behaviour. It is in methods where the
logics are written, data is manipulated and all actions are executed.
Inheritance : In Java, classes can be derived from classes. If you require to create a new class and here is
already 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.
Data Encapsulation : is a process of wrapping of data and methods in a single unit is called encapsulation.
It is achieved by class concept in Java. The insulation of the data from direct access by the program is
called 'data hiding'.
Polymorphism : A process of representing one form in various forms is called 'Polymorphism'. For
example, a single persons 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.
QQ Java Identifiers :
All Java components require names. Names used for classes, variables and methods are called identifiers.
There are following points to remember for identifiers :
xx All identifier should begin with a letter (A to Z or a to z), $ (dollar sign), (__) underscore).
xx A key word cannot be used as an identifier.
xx Identifiers are case-sensitive.
xx Legal identifiers : age, $ salary, _value, _1_value.
xx Illegal identifiers : 123abc, _salary
QQ Java Keywords : The following lists show the reserved words in Java. These reserved words may not be used
as constant or variable or any other identifier names.
abstract private double synchronized new float
byte short final while public implements
class switch go to catch strictly interface
do throws instance of continue this package
12 ] Oswaal ISC Chapterwise & Topicwise Revision Notes, For Semester-1, COMPUTER SCIENCE, Class –XII
System.out.println(x); //10.6
There are two uses with wrapper classes :
xx To convert simple data types into objects.
xx To convert strings into data type.
Arrays
Arrays are the type of data structure which stores 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.
QQ One-Dimensional Arrays
A one-dimensional array is, essentially, a list of like-typed variables. To create an array, you first must create
an array variable of the desired type. The general form of a one-dimensional array declaration is
type var_name[ ]=new type[size];
16 ] Oswaal ISC Chapterwise & Topicwise Revision Notes, For Semester-1, COMPUTER SCIENCE, Class –XII
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[ ];
QQ Multidimensional Arrays
In Java, multidimensional arrays are actually arrays of arrays. There are a couple of subtle 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++)
System.out.print(twoD[i][j] + " ");
System.out.println();
}}}
This program generates the following output:
01234
56789
10 11 12 13 14
15 16 17 18 19
Strings
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
Oswaal ISC Chapterwise & Topicwise Revision Notes, For Semester-1, COMPUTER SCIENCE, Class –XII [ 17
QQ 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:
String s1="Welcome";
String s2="Welcome";//will not create new instance
(2) By new keyword
String s=new String("Welcome");//creates two objects and one reference variable
In such case, JVM will create a new string object in normal (non pool) heap memory and the literal
"Welcome" will be placed in the string constant pool. The variable s will refer to the object in heap (non
pool).
Java String class methods
The java.lang.String class provides many useful methods to perform operations on sequence of char values.
No. Method Description
1. char charAt(int index) returns char value for the particular index
2. int length() returns string length
3. static String format (String format, object... args) returns formatted string
4. static String format(Locale l, String format, returns formatted string with given locale
Object... args)
5. String substring(int beginIndex) returns substring for given begin index
6. String substring(int beginIndex, int endIndex) returns substring for given begin index and end
index
7. boolean contains(CharSequence s) returns true or false after matching the sequence
of char value
8. static String join(CharSequence delimiter, Char returns a joined string
Sequence... elements)
9. Static String join (CharSequence delimiter, returns a joined string
iterable < ? extends CharSequence > elements)
10. boolean equals(Object another) checks the equality of string with object
11. booleanis Empty() checks if string is empty
12. String concat(String str) concatenates specified string
13. String replace(char old, char new) replaces all occurrences of specified char value
14. String replace(CharSequence old, CharSequence replaces all occurrences of specified
new) CharSequence
15. static String equalsIgnoreCase(String another) compares another string. It doesn't check case.
16. String[] split(String regex) returns splitted string matching regex
17. String[] split(String regex, int limit) returns splitted string matching regex and limit
18. String intern() returns interned string
19. int indexOf(int ch) returns specified char value index
20. int indexOf(int ch, int fromIndex) returns specified char value index starting with
given index
18 ] Oswaal ISC Chapterwise & Topicwise Revision Notes, For Semester-1, COMPUTER SCIENCE, Class –XII