You are on page 1of 33

http://vujannat.ning.

com
BEST SITE TO HELP STUDENTS
FINALTERM EXAMINATION
FALL 2006 Marks: 50
CS304 - OBJECT ORIENTED PROGRAMMING Time: 120min
(Session - 1 )

StudentID/LoginID: ______________________________

Student Name: ______________________________

Center Name/Code: ______________________________

Exam Date: Friday, February 09, 2007

Please read the following instructions carefully before attempting any


of the questions:
1. Attempt all questions. Marks are written adjacent to each question.
2. Do not ask any questions about the contents of this examination
from anyone.
a. If you think that there is something wrong with any of the
questions, attempt it to the best of your understanding.
b. If you believe that some essential piece of information is
missing, make an appropriate assumption and use it to solve the
problem.
c. Write all steps, missing steps may lead to deduction of marks.
d. All coding questions should be answered using the C ++ syntax.
e. Choose the most appropriate choice (among the given), while answering
MCQs.
3. You are not allowed to use IDE (Dev-C++ or any) in your paper.

**WARNING: Please note that Virtual University takes serious note of


unfair means. Anyone found involved in cheating will get an `F` grade
in this course.

For Teacher's use only


Question 1 2 3 4 5 6 7 8 9 Total
Marks

Question No: 1 ( Marks: 2 ) - Please choose one


Which of the statements is true about destructor?

► Destructors are used to initialize data members

► Destructors return types are always void

► Destructors are called in reverse order of constructor called in a class hierarchy

► Destructors are used to display the data members of their respective class

Question No: 2 ( Marks: 2 ) - Please choose one

Identify the type of variable that is part of a class, yet is not part of an object of that class.

► instance

► static

► global

► local

Question No: 3 ( Marks: 2 ) - Please choose one

Which of the following operators can not be overloaded?

► ++

► new

► sizeof

► =

Question No: 4 ( Marks: 2 ) - Please choose one


Target function for a call is selected at compile time in case of

► Static binding

► Polymorphism

► Encapsulation

► Dynamic binding

Question No: 5 ( Marks: 2 ) - Please choose one

Suppose it is required to implement a single functionality with different data type, which of the
following techniques should be used

► Inheritance

► Friend function

► Templates

► Encapsulation

Question No: 6 ( Marks: 5 )

Identify and correct the error(s) in the given code segment.

template< typename T >


class Parent {
// …
};

template< >
class Child< int > : public Parent {
// …
};

int main() {
Parent< char > obj;
Child< int > obj2;
return 0;
}
Question No: 7 ( Marks: 10 )

Given are two classes A and B. class B is inherited from class A. Write a code snippet(for main
function) that polymorphically call the method of class B. Also what changes do you suggest in the
given code segment that are required to call the class B method polymorphically.

class A
{
public:
void method() { cout<<"A's method \n"; }

};

class B : public A
{

public:
void method() { cout<<"B's method\n"; }

};

Question No: 8 ( Marks: 10 )

Implement the given class hierarchy where there exist a relation ship of inheritance between
Employee and Contract (for contract employee). The Display() function of Contract should
display the data that includes ; Name, Num_hours, Per_hour_sal, Salary

Monthly salary of contract employee is calculated as

Salary = Per_hour_sal*Num_hours
Question No: 9 ( Marks: 15 )

A Real world Problem:

This is a business rule of a bank that the Balance of customer must always be Positive,
Further that it is also a business rule that a customer can not withdraw amount greater than his/her
current balance.

Question statement
You are required to write a C++ program to solve this real world problem, using Exception
Handling.

Your program should consist of a class Customer and 4 instance variables. Cust_name,
Cust_AC_No, Cust_balance, Amount_withdraw.

Cust_name : Customer Name


Cust_AC_No : Customer Account Number
Cust_balance : Customer Balance
Amount_withdraw : Amount that is to be withdraw

The class should further consists of getter and setter function for each instance variable.
The setter function of Cust_balance consists of a try and a catch block, if the user enters the
balance less than zero (means negative, which is not possible) then this function should throw an
exception, and its corresponding catch block should handle this exception by providing another
opportunity to the user to enter the balance again.

Similarly the setter of Amount_withdraw variable should also have a try and a catch blocks. If the
user enters the withdraw amount greater than the current balance then this function should throw
an exception, and its corresponding catch block should handle this exception.
In main function just declare an object of Customer class and call all its setter and getter functions.
www.vujannat.ning.com

