SlideShare a Scribd company logo
1 of 3
1. Difference between C and C++
C++ is an extension of C language. This means that you can not only use the new features introduced with C++ but can also use the power
and efficiency of C language. C and C++ are no more language for writing compilers and other languages, these general purpose languages
are used worldwide in every field.
The main difference between C and C++ is that C++ is object oriented while C is function or procedure oriented. Object oriented
programming paradigm is focused on writing programs that are more readable and maintainable. It also helps the reuse of code by
packaging a group of similar objects or using the concept of component programming model. It helps thinking in a logical way by using the
concept of real world concepts of objects, inheritance and polymorphism. It should be noted that there are also some drawbacks of such
features. For example using polymorphism in a program can slow down the performance of that program.
On the other hand, functional and procedural programming focus primarily on the actions and events, and the programming model focuses
on the logical assertions that trigger execution of program code.
2. What is polymorphism? Explain with example
Polymorphism refers to the ability to assume different forms. In OOP, it indicates a language’s ability to handle objects differently based on
their runtime type. When objects communicate with one another, we say that they send and receive messages.
An example of polymorphism can be demonstrated with geometric shapes. Suppose we have a Triangle, a Square, and a Circle. Each class is
a Shape and each has a method named Draw that is responsible for rendering the Shape to the screen. With polymorphism, you can write a
method that takes a Shape object or an array of Shape objects as a parameter (as opposed to a specific kind of Shape). We can pass
Triangles, Circles, and Squares to these methods without any problems, because referring to a class through its parent is perfectly legal. In
this instance, the receiver is only aware that it is getting a Shape that has a method named Draw, but it is ignorant of the specific kind of
Shape. If the Shape were a Triangle, then Triangle’s version of Draw would be called. If it were a Square, then Square’s version would be
called, and so on.
Advantage of polymorphism is that the sender of a message doesn’t need to know which class the receiver is a member of. It can be any
arbitrary class. The sending object only needs to be aware that the receiving object can perform a particular behaviour.
3. What are the basic data types?
A programming language is proposed to help programmer to process certain kinds of data and to provide useful output. The task of data
processing is accomplished by executing series of commands called program. A program usually contains different types of data types
(integer, float, character etc.) to store the values being used in the program along with some library function and user defined function
(UDF) to process that stored data. C language is rich of data types and library function. A C programmer has to employ proper data type as
per his /her requirements has different data types for different types of data and can be broadly classified as:
 Primary data types
 Secondary data types
4. Explain briefly control statements with an example.
When a programmer is crafting a program, it is good practice to break the program down into pieces that can be thought of independently.
Once the program has been completed, we can think of its execution as being a series of these pieces that work together in a certain
sequence. These pieces then pass the control of the program between each other. While one piece has the control, the other pieces are
inactive. This is known as the flow of control in a program. If our program had three parts, called Start, Middle, and End, the flow of control
could look like:
Control statements: Control Statements, then, are ways for a programmer to control what pieces of the program are to be executed at
certain times. The syntax of Control statements are very similar to regular English, and are very similar to choices that we make every day.
There are two basic types of control statements: branching statements and loops.
Branching statements
We will first look at branching statements. Let's say Julien is shopping at a mall and he finds a CD that he wants to buy. Julien then checks
his pocket to see if he has enough money to pay for the CD. When he pulls his money out of his pocket Julian may be thinking: "if I have
more money than the price of the CD then I will buy the CD." In pseudocode that thought could be translated into:
if (my_money > cost_of_CD) then
buy_CD
else
get_a_job
end if;
Loops
Let's pretend now that Julien was buying a house instead of a CD. If Julien wanted to buy the house without taking a loan from the bank, he
would have to wait until he had enough money to buy the house. The pseudocode for this could be:
if (my_money > cost_of_house) then
buy_house
end if;
But this means that Julien would only check once if he had enough money to buy the house. What we want to describe is the fact that Julien
needs to keep waiting until he has enough money to buy the house.
while (my_money < cost_of_house)
work_more
end while;
buy_house;
This is a loop statement.
5. Explain briefly about the escape sequence characters? Give example?
A character constant in C++ must contain one or more characters and must be enclosed in single quotation marks. For example ‘A’, ‘9’, etc.
C++ allows nongraphic characters which cannot be typed directly from keyboard, e.g., backspace, tab, carriage return etc. These characters
can be represented by using a escape sequence. An escape sequence represents a single character. The following table gives a listing of
common escape sequences.
Escape Sequence Nongraphic Character
a Bell (beep)
b Backspace
f Formfeed
n Newline or line feed
r Carriage return
t Horizontal tab
v Vertical tab
? Question mark
  Backslash
 ’ Single quote
 ” Double quote
 xhh Hexadecimal number (hh represents the number in hexadecimal)
 000 Octal number (00 represents the number in octal)
