0% found this document useful (0 votes)
3 views6 pages

Chapter 2 CS (Class 12)

The document provides an overview of object-oriented programming (OOP), explaining key concepts such as programming languages, paradigms, classes, and objects. It highlights the characteristics, advantages, and disadvantages of both procedural and object-oriented programming. Additionally, it discusses fundamental OOP concepts like data abstraction, encapsulation, modularity, inheritance, and polymorphism.

Uploaded by

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

Chapter 2 CS (Class 12)

The document provides an overview of object-oriented programming (OOP), explaining key concepts such as programming languages, paradigms, classes, and objects. It highlights the characteristics, advantages, and disadvantages of both procedural and object-oriented programming. Additionally, it discusses fundamental OOP concepts like data abstraction, encapsulation, modularity, inheritance, and polymorphism.

Uploaded by

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

Chapter-2 || Object oriented programming

Q. What is Computer programming?


Ans.: Computer programming is the process of writing step by step
instructions, called code, using special languages (Like python, C++,
Java) to make a computer perform tasks – like solving problems,
displaying messages, playing games, or running websites.
For example-
Just like a recipe tells you how to make a cake, a problem tells
the computers how to do a job-like calculating marks or showing
message on the screen.
Q. What is programming language?
Ans.: A programming language is a special language used to write
instructions that a computer can understand and follow.
Just like we use English, Hindi or Bodo to talk to people, we use
programming language like C++, python to communicate with
computers and tell them what to do.
Q. What is programming paradigm?
Ans.: A programming paradigm is a style or approaching for writing
and organizing computer programs. It provides rules or guidelines or
patters for how we should think about and structure our code.
For example:
Just like there are different ways to solve a math problem, there
are different ways to write a program. These style or approaches are
called programming paradigms.
Q. List same of the main programming paradigms.
Ans.: Some of the main programming paradigms are as follows:
1. Procedural programming.
2. Object-oriented programming.
3. Functional programming.
4. Logic programming.
Q. What is procedural programming?
Ans.: procedural programming is a programming paradigm where
the code is written as a series of step-by-step instructions to be
executed in sequence. It focuses on functions (also called procedure)
to perform tasks.
1
Simple put, we write a program as a set of instructions, just like
a recipe for baking a cake. The program was functions to break the
task into smaller, management parts.
For example: In coding it may look like the following:

Q. What is object-oriented programming?

Ans.: Object-oriented programming is a programming paradigm


where programs are organized using classes and object, where
objects represent real-world things. Each object has data (Called
attributes) and functions (Called methods) that defines its behavior.

Q. What is a class?

Ans.: A class is blueprint or model for creating objects. It defines the


structure (data/attributes) and the behavior (methods/functions) that
the object should have.
For example:
Think of Animal as a blueprint. Dog and cat are objects created
from this blueprint.
To be considered an animal, these objects might have data
such as species, number of-legs and has tails.
They may also have function like make sound () - for a dog, it
may return “Bark”, and for a cat, it may return “Meow”.
Q. What is an Object?

Ans.: An object is an instance or entity of a class that contains


specific data (Called attributes) and functions (Called methods)
based on the structure defined in the class.

2
Q. What are characteristics of procedural programming?
Ans.: The characteristics of procedural programming are:
 Its emphasis on writing algorithm (step by step procedures)
rather than data.
 Large programs are divided into smaller programs called
functions.
 Functions communicate with global variables.
 Data can more freely from one function to another function.
 It follows top-down programming approach.
 Example- C, FORTRANM, COBOL etc.
Q. What are the Characteristics of object-oriented programming?
Ans.: The characteristics of object-oriented programming are:
 Its emphasis on data rather than procedures.
 Programs are divided into small parts known as objects.
 Objects can move and communicate with each other through
member functions.
 Data hiding is possible due to abstraction.
 It follows bottom-up approach.
 Examples- C++, JAVA, Python, C#, NET etc.