CS304 Object Oriented Programming


Final Term Examination – Spring 2005
Time Allowed: 150 Minutes

Please read the following instructions carefully before


attempting any of the questions:
1. Attempt all questions. Marks are written adjacent to each
question.
2. Do not ask any questions about the contents of this
examination from anyone.
a. If you think that there is something wrong with any of
the questions, attempt it to the best of your understanding.
b. If you believe that some essential piece of information is
missing, make an appropriate assumption and use it to
solve the problem.
c. Write all steps, missing steps may lead to deduction of
marks.
d. All coding questions should be answered using the C ++
syntax.
You are allowed to use the Dev-C++ compiler to write and test your
code. If you do so please remember to copy and paste your code into
the examination solution area. (Do NOT share your code; your
colleague could get higher marks than you!!)

**WARNING: Please note that Virtual University takes serious


note of unfair means. Anyone found involved in cheating will
get an `F` grade in this course.

Total Marks: 55 Total Questions: 03

Question No. 1 Marks : 10

class Exception {
protected:
char message [30] ;
public:
Exception() {strcpy(message,"Exception");}
char * what() { return message; }
};

class DerivedException : public Exception {


public:
DerivedException() {strcpy(message,"Derived exception");}
};

class A {
public:
A(){ cout << "Constructor A\n";}
~A(){
cout << "Destructor A\n";
if(condition1) //condition one
throw Exception();
}
};

class B {
public:
B(){ cout << "Constructor B\n";
if(condition2) //condition two
throw 1;
}
~B(){ cout << "Destructor B\n";}
};

void Function1() {
DerivedException DE;
cout << "I am Function1" << endl;
if(condition3) //condition three
{
throw DE;
}
}

void Function2() {
cout << "I am Function2\n" << endl;
try{
B obj2;
Function1();
}
catch(int)
{
throw 10.1;
}
catch(...){
throw;
}
}

void Function3(){
cout << "I am Function3\n";
A obj;
Function2();
}

int main() {
try{
Function3();
}

catch(DerivedException & e1){


cout << "Exception: " << e1.what() << endl;
}
catch(Exception & e2){
cout << "Exception: " << e2.what() << endl;
}
catch(int i){
cout << "Exception: int";
}
catch(...){
cout << "Exception: unknown\n";
}

cout << "End of Program\n";


return 0;
}

a. What will be the output when only condition one is true? 02


b. What will be the output when only condition two is true? 02
c. What will be the output when only condition three is true? 02
d. What will be the out put when all three conditions (1,2&3) are true? 02
e. Make changes in the following code so that "Function" only throws 02
the three types of exceptions mentioned in the body and no other exception.

void Function(){
if(condition1){

throw Exception();
}
if(condition2){

throw DerivedException();
}
if(condition3){
throw 1;
}
}

Question No. 2 Marks : 30

a) The following program causes a compile-time error. Identify the error, 10


explain the cause, and correct it.

template< typename T >


class Tree {
// …
};

template< >
class RBTree< int > : public Tree {
// …
};

int main() {
Tree< char > chTree;
RBTree< int > intRBTree;
return 0;
}
b) Consider the following vector class: 20

class Vector {

public:

int* first();
int* last();
int* next( int* );
};

A reverse iterator is an iterator that traverses backwards for


the operator ++, and forwards for the operator --. Write code
for a reverse iterator that works with the following function:
(Note: typename T stands for iterator type and U for element
type)

template< typename T, typename U >


T find( T start, T beyond, const U& x ) {
while ( start != beyond && *start != x )
++strat;
return start;
}
Question No. 3 Marks : 15

a) Briefly describe the two major issues in multiple inheritance? Illustrate 04


by giving an example of each.
b) Describe the three essential characteristics of an object from the perspective 03
of object-oriented paradigm.
c) Why use abstract classes at all? Why not just declare a class and then make 02
sure you do not declare any variables of that type?
d) What is the difference between a partial and complete template 03
specialization? Give an example of each.
e) What are the two mechanism of calling base class assignment operator 03
from derived class assignment operator?
WWW.vujannat.ning.Com
Connecting VU Students

CS304
Final Term Examination – Spring 2006
Time Allowed: 150 Minutes

Question No. 1 Marks : 1

What is the name of the function that overloads the + operator for the complex class?
1. add
2. complex add
3. +
4. operator +
5. operator

Question No. 2 Marks : 3

Within a member function, the expression *this always refers to

1. the objects passes as an argument to the function