0 Null
6.Explain class with an example?
An object, such as a CD Player, a printer, a car, etc, is built from assembling various parts. In the same way, C++ allows you to group
various variables and create a new object called a class. A class is an organisation of data and functions which operate on them. Data
structures are called data members and the functions are called member functions, The combination of data members and member functions
constitute a data object or simply an object.
Imagine a company that manufactures shoe boxes hires you to write a program that would help design and identify those shoe boxes. A shoe
box is recognized for its dimensions (length, width, height), color, and shoe size that a particular box can contain, etc. The variables that
characterize such an object could be:
double Length, Width, Height;
char Color;
float ShoeSize;
A Class Example
class ShoeBox
{
double Length, Width, Height;
char Color[12];
float ShoeSize;
};The items that compose a class are called members of the class.
7. Features of c++ language.
 The C++ programming language is based on the C language.
 In C++, you can develop new data types that contain functional descriptions (member functions) as well as data representations.
 These new data types are called classes.
 The work of developing such classes is known as data abstraction.
 You can work with a combination of classes from established class libraries, develop your own classes, or derive new classes
from existing classes by adding data descriptions and functions.
 New classes can contain (inherit) properties from one or more classes.
 The classes describe the data types and functions available, but they can hide (encapsulate) the implementation details from the
client programs.
 You can define a series of functions with different argument types that all use the same function name.
 This is called function overloading. A function can have the same name and argument types in base and derived classes.
 Declaring a class member function in a base class allows you to override its implementation in a derived class. If you use virtual
functions, class-dependent behaviour may be determined at run time. This ability to select functions at run time, depending on
data types, is called polymorphism
 Adding properties to operators for new data types is called operator overloading.
 The C++ language provides templates and several keywords not found in the C language.
 Other features include try-catch-throw exception handling, stricter type checking and more versatile access to data and functions
compared to the C language.

More Related Content

What's hot

Java Data Types
Java Data TypesJava Data Types
Java Data TypesSpotle.ai
 
C++ Langauage Training in Ambala ! BATRA COMPUTER CENTRE
C++  Langauage Training in Ambala ! BATRA COMPUTER CENTREC++  Langauage Training in Ambala ! BATRA COMPUTER CENTRE
C++ Langauage Training in Ambala ! BATRA COMPUTER CENTREjatin batra
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programmingHarshita Yadav
 
C data types, arrays and structs
C data types, arrays and structsC data types, arrays and structs
C data types, arrays and structsSaad Sheikh
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Typesk v
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Examshishamrizvi
 
+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II NotesAndrew Raj
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C ProgrammingKamal Acharya
 
Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++Deepak Singh
 
Oop with c++ notes unit 01 introduction
Oop with c++ notes   unit 01 introductionOop with c++ notes   unit 01 introduction
Oop with c++ notes unit 01 introductionAnanda Kumar HN
 
C++
C++C++
C++k v
 
DATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.netDATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.netSireesh K
 