BASIC CONCEPTS OOP
Object-oriented programming (OOP) helps overcome the
limitations or problems faced by conventional or traditional
programming approach like procedural programming Traditional
methods often suffer from issues such as code redundancy
(repeating code) and difficult maintenance, especially in large or
complex programs.
OPP address these issues by introducing a set of case concepts
(also called pillar) that make programs more modular, reusable, and
easier to manage.
These concepts are:
 Data Abstraction.
 Data Encapsulation
 Modularity
 Inheritance
 Polymorphism
Q. What is data abstraction?

3
Ans.: Data Abstraction is the process of hiding unnecessary details
and showing only the essential features of an object or systems by
allowing users to focus only on what they meet to know.
For example:
When driving a car, the diver only needs to know how to use
the steering wheel, clutch, accelerator and breaks. The internal
working of the engine wiring or fuel injection system is hidden from
the driver because it’s not necessary to operate the car. This is
abstraction.
Q. What is Data Encapsulation?
Ans.: Data Encapsulation is the process of wrapping data (variables)
and functions (methods) together into a single unit called class. It is
one of the key features of object-oriented programming and
supports the concept of data hiding.
For example:
Just like important documents are kept in a locked box and can
only be accessed using a key, Class variables are kept private and
can only be accessed using specific methods.
Q. What is Modularity?
Ans.: Modularity is the process of dividing a program into smaller,
independent parts called modules. Each module performs a specific
task, and all modules work together to form a complete program.
This makes the program easier to understand manage, debug and
update since changes can be made to one module without affecting
the others.
For example:
Just like our body is made up of parts like the hands, legs, and
brain – each with a specific function (movement, working, and
thinking) – a program is made of different modules that handle
different tasks.
Q. What are the advantages of Modularity?
Ans.: Dividing a program into modules has the following advantages:
 It reduces code complexity, making it easier to write and
manage large programs.
 It allows for well-defined, independent sections, which can be
tested, debugged, and updated separately.

4
Note:
Bag= an error in the code. (Wrong output, system crash, unexpected
behavior)
Debug= the process of locating that bug and correcting or fixing it.
Q. What is Inheritance?
Ans.: Inheritance is an object-oriented programming concept where
one class can inherit properties and behavior (data and methods)
from another class. It allows code reusability and helps create a
hierarchy between classes.
For example:
A class car can inherit properties from a class automobile,
which itself inherits from another class vehicle. Here, vehicle is the
base (or parent) class, and automobile, and car are derived (or child)
classes that inherits from it.
Q. What are the features or characteristics of inheritance?
Ans.: Inheritance provides the following features:
1. It helps us model real-world relationships in programs by
allowing one class to inherit from another.
2. It supports code reusability; a new class can be created by
building on existing ones.
3. It is transitive in nature- if class A inherits from class B, and
class C inherits from class A, then class C automatically inherits
the properties of both A and B.
Q. What is polymorphism?
Ans.: polymorphism means “many form”. It is a feature of object-
Oriented programming that allows the same function or method
name to behave differently depending on the objects or context.
For example:
One common example of polymorphism is function overloading,
where multiple functions have the same name but different
parameters.

Q. What are advantages of object oriented programming?


Ans.: The advantages of object-oriented programming are as follow:
5
1. Re-use of code: We can create a general class and derive new
classes from it, reusing its properties and methods.
2. Ease of comprehension: Since OOP is structured like real-
world systems; it makes the code easier for the programmer to
understand.
3. Ease of fabrication and maintenance: Since code is divided
into classes and objects, it becomes easier to build, test,
update, and fix without affecting the entire program.
4. Easy redesign and extension: Programs can be easily
modified or extended without rewriting the whole code.
Q. What are the disadvantages of object oriented programming?
Ans.: some of the disadvantages of object oriented programming are
as follow:
1. Classes tend to be overly generalized: Classes may be
designed too broadly, making them hard to understand and
maintain.
2. Relationships between classes and feel artificial: To
reuse code, unnecessary links between unrelated classes might
be forced.
3. OOP design can be tricky: Planning a good OOP structure
takes more time and effort than procedural code.
4. Requires proper planning and design: Class structure and
object interaction must be carefully planned before coding.
5. Requires good programming skills: OOP needs a strong
understands of how to design classes, use object, and think in
terms of real word entities and their interactions.

You might also like