2. the address of an object
3. a temporary object created within the function
4. the object that called the function
5. the object that will be returned from the function

Question No. 3 Marks : 3

Write two classes Customer and Account. Declare Account as a friend class of Customer.

Private data members of Customer class are:


i. cusName
ii. cusAddress
iii. cusbalance

Private data members of Account class are:


i. AccTitle
ii. AccBalance

a) Write parameterized constructors for both classes i.e. Customer and Account, to initialize their
data members. For Customer class initialize cusbalance to zero.
b) Write a member function of Account class, named setBalance ( ) to assign AccBalance to
cusbalance, which is a data member of Customer class.
Write a member function for the Customer class, named displaytData ( ) to display the values of
Customer’s cusName, cusAddress and cusbalance.

Question No. 4 Marks : 1

Given below is a code snippet:


Class YourClass
{
private:
YourClass();
// other private methods
public:
// public members
}
void main()
{
YourClass *Yclass;
Yclass = new YourClass[3];
}

Do you see any problem with the code above?


1. The class name is invalid
2. The public members should be provided above the private members in the class
3. The constructor is declared private but an array is being created in the function main, therefore,
the statement will result in an error
4. The array creating syntax is incorrect
5. Return type of main () is not int

Question No. 5 Marks : 1

a) Write a C++ program which creates a class Employee with the following attribute

1. name

This class should have a parameterized constructor and destructor, the getter/setter functions and a
virtual member function called pay () that returns the salary of the Employee.

b) Create a class named as Salaried that inherits from class Employee. A Salaried object has the
following attribute

1. salary

This class should also have parameterized constructor and default destructor, setter/getter functions
and a pay () member function.

c) Similarly, develop a class named as Hourly that inherits from class Employee. An Hourly object is
distinguished by the following attributes

1. hours
2. rate
This class should also have a parameterized constructor, default destructor, setter/getter functions and
a pay () member function.
Your program should create objects of Salaried and Hourly classes and then invoke the pay () function
of these classes polymorphicly (through Employee Object)

Question No. 6 Marks : 1

The code for an inline function


1. is inserted into the program in the place of each of function call
2. is not generated by the compiler itself, but by the processor
3. takes extra memory
4. occurs only once in the program
5. is merely symbolic; it is not actually executed

Question No. 7 Marks : 1

Write a C++ program to determine the area and perimeter of rectangle according to the length and
width entered by the user. Your code should include a template <class T>.

Your rectangle class has the following data member.

1: length
2: width

The area and perimeter should be calculated for each int, float and double type data member. Hence the
data member of the class rectangle should be of type Template as well.

Your program should have following member functions of a template <class T>.

1: area ();
This member function will calculate the area of the rectangle. The area of a rectangle can be calculated
by the following formula:

Area = length * width

2: perimeter ();

This member function will calculate the perimeter of the rectangle where the formula for perimeter of
rectangle is

Perimeter = 2 *(length + width)

Area() and perimeter() member functions should return the same type on which the data is
manipulating. For example
If the area is calculating for a rectangle of int type length and width, then this member function should
return an integer number and vice versa.

Take three instances of one of each type of data members’ int, float, and double for the class rectangle
in main ().

Also write setter and getter for the data member of the class rectangle.

Question No. 8 Marks : 1


There is a class Student, Which one of the following is a valid destructor for this class
1. Student();
2. Student(int);
3. ~ Student();
4. int~ Student();
5. ~ Student(int);

Question No. 9 Marks : 1

Is there any difference between abstract and base class? If yes, then what is it?

Question No. 10 Marks : 3

Question No. 11 Marks : 3

Question No. 12 Marks : 10

Question No. 13 Marks : 1

Question No. 14 Marks : 1

Question No. 15 Marks : 1

Question No. 16 Marks : 1

Question No. 17 Marks : 1

Question No. 18 Marks : 10

Question No. 19 Marks : 1


Question No. 20 Marks : 1

Question No. 21 Marks : 1

Question No. 22 Marks : 1

Question No. 23 Marks : 1

Question No. 24 Marks : 1

Question No. 25 Marks : 3

Question No. 26 Marks : 1

Question No. 27 Marks : 1

Question No. 28 Marks : 1

Question No. 29 Marks : 1

Question No. 30 Marks : 1

Question No. 31 Marks :1


Question No. 32 Marks : 1
www.vujannat.ning.com
CS304 Object Oriented Programming
Mid Term Examination – Spring 2005
Time Allowed: 90 Minutes

Please read the following instructions carefully before attempting any of


the questions:
1. Attempt all questions. Marks are written adjacent to each question.
2. Do not ask any questions about the contents of this examination from anyone.
a. If you think that there is something wrong with any of the questions, attempt it
to the best of your understanding.
b. If you believe that some essential piece of information is missing, make an
appropriate assumption and use it to solve the problem.
c. Write all steps, missing steps may lead to deduction of marks.
d. All coding questions should be answered using the C ++ syntax.

You are allowed to use the Dev-C++ compiler to write and test your code. If you
do so please remember to copy and paste your code into the examination
solution area. (Do NOT share your code; your colleague could get higher
marks than you!!) **WARNING: Please note that Virtual University takes
serious note of unfair means. Anyone found involved in cheating will
get an `F` grade in this course.
Total Marks: 40 Total Questions: 3

Question No. 1 Marks : 30


Design and implement a String class that makes the following code work properly. The
class should store the string in a dynamically allocated memory.

int main()
{
String X, Y = "World!";
X = "Hello " + Y;
cout<< X << endl;
return 0;
}

Question No. 2 Marks : 05


a. Write the exact type of this pointer in a member function of a class XYZ. 02
b. Write three distinct situations in which copy constructor of a class is called. 03
Answer:
a)
XYZ *this;
b)
1. Assignment of private data members at the time of object creation.
2. When an object is passed by vale to a function.
3. When allocating memory dynamically we use copy constructor to avoid
dangling pointer issue.

Question No. 3 Marks : 05


class Complex
{
private:
double x,y;
static int z;
public:
Complex(double = 0.0);
friend ostream& operator<<(ostream&, const Complex&);
static int doSomething( ) { z = 2 * y; return z; }
};
a. What is wrong in the definition of member function doSomething( ). 03
Answer:
Static keyword because using static key word we are declaring a static member
function doSomething(). Which can not use non static data members.
b. What will be the effect of writing the friend function operator<<(…) in private part
of the above class? 02
Answer:
There will be no effect on friend function if we write it in private part. Friend
function is a friend function and can use any private or public data member of the class.
Where ever we declare it in class body.
www.vujannat.ning.com
MIDTERM EXAMINATION
SPRING 2006 Marks:
CS304 – object oriented programming (Session - 1 ) Time: 120min

StudentID/LoginID: ______________________________

Student Name: ______________________________

Center Name/Code: ______________________________

Exam Date:

Please read the following instructions carefully before attempting any


question:

1. This examination is closed book, closed notes, closed neighbors.

2. Answer all questions.

a. There is no choice.

b. You will have to answer all questions correctly in this examination to


get the maximum possible marks.

3. Do not ask any questions about the contents of this examination from
anyone.

a. If you think that there is something wrong with any of the questions,
attempt it to the best of your understanding.

b. If you believe that some essential piece of information is missing, make


an appropriate assumption and use it to solve the problem.

4. Examination also consists of multiple-choice questions. Choose only one


choice as your answer.

a. If you believe that two (or more) of the choices are the correct ones for
a particular question, choose the best one.

b. On the other hand, if you believe that all of the choices provided for a
particular question are the wrong ones, select the one that appears to
you as being the least wrong.

**WARNING: Please note that Virtual University takes serious note of unfair
means. Anyone found involved in cheating will get an `F` grade in this
course.
For Teacher's use only
Question 1 2 3 4 5 6 7 8 9 10 Total
Marks

Question No: 1 ( Marks: 2 )

int *p=new int;


In the code given above, memory is allocated during program:

• compilation
• linking
• execution
• loading

Question No: 2 ( Marks: 2 )


The proper syntax to free the memory allocated to array a of five objects is

• free(a,5);
• delete(a,5);
• delete a;
• delete [] a;

Question No: 3 ( Marks: 6 )


What methods would you add to make this class declaration very useful?

Class Cat
{
int GetAge() const;
private:
int itsAge;
};

Question No: 4 ( Marks: 18 )


Write a class Coordinate that performs the mathematical operations (Addition and
Multiplication) on its coordinates with the help of operator overloading.

Class Coordinate should have the following Private data members


1. xCord
2. yCord

a) Write a parameterized constructor to initialize its coordinates/data members.


b) Write member functions to Overload the following Operators and Display the Results
after Operations.
1. +
2. *
Question No: 5 ( Marks: 17 )
Create a class named Employee, its data members are

i. empName
ii. empDesignation
iii. empSalary

a) Create the object of this class using parameterized constructor in order to initialize
all the three data members i.e. empName, empDesignation and empSalary
b) Write a member function of this class named increment (), this function will
calculate the incremented salary of the employee. In increment function user will
enter the increment amount in the current salary of the employee and displays the
incremented salary after the addition of increment.
c) write the getter and setter functions for the data members of this class

Question No: 6 ( Marks: 2 ) - Please choose one

A system call

► Is an entry point into the kernel code

► Allows a program to request a kernel service

► Is a technique to protect I/O devices and other system resources

► All of the these

Question No: 7 ( Marks: 2 ) - Please choose one

Logical address is generated by,

► CPU

► Compiler

► Hard disk

► None of the these


WWW.vujannat.ning.com
http://vujannat.ning.com
Largest Online Community of VU Students

FINALTERM EXAMINATION
FALL 2006 Marks: 50
CS304 - OBJECT ORIENTED PROGRAMMING Time: 120min
(Session - 1 )

StudentID/LoginID: ______________________________

Student Name: ______________________________

Center Name/Code: ______________________________

Exam Date: Friday, February 09, 2007

Please read the following instructions carefully before attempting any


of the questions:
1. Attempt all questions. Marks are written adjacent to each question.
2. Do not ask any questions about the contents of this examination
from anyone.
a. If you think that there is something wrong with any of the
questions, attempt it to the best of your understanding.
b. If you believe that some essential piece of information is
missing, make an appropriate assumption and use it to solve the
problem.
c. Write all steps, missing steps may lead to deduction of marks.
d. All coding questions should be answered using the C ++ syntax.
e. Choose the most appropriate choice (among the given), while answering
MCQs.
3. You are not allowed to use IDE (Dev-C++ or any) in your paper.

**WARNING: Please note that Virtual University takes serious note of


unfair means. Anyone found involved in cheating will get an `F` grade
in this course.

For Teacher's use only


Question 1 2 3 4 5 6 7 8 9 Total
Marks
Question No: 1 ( Marks: 2 ) - Please choose one

Which of the statements is true about destructor?

► Destructors are used to initialize data members

► Destructors return types are always void

► Destructors are called in reverse order of constructor called in a class hierarchy

► Destructors are used to display the data members of their respective class

Question No: 2 ( Marks: 2 ) - Please choose one

Identify the type of variable that is part of a class, yet is not part of an object of that class.

► instance

► static

► global

► local

Question No: 3 ( Marks: 2 ) - Please choose one

Which of the following operators can not be overloaded?

► ++

► new

► sizeof

► =
Question No: 4 ( Marks: 2 ) - Please choose one

Target function for a call is selected at compile time in case of

► Static binding

► Polymorphism

► Encapsulation

► Dynamic binding

Question No: 5 ( Marks: 2 ) - Please choose one

Suppose it is required to implement a single functionality with different data type, which of the
following techniques should be used

► Inheritance

► Friend function

► Templates

► Encapsulation

Question No: 6 ( Marks: 5 )

Identify and correct the error(s) in the given code segment.

template< typename T >


class Parent {
// …
};

template< >
class Child< int > : public Parent {
// …
};

int main() {
Parent< char > obj;
Child< int > obj2;
return 0;
}

Question No: 7 ( Marks: 10 )

Given are two classes A and B. class B is inherited from class A. Write a code snippet(for main
function) that polymorphically call the method of class B. Also what changes do you suggest in the
given code segment that are required to call the class B method polymorphically.

class A
{
public:
void method() { cout<<"A's method \n"; }

};

class B : public A
{

public:
void method() { cout<<"B's method\n"; }

};

Question No: 8 ( Marks: 10 )

Implement the given class hierarchy where there exist a relation ship of inheritance between
Employee and Contract (for contract employee). The Display() function of Contract should
display the data that includes ; Name, Num_hours, Per_hour_sal, Salary

Monthly salary of contract employee is calculated as

Salary = Per_hour_sal*Num_hours
Question No: 9 ( Marks: 15 )

A Real world Problem:

This is a business rule of a bank that the Balance of customer must always be Positive,
Further that it is also a business rule that a customer can not withdraw amount greater than his/her
current balance.

Question statement
You are required to write a C++ program to solve this real world problem, using Exception
Handling.

Your program should consist of a class Customer and 4 instance variables. Cust_name,
Cust_AC_No, Cust_balance, Amount_withdraw.

Cust_name : Customer Name