Data types in java | What is Datatypes in Java | Learning with RD | Created b...
Data types in java | What is Datatypes in Java | Learning with RD | Created b...Data types in java | What is Datatypes in Java | Learning with RD | Created b...
Data types in java | What is Datatypes in Java | Learning with RD | Created b...rahuldaredia21
 
C PROGRAMMING LANGUAGE
C  PROGRAMMING  LANGUAGEC  PROGRAMMING  LANGUAGE
C PROGRAMMING LANGUAGEPRASANYA K
 

What's hot (20)

Java Data Types
Java Data TypesJava Data Types
Java Data Types
 
C++ Langauage Training in Ambala ! BATRA COMPUTER CENTRE
C++  Langauage Training in Ambala ! BATRA COMPUTER CENTREC++  Langauage Training in Ambala ! BATRA COMPUTER CENTRE
C++ Langauage Training in Ambala ! BATRA COMPUTER CENTRE
 
Data Handling
Data HandlingData Handling
Data Handling
 
Data type
Data typeData type
Data type
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
C data types, arrays and structs
C data types, arrays and structsC data types, arrays and structs
C data types, arrays and structs
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
 
Smali语法
Smali语法Smali语法
Smali语法
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
 
+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes
 
Data types
Data typesData types
Data types
 
Notes on c++
Notes on c++Notes on c++
Notes on c++
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
 
Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++
 
Oop with c++ notes unit 01 introduction
Oop with c++ notes   unit 01 introductionOop with c++ notes   unit 01 introduction
Oop with c++ notes unit 01 introduction
 
C++
C++C++
C++
 
DATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.netDATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.net
 
Data types in java | What is Datatypes in Java | Learning with RD | Created b...
Data types in java | What is Datatypes in Java | Learning with RD | Created b...Data types in java | What is Datatypes in Java | Learning with RD | Created b...
Data types in java | What is Datatypes in Java | Learning with RD | Created b...
 
Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11
 
C PROGRAMMING LANGUAGE
C  PROGRAMMING  LANGUAGEC  PROGRAMMING  LANGUAGE
C PROGRAMMING LANGUAGE
 

Similar to Oo ps exam answer2

C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]Rome468
 
Paradigms.pptx
Paradigms.pptxParadigms.pptx
Paradigms.pptxaikomo1
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++Amresh Raj
 
classVI_Coding_Teacher_Presentation.pptx
classVI_Coding_Teacher_Presentation.pptxclassVI_Coding_Teacher_Presentation.pptx
classVI_Coding_Teacher_Presentation.pptxssusere336f4
 
INTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGE
INTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGEINTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGE
INTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGERathnaM16
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Languagedheva B
 
1 intro
1 intro1 intro
1 introabha48
 
Bca winter 2013 2nd sem
Bca winter 2013 2nd semBca winter 2013 2nd sem
Bca winter 2013 2nd semsmumbahelp
 
C++ programming introduction
C++ programming introductionC++ programming introduction
C++ programming introductionsandeep54552
 
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Akhil Mittal
 
香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideShare香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideSharebiyu
 
M.c.a. (sem iv)- java programming
M.c.a. (sem   iv)- java programmingM.c.a. (sem   iv)- java programming
M.c.a. (sem iv)- java programmingPraveen Chowdary
 

Similar to Oo ps exam answer2 (20)

M.c.a (sem iii) paper - i - object oriented programming
M.c.a (sem   iii) paper - i - object oriented programmingM.c.a (sem   iii) paper - i - object oriented programming
M.c.a (sem iii) paper - i - object oriented programming
 
C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]
 
Paradigms.pptx
Paradigms.pptxParadigms.pptx
Paradigms.pptx
 
C++
C++C++
C++
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
Unit 5.ppt
Unit 5.pptUnit 5.ppt
Unit 5.ppt
 
