Dear students, get fully solved assignments by professionals
Do send your query at :
or call us at :08263069601
BCS-031 ASSIGNMENT SOLUTION (2020-21)
Q1. a) What is Object Oriented Programming? Explain concept of Object,
Class and Inheritance with example of each.
Answer : - Object-Oriented Programming is a methodology or paradigm to design a
program using classes and objects. It simplifies the software development and
maintenance by providing some concepts :
- Object - Any entity that has state and behavior is known
as an object. An Object can be defined as an instance of a class.
- Class - Collection of objects is called class. It is a logical
entity. A class can also be defined as a blueprint from which you
Q1. b)Explain different operators available in C++ programming language.
Answer : -
Q1. c)Explain the use of followings in C++ programming with an example
program for each.
a) for
b) ?:
c) ::
d)while
Answer : -
a) for loop - A loop is used for executing a block of statements repeatedly until a
particular condition is satisfied.
b) ?: (Ternary Operator) - There is also a short-hand if
else, which is known as the ternary operator because it consists of three
operands. It can be
c) :: (Scope Resolution Operator) - In C++, scope resolution
operator (::) is used for following purposes -
1.
To access a global variable when there is a local variable with same name
d) while loop - A while loop statement repeatedly executes a target
statement as long as a given condition is true.
Syntax :
initialization;
while(condition)
{
Q2. a) What is access specifire ? Explain uses different types of access
specifiers in C++ with the help of example programs.
Answer : - Access Specifiers in C++ are used to set the accessibility of the class
members. That is, it sets some restrictions on the class members not to get
directly accessed by the outside functions.
Q2. b) Explain the following in detail, in context of C++ programming.
i.
Friend function
ii.
Encapsulation and data hiding
iii.
Abstract Class
Answer : -
i) Friend Function
A friend function of a class is defined outside that class scope but it
has the right to access all private and protected members of the class.
Q3. a)What is inheritance? Explain advantages of inheritance. What are
different types of inheritance in C++. Explain order of constructor calling in
multilevel inheritance with the help of example program.
Answer : - Inheritance in C++ is a mechanism in which one object acquires all the
properties and behaviors of a parent object.
The idea behind inheritance in C++ is that you can create new classes
that are built upon existing classes. When you inherit from an existing class,
you can reuse methods and fields of the parent class. Moreover, you can add
Q3. b) What is polymorphism? Explain different types of polymorphism in
C++ with the help of example programs.
Answer : - The word polymorphism means having many forms. In simple words, we can
define polymorphism as the ability of a message to be displayed in more than
one form.
Real life example of polymorphism - A person at the same time can
have different characteristic. Like a man at the same time is a father, a
husband, an employee. So the same person posses different behaviour in
different situations. This is called polymorphism.Q4.
a) Write a C++ program to overload ‘+’ operator to add two matrices. Make
necessary assumptions require.
Answer : -
Q4. b) Explain use of different stream manipulators in C++?
Answer : - Manipulators are values that you can insert into or extract from
iostreams to have special effects.
istr is an input stream.
ostr is an output stream.
Examples :
Predefined Manipulator |
Description |
ostr
<< dec, istr >> dec |
Makes
the integer conversion base 10. |
Q4. c) Write a C++ program to explain exceptions handling in C++.
Answer : - Exceptions are run-time anomalies or abnormal conditions that a program
encounters during its execution. C++ provides following specialized keywords
for this purpose.
Q5. a) What is function template and class template? Write appropriate
statements to create a template class for Queue data structure in C++.
Answer : -
Function Template - Function templates are special functions that can
operate with generic types. This allows us to create a function template whose
functionality can be adapted to more than one type or class without repeating
the entire code for each type.
In C++ this can be achieved using template parameters. A template
parameter is a special kind of parameter that can be used to pass a type as
argument: just like regular function parameters can be used to pass values to a
function, template parameters allow to pass also types to a function. These
function templates can use these
Q5. b) What is function overriding, explain with examples. Also explain
advantages of function overriding.
Answer : - Function overriding is a feature that allows us to have a same function
in child class which is already present in the parent class. A child class
inherits the data members and member functions of parent class, but when you
want to override a functionality in the child class then you can use function
overriding.
Example
Q5. c) Write C++ program to create an Account class to manage saving bank
account activities. Make necessary assumptions.
Answer : -
Dear students, get fully solved assignments by professionals
Do send your query at :
or call us at :08263069601
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.