Cust_AC_No : Customer Account Number
Cust_balance : Customer Balance
Amount_withdraw : Amount that is to be withdraw

The class should further consists of getter and setter function for each instance variable.
The setter function of Cust_balance consists of a try and a catch block, if the user enters the
balance less than zero (means negative, which is not possible) then this function should throw an
exception, and its corresponding catch block should handle this exception by providing another
opportunity to the user to enter the balance again.

Similarly the setter of Amount_withdraw variable should also have a try and a catch blocks. If the
user enters the withdraw amount greater than the current balance then this function should throw
an exception, and its corresponding catch block should handle this exception.
In main function just declare an object of Customer class and call all its setter and getter functions.
WWW.vujannat.ning.com
http://vujannat.ning.com
Largest Online Community of VU Students

MIDTERM EXAMINATION
SPRING 2007 Marks: 40
CS304 - OBJECT ORIENTED PROGRAMMING Time: 90min
(Session - 4 )

StudentID/LoginID: ______________________________

Student Name: ______________________________

Center Name/Code: ______________________________

Exam Date: Thursday, May 03, 2007

Please read the following instructions carefully before attempting any


of the questions:
1. Attempt all questions. Marks are written adjacent to each question.
2. Do not ask any questions about the contents of this examination
from anyone.
a. If you think that there is something wrong with any of the
questions, attempt it to the best of your understanding.
b. If you believe that some essential piece of information is
missing, make an appropriate assumption and use it to solve the
problem.
c. Write all steps, missing steps may lead to deduction of marks.
d. All coding questions should be answered using the C ++ syntax.
3. You are not allowed to use IDE (Dev-C++ or any) in your paper.
4. This paper is closed handouts.

**WARNING: Please note that Virtual University takes serious note of


unfair means. Anyone found involved in cheating will get an `F` grade
in this course.
For Teacher's use only
Question 1 2 3 4 5 6 7 8 9 10 Total
Marks

Question No: 1 ( Marks: 1 ) - Please choose one

The main function of scope resolution operator (::) is,

► To define an object

► To define a data member

► To link the definition of an identifier to its declaration

► All of the given

Question No: 2 ( Marks: 1 ) - Please choose one

What is a class?

► A class is a section of computer memory containing objects.

► A class is a section of the hard disk reserved for object oriented programs

► A class is the part of an object that contains the variables.

► A class is a description of a kind of object.

Question No: 3 ( Marks: 1 ) - Please choose one

Which of the following features of OOP is used to derive a class from another?

► Encapsulation

► Polymorphism

► Data hiding
► Inheritance

Question No: 4 ( Marks: 1 ) - Please choose one

Which of the following is an advantage of OOP?

► OOP makes it easy to re-use the code

► It provides an ability to create one user defined data type by extending the other

► It provides the facility of defining Abstract data types through which real world
entities can be defined better

► All of the given options

Question No: 5 ( Marks: 1 ) - Please choose one

Objects having identical characteristics belong to

► Same class

► Two different classes

► Any number of different classes

► Objects can not have identical characteristics

Question No: 6 ( Marks: 5 )

Write any two advantage(s) of declaring a member function as const?

Question No: 7 ( Marks: 10 )

Write the code for Deep copy constructor for the given class.

class MidTerm
{
private:
char* papername;
int Totalmarks;

// Code for Deep copy constructor

};

Question No: 8 ( Marks: 18 )

Write a program which consists of a class named Zakat and consists of two data members
OwnerName and Totalamount, the class should also consists of three constructors i.e. Default
constructor , one argument constructor and two argument constructor.
The class should further consists of a member function named Cal_zakat () which calculate the
zakat.
It should be keep in mind that the zakat will be calculated only if the Totalamount is greater than
or equal to 20,000.
In main, define three object of this class for respective constructors and also display the zakat for
each object.

Note: The zakat will be calculated by the formula (Totalamount * 2.5)/100;

Question No: 9 ( Marks: 1 ) - Please choose one

At the most, how many instances of certain class can be created?

► 1

► 6

► 3

► none of these

Question No: 10 ( Marks: 1 ) - Please choose one

class A
{
public:
virtual void MyVirtualMethod() = 0;
};
class B : public A
{
public:
void MyVirtualMethod()
{
//do something
}
};

Considering the given code, which of the following statements is correct?

► Class B is a an abstract class

► Class A is a concrete class

► Object of class A can not be instantiated

► Class B is a child class of class A

You might also like