C++ programing lanuage
C++ programing lanuageC++ programing lanuage
C++ programing lanuage
 
classVI_Coding_Teacher_Presentation.pptx
classVI_Coding_Teacher_Presentation.pptxclassVI_Coding_Teacher_Presentation.pptx
classVI_Coding_Teacher_Presentation.pptx
 
INTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGE
INTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGEINTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGE
INTRODUCTION TO CODING-CLASS VI LEVEL-DESCRIPTION ABOUT SYNTAX LANGUAGE
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Language
 
1 puc programming using c++
1 puc programming using c++1 puc programming using c++
1 puc programming using c++
 
1 intro
1 intro1 intro
1 intro
 
Seminar
SeminarSeminar
Seminar
 
SEMINAR
SEMINARSEMINAR
SEMINAR
 
Bca winter 2013 2nd sem
Bca winter 2013 2nd semBca winter 2013 2nd sem
Bca winter 2013 2nd sem
 
C++ programming introduction
C++ programming introductionC++ programming introduction
C++ programming introduction
 
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
 
Technical Interview
Technical InterviewTechnical Interview
Technical Interview
 
香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideShare香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideShare
 
M.c.a. (sem iv)- java programming
M.c.a. (sem   iv)- java programmingM.c.a. (sem   iv)- java programming
M.c.a. (sem iv)- java programming
 

Recently uploaded

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

Oo ps exam answer2

  • 1. 1. Difference between C and C++ C++ is an extension of C language. This means that you can not only use the new features introduced with C++ but can also use the power and efficiency of C language. C and C++ are no more language for writing compilers and other languages, these general purpose languages are used worldwide in every field. The main difference between C and C++ is that C++ is object oriented while C is function or procedure oriented. Object oriented programming paradigm is focused on writing programs that are more readable and maintainable. It also helps the reuse of code by packaging a group of similar objects or using the concept of component programming model. It helps thinking in a logical way by using the concept of real world concepts of objects, inheritance and polymorphism. It should be noted that there are also some drawbacks of such features. For example using polymorphism in a program can slow down the performance of that program. On the other hand, functional and procedural programming focus primarily on the actions and events, and the programming model focuses on the logical assertions that trigger execution of program code. 2. What is polymorphism? Explain with example Polymorphism refers to the ability to assume different forms. In OOP, it indicates a language’s ability to handle objects differently based on their runtime type. When objects communicate with one another, we say that they send and receive messages. An example of polymorphism can be demonstrated with geometric shapes. Suppose we have a Triangle, a Square, and a Circle. Each class is a Shape and each has a method named Draw that is responsible for rendering the Shape to the screen. With polymorphism, you can write a method that takes a Shape object or an array of Shape objects as a parameter (as opposed to a specific kind of Shape). We can pass Triangles, Circles, and Squares to these methods without any problems, because referring to a class through its parent is perfectly legal. In this instance, the receiver is only aware that it is getting a Shape that has a method named Draw, but it is ignorant of the specific kind of Shape. If the Shape were a Triangle, then Triangle’s version of Draw would be called. If it were a Square, then Square’s version would be called, and so on. Advantage of polymorphism is that the sender of a message doesn’t need to know which class the receiver is a member of. It can be any arbitrary class. The sending object only needs to be aware that the receiving object can perform a particular behaviour. 3. What are the basic data types? A programming language is proposed to help programmer to process certain kinds of data and to provide useful output. The task of data processing is accomplished by executing series of commands called program. A program usually contains different types of data types (integer, float, character etc.) to store the values being used in the program along with some library function and user defined function (UDF) to process that stored data. C language is rich of data types and library function. A C programmer has to employ proper data type as per his /her requirements has different data types for different types of data and can be broadly classified as:  Primary data types  Secondary data types 4. Explain briefly control statements with an example. When a programmer is crafting a program, it is good practice to break the program down into pieces that can be thought of independently. Once the program has been completed, we can think of its execution as being a series of these pieces that work together in a certain sequence. These pieces then pass the control of the program between each other. While one piece has the control, the other pieces are inactive. This is known as the flow of control in a program. If our program had three parts, called Start, Middle, and End, the flow of control could look like:
  • 2. Control statements: Control Statements, then, are ways for a programmer to control what pieces of the program are to be executed at certain times. The syntax of Control statements are very similar to regular English, and are very similar to choices that we make every day. There are two basic types of control statements: branching statements and loops. Branching statements We will first look at branching statements. Let's say Julien is shopping at a mall and he finds a CD that he wants to buy. Julien then checks his pocket to see if he has enough money to pay for the CD. When he pulls his money out of his pocket Julian may be thinking: "if I have more money than the price of the CD then I will buy the CD." In pseudocode that thought could be translated into: if (my_money > cost_of_CD) then buy_CD else get_a_job end if; Loops Let's pretend now that Julien was buying a house instead of a CD. If Julien wanted to buy the house without taking a loan from the bank, he would have to wait until he had enough money to buy the house. The pseudocode for this could be: if (my_money > cost_of_house) then buy_house end if; But this means that Julien would only check once if he had enough money to buy the house. What we want to describe is the fact that Julien needs to keep waiting until he has enough money to buy the house. while (my_money < cost_of_house) work_more end while; buy_house; This is a loop statement. 5. Explain briefly about the escape sequence characters? Give example? A character constant in C++ must contain one or more characters and must be enclosed in single quotation marks. For example ‘A’, ‘9’, etc. C++ allows nongraphic characters which cannot be typed directly from keyboard, e.g., backspace, tab, carriage return etc. These characters can be represented by using a escape sequence. An escape sequence represents a single character. The following table gives a listing of common escape sequences. Escape Sequence Nongraphic Character a Bell (beep) b Backspace f Formfeed n Newline or line feed r Carriage return t Horizontal tab v Vertical tab ? Question mark Backslash ’ Single quote ” Double quote xhh Hexadecimal number (hh represents the number in hexadecimal) 000 Octal number (00 represents the number in octal) 0 Null 6.Explain class with an example? An object, such as a CD Player, a printer, a car, etc, is built from assembling various parts. In the same way, C++ allows you to group various variables and create a new object called a class. A class is an organisation of data and functions which operate on them. Data structures are called data members and the functions are called member functions, The combination of data members and member functions constitute a data object or simply an object. Imagine a company that manufactures shoe boxes hires you to write a program that would help design and identify those shoe boxes. A shoe box is recognized for its dimensions (length, width, height), color, and shoe size that a particular box can contain, etc. The variables that characterize such an object could be: double Length, Width, Height; char Color; float ShoeSize; A Class Example class ShoeBox { double Length, Width, Height; char Color[12]; float ShoeSize; };The items that compose a class are called members of the class. 7. Features of c++ language.  The C++ programming language is based on the C language.  In C++, you can develop new data types that contain functional descriptions (member functions) as well as data representations.  These new data types are called classes.  The work of developing such classes is known as data abstraction.  You can work with a combination of classes from established class libraries, develop your own classes, or derive new classes from existing classes by adding data descriptions and functions.  New classes can contain (inherit) properties from one or more classes.
  • 3.  The classes describe the data types and functions available, but they can hide (encapsulate) the implementation details from the client programs.  You can define a series of functions with different argument types that all use the same function name.  This is called function overloading. A function can have the same name and argument types in base and derived classes.  Declaring a class member function in a base class allows you to override its implementation in a derived class. If you use virtual functions, class-dependent behaviour may be determined at run time. This ability to select functions at run time, depending on data types, is called polymorphism  Adding properties to operators for new data types is called operator overloading.  The C++ language provides templates and several keywords not found in the C language.  Other features include try-catch-throw exception handling, stricter type checking and more versatile access to data and functions compared to the C language.