0% found this document useful (0 votes)
16 views5 pages

Chapter 1 Unit 1

Uploaded by

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

Chapter 1 Unit 1

Uploaded by

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

Chapter 1: Unit 1

What is computer/ language?


It is a language by which we can write the program or instructions for computer to do a
particular task.

Types of computer languages


It is two types i.e. Low Level Language and High Level Language

Low Level Language:


It is directly understood by computer. It is dependent on machine means program developed
in one machine cannot be used in another machine. It is further divided into two types i.e.
Machine Language and Assembly Language

Machine Language:
In this language instructions are written in the form of binary i.e. 0 or 1. Instructions written in
this language is called machine code or object code. This language is the internal language of
machine. Therefore, no translation is required. Program execution is faster. It is a machine
dependent language. But disadvantage is writing program is difficult, finding errors and
correction is difficult.

Assembly Language:
In this language instructions are written in the form of mnemonics/symbolic code. It is little bit
easier to write the program as compared to machine language. It is also machine dependent
language. In this language a translator program is used to translate assembly language into
machine language called Assembler. Program execution is slower than machine language.

High Level Language:


In this language instructions are written in the form of English letter. Therefore, writing
programs, finding errors, understanding the program is easy as compared to low level
language. It is machine independent language. In this language two translator programs are
used to convert from high level language into machine language called compiler and
interpreter. Program execution is slower as compared to low level language.

Compiler Interpreter
It translates whole source code into It translates source code into object code
object code at once. line by line.
It displays all the errors of the program It displays one error at a time. After
together. correction of the error it displays next.
Compilation process is faster Interpretation process is slower.

Source Code Object Code


It is written by the programmer. It is generated after the compilation of
source code.
It is in the form of English like language. It is in the form of binary i.e. 0 or 1`
It is understood by programmer It is understood by machine

Different Programming Approach


Procedure Oriented Programming Object Oriented Programming
In this approach emphasis is more on In this approach emphasis is more on data
functions rather than data. rather than function
It follows top down approach It follows bottom up approach
It cannot model real world objects It can model real world objects
In POP data can freely move from In OOP data is restricted and cannot move
function to function freely from function to function.

Elements of OOP
1. Object: It is an identifiable entity which has some characteristics and behavior. It is called
instance of the class. It is created by using new keyword. Many objects can be created from
a class. Example:- FAN – Characteristics are no. of wings, color, brand etc. and behavior is
rotate.
2. Class: It is a blueprint or prototype for the object. It defines common characteristics and
behavior for the object. It is called as object factory because from a class many similar kinds
of objects can be created. It is created only once and created by using class keyword.
Difference between class and object
Class Object
1. It is a blueprint or prototype for the 1. It is an identifiable entity which
objects which defines the common have some characteristics and
characteristics and behavior for the objects behavior
2. It is called as object factory 2. It is called as instance of the class
3. It is created once 3. Many objects can be created
4. It is created by using class keyword 4. It is created by using new
keyword

Principles of OOP
1. Data Abstraction
It is an act of presenting essential features without including background details.
In abstraction the implementation details are not considered by the user.
Ex - Switch board
In switch board, only the switches are presented but how the current is flowing from switch to
device that is hidden

2. Inheritance
It is a principle in which the object of one class acquires the properties of another class. The
class which is inherited to another class is known as super class or parent class. The class which
inherits from super class is known as sub class or derived class.
The inheritance is done by using extends keyword
Advantages
1. It provides the reusability feature
2. Easy extension of existing code
3. Improves the programmer's productivity

Example:
3. Polymorphism
It is a principle in which more than one function having same name but behaves differently
with different set of values. It is also known as function overloading.
Example 1:

Example 2:
+ operator
5+3 = 8 (Addition when + operator is working with numbers)
"5"+"3" = 53 ( Concatenation when + operator is working with string values)

4. Encapsulation
The wrapping up of data and functions into a single unit called class is known as encapsulation.
In encapsulation implementation details are hidden from the user
Example 1 -
Medicine capsule in which different medicines are encapsulated in a single capsule

Example 2 -
Cola vending machine in which cola cans and the mechanism are encapsulated into a single
unit i.e. cola vending machine.

Difference between Data Abstraction and encapsulation


Data Abstraction Encapsulation
1. It is an act of presenting essential features 1. The wrapping up of data and
without including background details. functions into a single unit called class is
known as encapsulation.
2. In abstraction the implementation details are 2. In encapsulation implementation
not considered by the user. details are hidden from the user
Difference between super class and sub class
Super class Sub class
1. It is the class which is inherited to another 1. It is the class which inherits from super
class class
2. The object of super class acquires the 2. The object of sub class acquires the
properties of super class only properties of both super class and sub
class

What is reusability?
It means the properties of one class can be reused in another class. It is an important feature
of inheritance.

How encapsulation and data abstraction are interrelated?


Data Abstraction is the act of presenting necessary features without including background
details.
Encapsulation is the wrapping up of data and function into a single unit called class
Thus, data abstraction can be implemented when encapsulation is enforced.

What is compilation?
It is a process of converting source code into object code.

Why compiler is language specific?


Compiler is a translator program which translates high level language source code into
machine dependent object code. As each language is different from each other therefore
compiler is language specific.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy